Skip to content

edmt/record_roo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RecordRoo

Easy object mapping from spreadsheets.

It provides a way to obtain an object that wraps a row within a spreadsheet.

Installation

Add this line to your application's Gemfile:

gem 'record_roo'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install record_roo

Usage

All you need is to know the location of your spreadsheet file:

> filepath = "myfile.xlsx"

Then, after you have included the RecordRoo module:

> ds = DataSource.new filepath

…or like this, if you haven't:

> ds = RecordRoo::DataSource.new filepath

You can just obtain an array of records by sending the :parse message.

> ds.parse
=> [["Key", "Name", "Price", "Category"], ["678678676", "PS4", "8000", "consoles"], ["234234234", "Coffee", "30", "snacks"]]    

Or, for better, obtain a collection of instances from one of your classes.

> ds.model_generator({model: Product,
    attributes: [:key, :name, :price, :category]})
=> [#<Product:0x007fc31a085ef0>, #<Product:0x007fc31a085c98>]

Keep in mind that for the desired result, you must specify the correct order of the attributes, based on your spreadsheet.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

RecordRoo is built on top of Roo, a Ruby gem that implements read access for all spreadsheet types, among other things.

Anything we missed?

If there is anything at all that you need or want to know, please feel free to open a Issue.

Thank you! ಠ‿ಠ

About

Easy object mapping from spreadsheets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages