lib/hieracles/formats/csv.rb in hieracles-0.3.6 vs lib/hieracles/formats/csv.rb in hieracles-0.4.0
- old
+ new
@@ -46,9 +46,19 @@
def build_modules_line(key, value)
make_csv [key, value]
end
+ def build_list(hash, notifications, filter)
+ if filter[0]
+ hash.select! { |k, e| Regexp.new(filter[0]).match k }
+ end
+ hash.reduce([]) do |a, (k, v)|
+ a << make_csv([k, v.join(',')])
+ a
+ end.join()
+ end
+
private
def build_line(whatfile, key, value, overriden = '0')
make_csv(in_what_file(whatfile) + [key, value.to_s, overriden])
end