Class: Hieracles::Formats::Yaml
Overview
format mostly useful for re-integration in param files
Instance Method Summary
collapse
-
#add_array(output, key, leaf, params, indent) ⇒ Object
-
#add_hash(output, key, leaf, params, indent) ⇒ Object
-
#add_string(output, key, leaf, params, indent) ⇒ Object
-
#allparams(args) ⇒ Object
-
#commented_yaml_tree(without_common = true) ⇒ Object
-
#files(_) ⇒ Object
-
#info(_) ⇒ Object
-
#mergetree(output, key, leaf, params) ⇒ Object
-
#modules(_) ⇒ Object
-
#params(args) ⇒ Object
-
#paths(_) ⇒ Object
#initialize, #show_params
Instance Method Details
#add_array(output, key, leaf, params, indent) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/hieracles/formats/yaml.rb', line 49
def add_array(output, key, leaf, params, indent)
yaml = leaf.to_yaml[4..-1]
aryaml = yaml.each_line.map do |l|
indent + l
end
output += "\n" + indent + "# " + params[key.join('.')][0][:file]
output += "\n" + aryaml.join().chomp
output
end
|
#add_hash(output, key, leaf, params, indent) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/hieracles/formats/yaml.rb', line 41
def add_hash(output, key, leaf, params, indent)
leaf.each do |k, v|
output += "\n" + indent + k + ': '
output = mergetree(output, key + [k], v, params)
end
output
end
|
#add_string(output, key, leaf, params, indent) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/hieracles/formats/yaml.rb', line 59
def add_string(output, key, leaf, params, indent)
output += leaf
if params["#{key.join('.')}"]
output += " # " + params[key.join('.')][0][:file]
end
output
end
|
#allparams(args) ⇒ Object
26
27
28
|
# File 'lib/hieracles/formats/yaml.rb', line 26
def allparams(args)
(false)
end
|
30
31
32
33
34
|
# File 'lib/hieracles/formats/yaml.rb', line 30
def (without_common = true)
tree = @node.params_tree(without_common)
params = Hash[@node.params(without_common)]
mergetree('---', [], tree, params)
end
|
#files(_) ⇒ Object
10
11
12
|
# File 'lib/hieracles/formats/yaml.rb', line 10
def files(_)
@node.files.to_yaml
end
|
#info(_) ⇒ Object
6
7
8
|
# File 'lib/hieracles/formats/yaml.rb', line 6
def info(_)
@node.info.to_yaml
end
|
#mergetree(output, key, leaf, params) ⇒ Object
36
37
38
39
|
# File 'lib/hieracles/formats/yaml.rb', line 36
def mergetree(output, key, leaf, params)
indent = ' ' * key.count
send("add_#{leaf.class.name.downcase}".to_sym, output, key, leaf, params, indent)
end
|
#modules(_) ⇒ Object
18
19
20
|
# File 'lib/hieracles/formats/yaml.rb', line 18
def modules(_)
@node.modules.to_yaml
end
|
#params(args) ⇒ Object
22
23
24
|
# File 'lib/hieracles/formats/yaml.rb', line 22
def params(args)
(true)
end
|
#paths(_) ⇒ Object
14
15
16
|
# File 'lib/hieracles/formats/yaml.rb', line 14
def paths(_)
@node.paths.to_yaml
end
|