Project

csv-omg

0.01
No commit activity in last 3 years
No release in over 3 years
CsvOmg easily lets you map CSV to objects. Inspired by happymapper.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0.6
~> 1.3.3
~> 0.10.0

Runtime

~> 1.5.4
 Project Readme

Overview stillmaintained

CsvOmg (formerly known as csvmapper) easily lets you map CSV to objects. Inspired by happymapper. Please check out the example below and included tests to see how it works.

Examples

module Shop
  class Product
    include CsvOmg

    col :name,           'product_name'
    col :uid,            'product_uid',    Integer
    col :description,    2
    col(:price_in_cents, 'product_price',  Float){|float| (float * 100).round }

  end
end

csv =<<-CSV.gsub(/^ +/,'')
  product_uid;product_name;product_description;product_price
  1200;Ham;like you never tasted before;19.99
CSV

p1 = Shop::Product.parse(csv, :col_sep => ';').first
p1.price_in_cents   # 1999

Requirements

FasterCSV

Installation

$ gem install csv-omg

Author

Gert Goet (eval) :: gert@thinkcreate.nl :: @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.