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.
name emission_factor units coal 5246.89 lbs/short ton natural gas 1.25 pounds / therm (nat gas) fuel oil 22.51 lbs/gallon
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 © 2009 Seamus Abshere. See LICENSE for details.