class Hieracles::Formats::Csv
for db compatibility
Constants
- CVS_DELIM
Public Instance Methods
build_head(without_common)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 23 def build_head(without_common) output = [] @node.files(without_common).each do |f| output << f end output += %w(var value overriden) make_csv output end
build_modules_line(key, value)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 47 def build_modules_line(key, value) make_csv [key, value] end
build_params_line(key, value, filter)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 32 def build_params_line(key, value, filter) output = '' if !filter || Regexp.new(filter).match(key) if value[:overriden] output << build_line('-', key, value[:value]) value[:found_in].each do |v| output << build_line(v[:file], key, v[:value], '1') end else output << build_line(value[:file], key, value[:value]) end end output end
facts(_)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 11 def facts(_) make_csv(@node.facts.keys) + make_csv(@node.facts.values) end
files(_)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 15 def files(_) make_csv @node.files end
info(_)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 7 def info(_) make_csv @node.info.values end
paths(_)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 19 def paths(_) make_csv @node.paths end
Private Instance Methods
build_line(whatfile, key, value, overriden = '0')
click to toggle source
# File lib/hieracles/formats/csv.rb, line 53 def build_line(whatfile, key, value, overriden = '0') make_csv(in_what_file(whatfile) + [key, value.to_s, overriden]) end
in_what_file(file)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 61 def in_what_file(file) output = [] @node.files.each do |f| if file == f output << '1' else output << '0' end end output end
make_csv(array)
click to toggle source
# File lib/hieracles/formats/csv.rb, line 57 def make_csv(array) array.join(CVS_DELIM) + "\n" end