oozou-fusion_tables 0.2.3.dev.20110408163600
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/CHANGELOG +6 -0
- data/LICENSE +20 -0
- data/README.textile +148 -0
- data/Rakefile +54 -0
- data/TODO +11 -0
- data/VERSION +1 -0
- data/examples/boris_bikes.rb +159 -0
- data/examples/compare_tweets.rb +143 -0
- data/examples/credentials.example.yml +4 -0
- data/fusion_tables.gemspec +78 -0
- data/lib/fusion_tables.rb +6 -0
- data/lib/fusion_tables/client/fusion_tables.rb +77 -0
- data/lib/fusion_tables/data/data.rb +72 -0
- data/lib/fusion_tables/data/table.rb +144 -0
- data/lib/fusion_tables/ext/fusion_tables.rb +96 -0
- data/pkg/fusion_tables-0.1.0.gem +0 -0
- data/pkg/fusion_tables-0.1.1.gem +0 -0
- data/pkg/fusion_tables-0.1.2.gem +0 -0
- data/pkg/fusion_tables-0.2.0.gem +0 -0
- data/pkg/fusion_tables-0.2.1.gem +0 -0
- data/pkg/fusion_tables-0.2.2.gem +0 -0
- data/test/README +3 -0
- data/test/helper.rb +34 -0
- data/test/test_client.rb +22 -0
- data/test/test_config.yml.sample +3 -0
- data/test/test_ext.rb +58 -0
- data/test/test_table.rb +76 -0
- metadata +110 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/README
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'fusion_tables'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
|
12
|
+
def init_config
|
13
|
+
if not defined? @config_file
|
14
|
+
begin
|
15
|
+
@config_file = YAML::load_file(File.join(File.dirname(__FILE__), 'test_config.yml'))
|
16
|
+
rescue
|
17
|
+
puts "Please configure your test_config.yml file using test_config.yml.sample as base"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@config_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def username
|
24
|
+
@config_file['username']
|
25
|
+
end
|
26
|
+
|
27
|
+
def password
|
28
|
+
@config_file['password']
|
29
|
+
end
|
30
|
+
|
31
|
+
def table_name
|
32
|
+
@config_file['table_name']
|
33
|
+
end
|
34
|
+
end
|
data/test/test_client.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestClient < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "The fusion_tables client library" do
|
6
|
+
setup do
|
7
|
+
init_config
|
8
|
+
@ft = GData::Client::FusionTables.new
|
9
|
+
@ft.clientlogin(username, password)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "be properly setup" do
|
13
|
+
assert_equal @ft.clientlogin_service, "fusiontables"
|
14
|
+
assert_equal @ft.headers["Content-Type"], "application/x-www-form-urlencoded"
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be able to authenticate with the google services" do
|
18
|
+
assert_equal @ft.auth_handler.service, "fusiontables"
|
19
|
+
assert @ft.auth_handler.token
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/test_ext.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestExt < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "The Fusion Tables helper functions" do
|
6
|
+
setup do
|
7
|
+
init_config
|
8
|
+
@ft = GData::Client::FusionTables.new
|
9
|
+
@ft.clientlogin(username, password)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
should "raise ArgumentError if supply unknown types to it" do
|
14
|
+
assert_raise ArgumentError do
|
15
|
+
@ft.create_table "test table", [{:name => "test_col", :type => "billys birthday" }]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
should "let you create a table if you get everything right" do
|
20
|
+
table = @ft.create_table "test_table", [{:name => "test_col", :type => "string" }]
|
21
|
+
assert_equal table.class, GData::Client::FusionTables::Table
|
22
|
+
@ft.drop(table.id)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "correct your table name to a certain degree on create" do
|
26
|
+
table = @ft.create_table "test table", [{:name => "test col", :type => "string" }]
|
27
|
+
assert_equal table.name, "test_table"
|
28
|
+
@ft.drop(table.id)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "return you a list of your fusion tables" do
|
32
|
+
resp = @ft.show_tables
|
33
|
+
assert_equal resp.first.class, GData::Client::FusionTables::Table if resp.first
|
34
|
+
end
|
35
|
+
|
36
|
+
should "be possible to delete a table with an id" do
|
37
|
+
table = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
|
38
|
+
assert_equal @ft.drop(table.id), 1
|
39
|
+
end
|
40
|
+
|
41
|
+
should "be possible to delete tables with an array of ids" do
|
42
|
+
table1 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
|
43
|
+
table2 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
|
44
|
+
assert_equal @ft.drop([table1.id, table2.id]), 2
|
45
|
+
end
|
46
|
+
|
47
|
+
should "be possible to delete multiple tables with a regex" do
|
48
|
+
table1 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
|
49
|
+
table2 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
|
50
|
+
assert_equal @ft.drop(/^test_/), 2
|
51
|
+
end
|
52
|
+
|
53
|
+
should "return zero if passed a silly id" do
|
54
|
+
assert_equal @ft.drop(235243875629384756), 0
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/test/test_table.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTable < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "uploading data to FT" do
|
6
|
+
setup do
|
7
|
+
init_config
|
8
|
+
@ft = GData::Client::FusionTables.new
|
9
|
+
@ft.clientlogin(username, password)
|
10
|
+
@table = @ft.create_table "test", [{:name => 'firstname', :type => 'string'},
|
11
|
+
{:name => 'phone', :type => 'number'},
|
12
|
+
{:name => 'dob', :type => 'datetime'},
|
13
|
+
{:name => 'house', :type => 'location'}]
|
14
|
+
end
|
15
|
+
|
16
|
+
should "format data and prep for upload" do
|
17
|
+
data = @table.encode [{:firstname => "\\bob's piz\za",
|
18
|
+
:phone => 12,
|
19
|
+
:dob => Time.utc(2010,"aug",10,20,15,1),
|
20
|
+
:house => "POINT(1,1)"}]
|
21
|
+
|
22
|
+
row = data.first
|
23
|
+
assert_equal row[:firstname], "'\\\\bob''s pizza'"
|
24
|
+
assert_equal row[:phone], "#{12}"
|
25
|
+
assert_equal row[:dob], "'08-10-2010'"
|
26
|
+
assert_equal row[:house], "'POINT(1,1)'"
|
27
|
+
end
|
28
|
+
|
29
|
+
should "be able to insert 1 row of data" do
|
30
|
+
data = 1.times.inject([]) { |a,i|
|
31
|
+
a << {:firstname => "\\bob's piz\za-#{i}",
|
32
|
+
:phone => 12,
|
33
|
+
:dob => Time.utc(2010,"aug",10,20,15,1),
|
34
|
+
:house => '<Point><coordinates>-74.006393,40.714172,0</coordinates></Point>'}
|
35
|
+
}
|
36
|
+
|
37
|
+
@table.insert data
|
38
|
+
end
|
39
|
+
|
40
|
+
should "be able to insert 501 rows of data" do
|
41
|
+
data = 501.times.inject([]) { |a,i|
|
42
|
+
a << {:firstname => "Person-#{i}",
|
43
|
+
:phone => 12,
|
44
|
+
:dob => Time.utc(2010,"aug",10,20,15,1),
|
45
|
+
:house => "<Point><coordinates>#{180-rand(360)},#{90-rand(180)},0</coordinates></Point>"}
|
46
|
+
}
|
47
|
+
|
48
|
+
@table.insert data
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
should "be able to count the number of rows" do
|
53
|
+
data = 2.times.inject([]) { |a,i|
|
54
|
+
a << {:firstname => "Person-#{i}",
|
55
|
+
:phone => 12,
|
56
|
+
:dob => Time.utc(2010,"aug",10,20,15,1),
|
57
|
+
:house => "<Point><coordinates>#{180-rand(360)},#{90-rand(180)},0</coordinates></Point>"}
|
58
|
+
}
|
59
|
+
|
60
|
+
@table.insert data
|
61
|
+
assert_equal @table.count, 2
|
62
|
+
end
|
63
|
+
|
64
|
+
should "be able to select the rows" do
|
65
|
+
data = 2.times.inject([]) { |a,i|
|
66
|
+
a << {:firstname => "Person-#{i}",
|
67
|
+
:phone => 12,
|
68
|
+
:dob => Time.utc(2010,"aug",10,20,15,1),
|
69
|
+
:house => "<Point><coordinates>1,1,0</coordinates></Point>"}
|
70
|
+
}
|
71
|
+
|
72
|
+
@table.insert data
|
73
|
+
assert_equal @table.select, [{:firstname=>"Person-0", :phone=>"12", :dob=>"08-10-2010", :house=>"<Point><coordinates>1,1,0</coordinates></Point>"}, {:firstname=>"Person-1", :phone=>"12", :dob=>"08-10-2010", :house=>"<Point><coordinates>1,1,0</coordinates></Point>"}]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oozou-fusion_tables
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.2.3.dev.20110408163600
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Simon Tokumine
|
9
|
+
- Tom Verbeure
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-04-08 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: thoughtbot-shoulda
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gdata_19
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.1.2
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: A simple Google Fusion Tables API wrapper. Supports bulk inserts and most API functions
|
39
|
+
email: simon@tinypla.net
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- LICENSE
|
46
|
+
- README.textile
|
47
|
+
- TODO
|
48
|
+
files:
|
49
|
+
- .document
|
50
|
+
- CHANGELOG
|
51
|
+
- LICENSE
|
52
|
+
- README.textile
|
53
|
+
- Rakefile
|
54
|
+
- TODO
|
55
|
+
- VERSION
|
56
|
+
- examples/boris_bikes.rb
|
57
|
+
- examples/compare_tweets.rb
|
58
|
+
- examples/credentials.example.yml
|
59
|
+
- fusion_tables.gemspec
|
60
|
+
- lib/fusion_tables.rb
|
61
|
+
- lib/fusion_tables/client/fusion_tables.rb
|
62
|
+
- lib/fusion_tables/data/data.rb
|
63
|
+
- lib/fusion_tables/data/table.rb
|
64
|
+
- lib/fusion_tables/ext/fusion_tables.rb
|
65
|
+
- pkg/fusion_tables-0.1.0.gem
|
66
|
+
- pkg/fusion_tables-0.1.1.gem
|
67
|
+
- pkg/fusion_tables-0.1.2.gem
|
68
|
+
- pkg/fusion_tables-0.2.0.gem
|
69
|
+
- pkg/fusion_tables-0.2.1.gem
|
70
|
+
- pkg/fusion_tables-0.2.2.gem
|
71
|
+
- test/README
|
72
|
+
- test/helper.rb
|
73
|
+
- test/test_client.rb
|
74
|
+
- test/test_config.yml.sample
|
75
|
+
- test/test_ext.rb
|
76
|
+
- test/test_table.rb
|
77
|
+
homepage: http://github.com/oozou/fusion-tables
|
78
|
+
licenses: []
|
79
|
+
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.1
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.7.1
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: Google Fusion Tables API wrapper
|
104
|
+
test_files:
|
105
|
+
- examples/boris_bikes.rb
|
106
|
+
- examples/compare_tweets.rb
|
107
|
+
- test/helper.rb
|
108
|
+
- test/test_client.rb
|
109
|
+
- test/test_ext.rb
|
110
|
+
- test/test_table.rb
|