fusion_tables
This gem lets you easily interact with Google Fusion Tables API from your Ruby application via a plain SQL interface, or an object orientated interface.
upgrading to current (v0.4)
Thanks to DerekEder's work, v0.4 supports the new Fusion Tables JSON API rather than the now defunct CSV API. This has introduced some small (but possibly breaking) changes:
- Geometry is returned as GeoJSON rather than KML.
- Null values are returned as empty strings (the FT API does this, so we're a bit stuck here).
- You need to supply an api_key to use the service. You can get an API key from your Google API console.
See the example below and tests for more.
Demo and examples
Installation
gem install fusion_tables
Gem Dependencies
Rubies
Usage
require 'fusion_tables'
@ft = GData::Client::FusionTables.new
@ft.clientlogin(username, password)
@ft.set_api_key(api_key)
@ft.execute "SHOW TABLES"
@ft.execute "INSERT INTO #{my_table_id} (name, geo) VALUES ('tokyo', '35.6894 139.6917');"
@ft.execute "SELECT count() FROM #{my_table_id};"
@ft.show_tables
table_1.id
table_1.count
table_1.select
table_1.select "name", "WHERE x=n"
row_ids = table_1.select "ROWID"
@ft.drop table_1.id
@ft.drop [table_1.id, table_2.id]
@ft.drop /yacht/
cols = [{:name => "friend name", :type => 'string' },
{:name => "age", :type => 'number' },
{:name => "meeting time", :type => 'datetime' },
{:name => "where", :type => 'location' }]
new_table = @ft.create_table "My upcoming meetings", cols
data = [{"friend name" => "Eric Wimp",
"age" => 25,
"meeting time" => Time.utc(2010,"aug",10,20,15,1),
"where" => "29 Acacia Road, Nuttytown"}]
new_table.insert data
new_table.update 1, [{"friend name" => "Bananaman"}]
new_table.delete 1
new_table.truncate!
Known Issues
- The Google gdata_19 gem conflicts with the GData2 gem. Only current fix is to uninstall GData2.
- You have to make a table public before you can display it on a map. This can only be done via FT web interface.
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a
future version unintentionally.
- Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request.
Contributors
Largely based on Tom Verbeure's work for MTBGuru
- tokumine
- sikachu
- troy
- wynst
- sdball
- jmannau
- tomykaira
- fallanic
- derekeder