gdocs_bootstrap

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

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

>> FuelType.bootstrap!
=> true

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  

would generate

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')

Copyright © 2009 Seamus Abshere. See LICENSE for details.