simplegeo 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +20 -7
- data/LICENSE +1 -1
- data/README.rdoc +108 -3
- data/Rakefile +14 -16
- data/VERSION +1 -1
- data/lib/simple_geo/client.rb +171 -0
- data/lib/simple_geo/connection.rb +109 -0
- data/lib/simple_geo/endpoint.rb +71 -0
- data/lib/simple_geo/hash_utils.rb +24 -0
- data/lib/simple_geo/record.rb +56 -0
- data/lib/simple_geo.rb +23 -0
- data/lib/simplegeo.rb +2 -177
- data/simplegeo.gemspec +41 -27
- data/spec/client_spec.rb +1180 -0
- data/spec/fixtures/contains.json +127 -0
- data/spec/fixtures/get_density_by_day.json +833 -0
- data/spec/fixtures/get_density_by_hour.json +36 -0
- data/spec/fixtures/get_history.json +13 -0
- data/spec/fixtures/get_nearby.json +84 -0
- data/spec/fixtures/get_record.json +38 -0
- data/spec/fixtures/get_records.json +197 -0
- data/spec/fixtures/layer_info.json +8 -0
- data/spec/fixtures/nearby_address.json +21 -0
- data/spec/fixtures/no_such_record.json +4 -0
- data/spec/fixtures/nonetype_not_iterable.json +4 -0
- data/spec/fixtures/overlaps.json +41 -0
- data/spec/spec_helper.rb +21 -7
- metadata +61 -46
- data/spec/simplegeo_spec.rb +0 -89
- data/spec/test_keys.yml +0 -2
metadata
CHANGED
@@ -1,94 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplegeo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.3
|
10
|
+
version: 0.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
|
-
-
|
13
|
+
- Dan Dofter
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-05-12 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: oauth
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
27
30
|
segments:
|
28
|
-
- 1
|
29
|
-
- 3
|
30
31
|
- 0
|
31
|
-
|
32
|
-
|
32
|
+
- 4
|
33
|
+
- 0
|
34
|
+
version: 0.4.0
|
35
|
+
type: :runtime
|
33
36
|
version_requirements: *id001
|
34
37
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
38
|
+
name: json_pure
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
|
-
|
44
|
-
|
45
|
-
version: 0.1.12
|
46
|
-
type: :development
|
48
|
+
version: "0"
|
49
|
+
type: :runtime
|
47
50
|
version_requirements: *id002
|
48
51
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
52
|
+
name: rspec
|
50
53
|
prerelease: false
|
51
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
52
56
|
requirements:
|
53
57
|
- - ">="
|
54
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 31
|
55
60
|
segments:
|
61
|
+
- 1
|
62
|
+
- 2
|
56
63
|
- 0
|
57
|
-
|
58
|
-
|
59
|
-
version: 0.3.6
|
60
|
-
type: :runtime
|
64
|
+
version: 1.2.0
|
65
|
+
type: :development
|
61
66
|
version_requirements: *id003
|
62
67
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
68
|
+
name: fakeweb
|
64
69
|
prerelease: false
|
65
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
66
72
|
requirements:
|
67
73
|
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
- 0
|
71
|
-
- 1
|
72
|
-
- 7
|
73
|
-
version: 0.1.7
|
74
|
-
type: :runtime
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: json
|
78
|
-
prerelease: false
|
79
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
75
|
+
hash: 31
|
83
76
|
segments:
|
84
77
|
- 1
|
85
78
|
- 2
|
86
|
-
-
|
87
|
-
version: 1.2.
|
88
|
-
type: :
|
89
|
-
version_requirements: *
|
90
|
-
description:
|
91
|
-
email:
|
79
|
+
- 0
|
80
|
+
version: 1.2.0
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id004
|
83
|
+
description:
|
84
|
+
email: dan@dofter.com
|
92
85
|
executables: []
|
93
86
|
|
94
87
|
extensions: []
|
@@ -97,19 +90,37 @@ extra_rdoc_files:
|
|
97
90
|
- LICENSE
|
98
91
|
- README.rdoc
|
99
92
|
files:
|
93
|
+
- .document
|
100
94
|
- .gitignore
|
101
95
|
- LICENSE
|
102
96
|
- README.rdoc
|
103
97
|
- Rakefile
|
104
98
|
- VERSION
|
99
|
+
- lib/simple_geo.rb
|
100
|
+
- lib/simple_geo/client.rb
|
101
|
+
- lib/simple_geo/connection.rb
|
102
|
+
- lib/simple_geo/endpoint.rb
|
103
|
+
- lib/simple_geo/hash_utils.rb
|
104
|
+
- lib/simple_geo/record.rb
|
105
105
|
- lib/simplegeo.rb
|
106
106
|
- simplegeo.gemspec
|
107
|
-
- spec/
|
107
|
+
- spec/client_spec.rb
|
108
|
+
- spec/fixtures/contains.json
|
109
|
+
- spec/fixtures/get_density_by_day.json
|
110
|
+
- spec/fixtures/get_density_by_hour.json
|
111
|
+
- spec/fixtures/get_history.json
|
112
|
+
- spec/fixtures/get_nearby.json
|
113
|
+
- spec/fixtures/get_record.json
|
114
|
+
- spec/fixtures/get_records.json
|
115
|
+
- spec/fixtures/layer_info.json
|
116
|
+
- spec/fixtures/nearby_address.json
|
117
|
+
- spec/fixtures/no_such_record.json
|
118
|
+
- spec/fixtures/nonetype_not_iterable.json
|
119
|
+
- spec/fixtures/overlaps.json
|
108
120
|
- spec/spec.opts
|
109
121
|
- spec/spec_helper.rb
|
110
|
-
- spec/test_keys.yml
|
111
122
|
has_rdoc: true
|
112
|
-
homepage: http://github.com/
|
123
|
+
homepage: http://github.com/simplegeo/simplegeo-ruby
|
113
124
|
licenses: []
|
114
125
|
|
115
126
|
post_install_message:
|
@@ -118,26 +129,30 @@ rdoc_options:
|
|
118
129
|
require_paths:
|
119
130
|
- lib
|
120
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
121
133
|
requirements:
|
122
134
|
- - ">="
|
123
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
124
137
|
segments:
|
125
138
|
- 0
|
126
139
|
version: "0"
|
127
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
145
|
+
hash: 3
|
131
146
|
segments:
|
132
147
|
- 0
|
133
148
|
version: "0"
|
134
149
|
requirements: []
|
135
150
|
|
136
151
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.3.
|
152
|
+
rubygems_version: 1.3.7
|
138
153
|
signing_key:
|
139
154
|
specification_version: 3
|
140
|
-
summary:
|
155
|
+
summary: A SimpleGeo Ruby Client
|
141
156
|
test_files:
|
142
|
-
- spec/
|
157
|
+
- spec/client_spec.rb
|
143
158
|
- spec/spec_helper.rb
|
data/spec/simplegeo_spec.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Simplegeo" do
|
4
|
-
it "should be able to get an access token" do
|
5
|
-
access_token = Simplegeo.get_access_token(@test_keys['key'], @test_keys['secret'])
|
6
|
-
result = access_token.get("/0.1/records/com.simplegeo.us.zip/98122.json")
|
7
|
-
result.should be_a_kind_of(Net::HTTPOK)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should be able to find a record" do
|
11
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.us.zip')
|
12
|
-
result = simple.records.get(98122)
|
13
|
-
result.should be_a_kind_of(Hash)
|
14
|
-
result['id'].should eql('98122')
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should be able to find history for a record" do
|
18
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.us.zip')
|
19
|
-
result = simple.records.history(98122)
|
20
|
-
result.should be_a_kind_of(Hash)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be able to find nearby" do
|
24
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.us.zip')
|
25
|
-
result = simple.nearby(47.607089,-122.332034)
|
26
|
-
result.should be_a_kind_of(Hash)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should be able to find nearby with options" do
|
30
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.global.foursquare')
|
31
|
-
result = simple.nearby(47.607089,-122.332034, :limit => 5)
|
32
|
-
result.should be_a_kind_of(Hash)
|
33
|
-
result['features'].count.should == 5
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should be able to find nearby address" do
|
37
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'])
|
38
|
-
result = simple.nearby_address(47.607089,-122.332034)
|
39
|
-
result.should be_a_kind_of(Hash)
|
40
|
-
result['properties'].should_not be_nil
|
41
|
-
result['properties']['place_name'].should eql('Seattle')
|
42
|
-
result['properties']['state_name'].should eql('Washington')
|
43
|
-
result['properties']['street'].should eql('5th Ave')
|
44
|
-
result['properties']['postal_code'].should eql('98104')
|
45
|
-
result['properties']['county_name'].should eql('King')
|
46
|
-
result['properties']['country'].should eql('US')
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should be able to find user stats" do
|
50
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.us.zip')
|
51
|
-
result = simple.user_stats
|
52
|
-
result.should be_a_kind_of(Hash)
|
53
|
-
result['requests'].should_not be_nil
|
54
|
-
result['requests']['nearby'].should_not be_nil
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should be able to put record" do
|
58
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.sentientmonkey.test')
|
59
|
-
result = simple.records.put(1, {:lat => 47.607089, :lon => -122.332034, :test => 'one'})
|
60
|
-
result = simple.records.get(1)
|
61
|
-
#TODO assertions
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should be able to delete record" do
|
65
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.sentientmonkey.test')
|
66
|
-
result = simple.records.put(2, {:lat => 47.607089, :lon => -122.332034, :test => 'two'})
|
67
|
-
result = simple.records.delete(2)
|
68
|
-
lambda{ simple.records.get(2) }.should raise_exception(Simplegeo::NotFound)
|
69
|
-
#TODO assertions
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should be able to find layer stats" do
|
73
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.sentientmonkey.test')
|
74
|
-
result = simple.layer_stats
|
75
|
-
result.should be_a_kind_of(Hash)
|
76
|
-
result['requests'].should_not be_nil
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should raise NotFound exception on invalid record" do
|
80
|
-
simple = Simplegeo.new(@test_keys['key'], @test_keys['secret'], 'com.simplegeo.us.zip')
|
81
|
-
lambda{ simple.records.get(1) }.should raise_exception(Simplegeo::NotFound)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should raise NotAuthorized exception on invalid keys" do
|
85
|
-
simple = Simplegeo.new('bad key', 'bad secret', 'com.simplegeo.us.zip')
|
86
|
-
lambda{ simple.records.get(98122) }.should raise_exception(Simplegeo::NotAuthorized)
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
data/spec/test_keys.yml
DELETED