lib/hieracles/formats/csv.rb in hieracles-0.2.0 vs lib/hieracles/formats/csv.rb in hieracles-0.2.1
- old
+ new
@@ -6,10 +6,14 @@
def info(_)
make_csv @node.info.values
end
+ def facts(_)
+ make_csv(@node.facts.keys) + make_csv(@node.facts.values)
+ end
+
def files(_)
make_csv @node.files
end
def paths(_)
@@ -28,31 +32,31 @@
def build_params_line(key, value, filter)
output = ''
if !filter || Regexp.new(filter).match(key)
first = value.pop
if is_merged? first
- output << make_csv(in_what_file('-') +
- [key, first[:merged].to_s, '0'])
- output << make_csv(in_what_file(first[:file]) +
- [key, first[:value].to_s, '1'])
+ output << build_line('-', key, first[:merged])
+ output << build_line(first[:file], key, first[:value], '1')
else
- output << make_csv(in_what_file(first[:file]) +
- [key, first[:value].to_s, '0'])
+ output << build_line(first[:file], key, first[:value])
end
while value.count > 0
overriden = value.pop
- output << make_csv(in_what_file(overriden[:file]) +
- [key, overriden[:value].to_s, '1'])
+ output << build_line(overriden[:file], key, overriden[:value], '1')
end
end
output
end
def build_modules_line(key, value)
make_csv [key, value]
end
private
+
+ def build_line(whatfile, key, value, overriden = '0')
+ make_csv(in_what_file(whatfile) + [key, value.to_s, overriden])
+ end
def make_csv(array)
array.join(CVS_DELIM) + "\n"
end