Sha256: 544723f390143aec3bd3a1dd464bacdf269beba165e964c29849a31e09221168

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

= gdocs_bootstrap

<tt>
class FuelType
  gdoc_bootstrap :url => 'http://spreadsheets.google.com/pub?key=p70r3FHguhimIdBKyVz3iPA&output=csv&gid=0'
end
</tt>

This lets you bootstrap your ActiveRecord models with Google Docs spreadsheets.

<tt>
>> FuelType.bootstrap!
=> true
</tt>

== Spreadsheet structure

The first column is always the key.

All of the other columns will be included as attributes, based on the column headers.

<tt>
name          emission_factor   units
coal          5246.89           lbs/short ton
natural gas   1.25              pounds / therm (nat gas)
fuel oil      22.51             lbs/gallon
</tt>

would generate

<tt>
a = FuelType.find_or_create_by_name('coal')
a.update_attributes(:name => 'coal', :emission_factor => '5246.89', :units => 'lbs/short ton')

a = FuelType.find_or_create_by_name('natural gas')
a.update_attributes(:name => 'coal', :emission_factor => '1.25', :units => 'pounds / therm (nat gas)')

a = FuelType.find_or_create_by_name('fuel oil')
a.update_attributes(:name => 'coal', :emission_factor => '22.51', :units => 'lbs/gallon')
</tt>

== Copyright

Copyright (c) 2009 Seamus Abshere. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seamusabshere-gdocs_bootstrap-0.0.1 README.rdoc