fusion_tables 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,10 +4,15 @@ fusion_tables
4
4
 
5
5
  This gem lets you easily interact with [Google Fusion Tables API](http://www.google.com/fusiontables/Home) from your Ruby application via a plain SQL interface, or an object orientated interface.
6
6
 
7
- v0.4 updates
8
- ------------
9
- Note that v0.4 onwards of this gem returns geometry as GeoJSON rather than KML by default.
7
+ upgrading to current (v0.4)
8
+ --------------------------
9
+ 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:
10
10
 
11
+ 1. Geometry is returned as GeoJSON rather than KML.
12
+ 2. Null values are returned as empty strings (the FT API does this, so we're a bit stuck here).
13
+ 3. You need to supply an api_key to use the service. You can get an API key from your Google API console.
14
+
15
+ See the example below and tests for more.
11
16
 
12
17
  Demo and examples
13
18
  ------------------
@@ -140,4 +145,4 @@ Largely based on Tom Verbeure's [work for MTBGuru](http://code.google.com/p/mtbg
140
145
  * jmannau
141
146
  * tomykaira
142
147
  * fallanic
143
- * derekeder
148
+ * derekeder
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fusion_tables"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Simon Tokumine", "Tom Verbeure"]
12
- s.date = "2013-01-14"
12
+ s.date = "2013-01-17"
13
13
  s.description = "A simple Google Fusion Tables API wrapper. Supports bulk inserts and most API functions"
14
14
  s.email = "simon@tinypla.net"
15
15
  s.extra_rdoc_files = [
@@ -27,19 +27,21 @@ module GData
27
27
  end
28
28
 
29
29
  def sql_encode(sql)
30
- # puts sql
31
30
  "sql=" + CGI::escape(sql)
32
31
  end
33
32
 
34
33
  def sql_get(sql)
34
+ raise ArgumentError, "need api key" if @api_key.nil?
35
35
  resp = self.get(SERVICE_URL + "?" + sql_encode(sql) + "&key=#{@api_key}")
36
36
  end
37
37
 
38
38
  def sql_post(sql)
39
+ raise ArgumentError, "need api key" if @api_key.nil?
39
40
  resp = self.post(SERVICE_URL, sql_encode(sql) + "&key=#{@api_key}")
40
41
  end
41
42
 
42
43
  def sql_put(sql)
44
+ raise ArgumentError, "need api key" if @api_key.nil?
43
45
  resp = self.put(SERVICE_URL, sql_encode(sql) + "&key=#{@api_key}")
44
46
  end
45
47
 
@@ -21,7 +21,10 @@ module GData
21
21
  http_req = sql.upcase.match(/^(DESCRIBE|SHOW|SELECT)/) ? :sql_get : :sql_post
22
22
  json_resp = JSON.parse(self.send(http_req, sql).body)
23
23
 
24
- # probably a much cleaner way to do this
24
+ if json_resp['rows'].nil?
25
+ return []
26
+ end
27
+
25
28
  rows = json_resp['rows']
26
29
  columns = json_resp['columns']
27
30
  correlated = []
@@ -18,5 +18,12 @@ class TestClient < Test::Unit::TestCase
18
18
  assert_equal "fusiontables", @ft.auth_handler.service
19
19
  assert @ft.auth_handler.token
20
20
  end
21
+
22
+ should "raise ArgumentError if no api key supplied" do
23
+ @ft.set_api_key(nil)
24
+ assert_raise ArgumentError do
25
+ @ft.sql_get "SHOW TABLES"
26
+ end
27
+ end
21
28
  end
22
29
  end
@@ -66,6 +66,11 @@ class TestTable < Test::Unit::TestCase
66
66
 
67
67
  assert_equal 1, ret.first[:"count()"].to_i
68
68
  end
69
+
70
+ should "return empty array if no results found" do
71
+ ret = @ft.execute "SELECT * FROM #{@table.id} WHERE firstname = 0;"
72
+ assert_equal [], ret
73
+ end
69
74
 
70
75
  # should "be able to query geographic data" do
71
76
  # @table = @ft.create_table "test", [{:name => 'name', :type => 'string'},
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusion_tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-14 00:00:00.000000000 Z
13
+ date: 2013-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thoughtbot-shoulda