Dumpster

Code Climate Build Status

Abstraction layer to export tabular data. Currently dumpster supports XLSX and CSV exports.

Installation

Add this line to your application's Gemfile:

gem 'dumpster'

Or install it yourself as:

$ gem install dumpster

Usage

data = [['col1-row1', 'col2-row1'], ['col1-row2', 'col2-row2']]
model = Dumpster::Model::Generic.new(data)

writer = Dumpster.csv_writer(model)
writer = Dumpster.csv_writer(model, :type => :windows)
writer = Dumpster.excel_writer(model)

writer.write_to_file('/some/directory/some.file')

ActiveRecord

Dumpster ships with a Dumpster::Model::ActiveRecordSql. This model allows you to execute arbitrary SQL through ActiveRecord to export the result.

model = Dumpster::Model::ActiveRecordSql.new('SELECT * from users')

writer = Dumpster.csv_writer(model) # for CSV output
writer = Dumpster.excel_writer(model) # for Excel output

writer.write_to_file('/some/directory/some.file')

Contributing

Please read the contribution guidelines before submitting code.

githalytics.com alpha