https://github.com/eval/csv-omg
Easily map CSV to objects
https://github.com/eval/csv-omg
Last synced: about 1 month ago
JSON representation
Easily map CSV to objects
- Host: GitHub
- URL: https://github.com/eval/csv-omg
- Owner: eval
- License: mit
- Created: 2011-04-08T09:43:52.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-04-13T13:16:09.000Z (about 14 years ago)
- Last Synced: 2025-04-19T06:05:09.575Z (about 2 months ago)
- Language: Ruby
- Homepage: https://github.com/eval/csv-omg
- Size: 101 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Overview [](http://stillmaintained.com/eval/csv-omg)
========CsvOmg (formerly known as [csvmapper](https://github.com/thinkcreate/csvmapper)) easily lets you map CSV to objects. Inspired by [happymapper](https://github.com/jnunemaker/happymapper).
Please check out the example below and included tests to see how it works.Examples
-----module Shop
class Product
include CsvOmgcol :name, 'product_name'
col :uid, 'product_uid', Integer
col :description, 2
col(:price_in_cents, 'product_price', Float){|float| (float * 100).round }end
endcsv =<<-CSV.gsub(/^ +/,'')
product_uid;product_name;product_description;product_price
1200;Ham;like you never tasted before;19.99
CSVp1 = Shop::Product.parse(csv, :col_sep => ';').first
p1.price_in_cents # 1999Requirements
------------[FasterCSV](https://rubygems.org/gems/fastercsv)
Installation
------------$ gem install csv-omg
Author
------Gert Goet (eval) :: [email protected] :: @gertgoet
License
------(The MIT license)
Copyright (c) 2011 Gert Goet, ThinkCreate
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.