Growstuff/growstuff

View on GitHub
app/views/plantings/index.csv.shaper

Summary

Maintainability
Test Coverage
csv.headers :id,
  :growstuff_url,
  :owner_id,
  :owner_name,
  :garden_id,
  :garden_name,
  :crop_id,
  :crop_name,
  :quantity,
  :planted_from,
  :sunniness,
  :date_planted,
  :finished,
  :date_finished,
  :description,
  :date_added,
  :last_modified,
  :license

@plantings.each do |p|
  csv.row p do |csv, planting|

    csv.cell :id
    csv.cell :growstuff_url, planting_url(p.slug)

    csv.cell :owner_id, p.owner_id
    csv.cell :owner_name, p.owner_login_name

    csv.cell :garden_id, p.garden_id
    csv.cell :garden_name, p.garden_name

    csv.cell :crop_id, p.crop_id
    csv.cell :crop_name, p.crop_name

    csv.cells :quantity, :planted_from, :sunniness

    csv.cell :date_planted, p.planted_at ? p.planted_at : ''

    csv.cell :finished
    csv.cell :date_finished, p.finished_at ? p.finished_at : ''

    csv.cell :description, p.description

    csv.cell :date_added, Time.at(p.created_at).to_fs(:db)
    csv.cell :last_modified, Time.at(p.updated_at).to_fs(:db)

    csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"

  end
end