0

アプリの構成を 1 点だけにするために、有効な Ruby コードでもある YAML 構成ファイルを作成する必要があります。つまり、YAML として解析し、Ruby として解析できる混合構文ファイルです。

私のアプリケーションは、godgem によって管理される一連のプロセスです。新しい構成ファイルごとに、管理されているプロセス (監視) の新しいグループをロードしたいと考えています。

God は、新しいウォッチが定義された新しい app.god (ruby) ファイルをロードすることを許可しますが、app.god と app.yml を 1 つのファイルだけにしたくありません。app.god ファイルを用意し、その中に構成を含めるのが最も簡単かもしれませんが、有効な Ruby コードでもある yml ファイルのアイデアを好みました。

4

1 に答える 1

0
#I found this that might be helpful:
#This is a valid ruby and a valid YAML file
#Comments are the same in YAML and ruby

true ?true: 
- <<YAML.to_i
# At this point in ruby it is the contents of a here doc (that will be 
# converted to an integer and negated if true happens not to be true)
# In YAML it is a hash with the first entry having key "true ?true"
# representing a list containing the string "- <<YAML.to_i"
# If your YAML object should be a list not a hash you could remove the first line

any_valid_yaml:  from here
a_list:
- or
- anything
- really
#Then mark the end of the YAML document with 
---
#And YAML is done and ignores anything from here on
#Next terminate the ruby here document
YAML

#Now we're in ruby world

@this = "pure ruby"

def anything(ruby)
   "here"
end
于 2014-04-10T08:33:22.073 に答える