lib/chronicle/etl/loaders/table_loader.rb in chronicle-etl-0.2.3 vs lib/chronicle/etl/loaders/table_loader.rb in chronicle-etl-0.2.4

- old
+ new

@@ -5,17 +5,18 @@ class TableLoader < Chronicle::ETL::Loader def initialize(options) super(options) end - def load(result) - @table ||= TTY::Table.new(header: result.keys) - values = result.values.map{|x| x.to_s[0..30]} + def load(record) + record_hash = record.to_h_flattened + @table ||= TTY::Table.new(header: record_hash.keys) + values = record_hash.values.map{|x| x.to_s[0..30]} @table << values end def finish - puts @table.render(:ascii, padding: [0, 1]) + puts @table.render(:ascii, padding: [0, 1]) if @table end end end end