0.0
No commit activity in last 3 years
No release in over 3 years
CSV generator utilising the decorator pattern
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 1.1.0
 Project Readme

Decorator CSV

This is a simple gem that lets you generate CSVs using the decorator pattern.

Requirements

This gem is compatible with ruby 1.9.3

This gem uses Draper as the decorator.

The decorator requires the following methods and constants to be available:

  • #as_csv_row
  • CSV_HEADER_ROW

How To Use

Firstly setup your Draper decorator with the required methods and constants. For example

class PersonDecorator < Draper::Decorator

  decorate :person

  CSV_HEADER_ROW = ['First Name', 'Last Name', 'Age']

  def as_csv_row
    [
      source.first_name,
      source.last_name,
      source.age
    ]
  end

end

Then call the generate method:

people = [person, another_person, third_person]
csv = DecoratedCSV.generate(PersonDecorator, people)