CSVKit is a middleware component aimed to allow tables found in a rails page to be effortlessly converted into a csv that can be read in excel (tsv format).
By adding and configuring the middleware you can visit .csv format pages with tables and instantly get the .csv versions of them without having to build a processor or formatter.
Add this line to your application's Gemfile:
gem 'csvkit'
And then execute:
$ bundle
Or install it yourself as:
$ gem install csvkit
Include the following in your application.rb
file
require 'csvkit'
config.middleware.use CSVKit::Middleware, {}#, :only => [%r[^/reports], %r[^/budgeting]]
There are two hashes passed in after config.middleware.use CSVKit::Middleware
, the options
hash and the conditions
hash.
This is not currently used.
The conditions hash supports the following attributes:
:only
which is an array of regular expressions to support .csv conversion on:except
which is an array of regular expressions to exclude .csv conversion on
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Author:: Mathew Hartley ([email protected])