pangel-sg-ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ module SimpleGeo
2
+
3
+ class Endpoint
4
+
5
+ class << self
6
+ def record(layer, id)
7
+ endpoint_url "records/#{layer}/#{id}.json"
8
+ end
9
+
10
+ def records(layer, ids)
11
+ ids = ids.join(',') if ids.is_a? Array
12
+ endpoint_url "records/#{layer}/#{ids}.json"
13
+ end
14
+
15
+ def add_records(layer)
16
+ endpoint_url "records/#{layer}.json"
17
+ end
18
+
19
+ def history(layer, id)
20
+ endpoint_url "records/#{layer}/#{id}/history.json"
21
+ end
22
+
23
+ def nearby_geohash(layer, geohash)
24
+ endpoint_url "records/#{layer}/nearby/#{geohash}.json"
25
+ end
26
+
27
+ def nearby_coordinates(layer, lat, lon)
28
+ endpoint_url "records/#{layer}/nearby/#{lat},#{lon}.json"
29
+ end
30
+
31
+ def nearby_address(lat, lon)
32
+ endpoint_url "nearby/address/#{lat},#{lon}.json"
33
+ end
34
+
35
+ def density(lat, lon, day, hour=nil)
36
+ if hour.nil?
37
+ path = "density/#{day}/#{lat},#{lon}.json"
38
+ else
39
+ path = "density/#{day}/#{hour}/#{lat},#{lon}.json"
40
+ end
41
+ endpoint_url path
42
+ end
43
+
44
+ def layer(layer)
45
+ endpoint_url "layer/#{layer}.json"
46
+ end
47
+
48
+ def contains(lat, lon)
49
+ endpoint_url "contains/#{lat},#{lon}.json"
50
+ end
51
+
52
+ def overlaps(south, west, north, east)
53
+ endpoint_url "overlaps/#{south},#{west},#{north},#{east}.json"
54
+ end
55
+
56
+ def boundary(id)
57
+ endpoint_url "boundary/#{id}.json"
58
+ end
59
+
60
+ def endpoint_url(path)
61
+ [REALM, API_VERSION, path].join('/')
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,24 @@
1
+ module SimpleGeo
2
+ class HashUtils
3
+ def self.symbolize_keys(hash)
4
+ hash.inject({}) do |options, (key, value)|
5
+ options[(key.to_sym rescue key) || key] = value
6
+ options
7
+ end
8
+ end
9
+
10
+ def self.recursively_symbolize_keys(object)
11
+ if object.is_a? Hash
12
+ symbolized_hash = symbolize_keys(object)
13
+ symbolized_hash.each do |key, value|
14
+ symbolized_hash[key] = recursively_symbolize_keys(value)
15
+ end
16
+ symbolized_hash
17
+ elsif object.is_a? Array
18
+ object.map { |value| recursively_symbolize_keys(value) }
19
+ else
20
+ object
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,56 @@
1
+ module SimpleGeo
2
+ class Record
3
+ attr_accessor :layer, :id, :lat, :lon, :type, :created, :properties
4
+
5
+ def initialize(options={})
6
+ options = {
7
+ :created => Time.now,
8
+ :type => 'object',
9
+ :properties => {}
10
+ }.merge(options)
11
+
12
+ @id = options[:id]
13
+ @layer = options[:layer]
14
+ @type = options[:type]
15
+ @lat = options[:lat]
16
+ @lon = options[:lon]
17
+ @created = options[:created]
18
+ @properties = options[:properties]
19
+ end
20
+
21
+ def to_hash
22
+ {
23
+ :type => 'Feature',
24
+ :id => id,
25
+ :created => created.to_i,
26
+ :geometry => {
27
+ :type => 'Point',
28
+ :coordinates => [ lon, lat ]
29
+ },
30
+ :properties => properties.merge({
31
+ :type => type
32
+ })
33
+ }
34
+ end
35
+
36
+ def to_json(*a)
37
+ self.to_hash.to_json(*a)
38
+ end
39
+
40
+ def ==(other)
41
+ other.class == self.class && self.to_hash == other.to_hash
42
+ end
43
+
44
+ def self.parse_geojson_hash(json_hash)
45
+ Record.new(
46
+ :id => json_hash['id'],
47
+ :type => json_hash['properties'].delete('type'),
48
+ :lat => json_hash['geometry']['coordinates'][1],
49
+ :lon => json_hash['geometry']['coordinates'][0],
50
+ :created => Time.at(json_hash['created']),
51
+ :properties => HashUtils.recursively_symbolize_keys(json_hash['properties'])
52
+ )
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,2 @@
1
+ # So you can require "simplegeo" instead of "simple_geo"
2
+ require "simple_geo"
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{pangel-sg-ruby}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dan Dofter"]
12
+ s.date = %q{2010-05-12}
13
+ s.email = %q{dan@dofter.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/simple_geo.rb",
26
+ "lib/simple_geo/client.rb",
27
+ "lib/simple_geo/connection.rb",
28
+ "lib/simple_geo/endpoint.rb",
29
+ "lib/simple_geo/hash_utils.rb",
30
+ "lib/simple_geo/record.rb",
31
+ "lib/simplegeo.rb",
32
+ "sg-ruby.gemspec",
33
+ "spec/client_spec.rb",
34
+ "spec/fixtures/contains.json",
35
+ "spec/fixtures/get_density_by_day.json",
36
+ "spec/fixtures/get_density_by_hour.json",
37
+ "spec/fixtures/get_history.json",
38
+ "spec/fixtures/get_nearby.json",
39
+ "spec/fixtures/get_record.json",
40
+ "spec/fixtures/get_records.json",
41
+ "spec/fixtures/layer_info.json",
42
+ "spec/fixtures/nearby_address.json",
43
+ "spec/fixtures/no_such_record.json",
44
+ "spec/fixtures/nonetype_not_iterable.json",
45
+ "spec/fixtures/overlaps.json",
46
+ "spec/spec.opts",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/archfear/sg-ruby}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.6}
53
+ s.summary = %q{A SimpleGeo Ruby Client}
54
+ s.test_files = [
55
+ "spec/client_spec.rb",
56
+ "spec/spec_helper.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<oauth>, [">= 0.4.0"])
65
+ s.add_runtime_dependency(%q<json_pure>, [">= 0"])
66
+ s.add_development_dependency(%q<rspec>, [">= 1.2.0"])
67
+ s.add_development_dependency(%q<fakeweb>, [">= 1.2.0"])
68
+ else
69
+ s.add_dependency(%q<oauth>, [">= 0.4.0"])
70
+ s.add_dependency(%q<json_pure>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, [">= 1.2.0"])
72
+ s.add_dependency(%q<fakeweb>, [">= 1.2.0"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<oauth>, [">= 0.4.0"])
76
+ s.add_dependency(%q<json_pure>, [">= 0"])
77
+ s.add_dependency(%q<rspec>, [">= 1.2.0"])
78
+ s.add_dependency(%q<fakeweb>, [">= 1.2.0"])
79
+ end
80
+ end
81
+
@@ -0,0 +1,1180 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Client" do
4
+ before do
5
+ SimpleGeo::Client.set_credentials 'token', 'secret'
6
+ end
7
+
8
+ context "getting a record" do
9
+ context "with an id for an existing record" do
10
+ before do
11
+ stub_request :get,
12
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/5373629.json',
13
+ :fixture_file => 'get_record.json'
14
+ end
15
+
16
+ it "should return a single record with the correct attributes" do
17
+ record = SimpleGeo::Client.get_record('com.simplegeo.global.geonames', 5373629)
18
+ record.class.should == SimpleGeo::Record
19
+ record.id.should == '5373629'
20
+ record.type.should == 'place'
21
+ record.layer.should == 'com.simplegeo.global.geonames'
22
+ record.created.should == Time.at(1269832510)
23
+ record.lat.should == 37.759650000000001
24
+ record.lon.should == -122.42608
25
+ record.properties.should == {
26
+ :layer => "com.simplegeo.global.geonames",
27
+ :elevation => "22",
28
+ :gtopo30 => "60",
29
+ :feature_code => "PRK",
30
+ :last_modified => "2006-01-15",
31
+ :country_code => "US",
32
+ :alternatenames => "",
33
+ :timezone => "America/Los_Angeles",
34
+ :population => "0",
35
+ :name => "Mission Dolores Park",
36
+ :feature_class => "L",
37
+ :cc2 => "",
38
+ :admin1 => "CA",
39
+ :admin3 => "",
40
+ :admin2 => "075",
41
+ :admin4 => "",
42
+ :asciiname => "Mission Dolores Park"
43
+ }
44
+ end
45
+ end
46
+
47
+ context "with an id for a nonexistant record" do
48
+ before do
49
+ stub_request :get,
50
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/foo.json',
51
+ :fixture_file => 'no_such_record.json', :status => 404
52
+ end
53
+
54
+ it "should raise a NotFound exception" do
55
+ lambda {
56
+ SimpleGeo::Client.get_record('com.simplegeo.global.geonames', 'foo')
57
+ }.should raise_exception(SimpleGeo::NotFound)
58
+ end
59
+ end
60
+ end
61
+
62
+ #TODO: verify request data contains correct record data
63
+ context "adding/updating a record" do
64
+ before do
65
+ stub_request :put,
66
+ 'http://api.simplegeo.com/0.1/records/io.path.testlayer/1234.json',
67
+ :status => 202
68
+ end
69
+
70
+ it "should create or update the record" do
71
+ lambda {
72
+ record = SimpleGeo::Record.new({
73
+ :id => '1234',
74
+ :created => Time.at(1269832510),
75
+ :lat => 37.759650000000001,
76
+ :lon => -122.42608,
77
+ :layer => 'io.path.testlayer',
78
+ :properties => {
79
+ :test_property => 'foobar'
80
+ }
81
+ })
82
+ SimpleGeo::Client.add_record(record)
83
+ }.should_not raise_exception
84
+ end
85
+ end
86
+
87
+ context "deleting a record" do
88
+ before do
89
+ stub_request :delete,
90
+ 'http://api.simplegeo.com/0.1/records/io.path.testlayer/1234.json',
91
+ :status => 202
92
+ end
93
+
94
+ it "should delete the record" do
95
+ lambda {
96
+ SimpleGeo::Client.delete_record('io.path.testlayer', '1234')
97
+ }.should_not raise_exception
98
+ end
99
+ end
100
+
101
+ context "getting multiple records" do
102
+ context "with ids for two existing records" do
103
+ before do
104
+ stub_request :get,
105
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.us.business/41531696,41530629.json',
106
+ :fixture_file => 'get_records.json'
107
+ end
108
+
109
+ it "should return an array of records with the correct attributes" do
110
+ records = SimpleGeo::Client.get_records('com.simplegeo.us.business', ['41531696', '41530629'])
111
+ records.size.should == 2
112
+ records[0].id.should == '41530629'
113
+ records[0].type.should == 'place'
114
+ records[0].layer.should == 'com.simplegeo.us.business'
115
+ records[0].created.should == Time.at(1271985142)
116
+ records[0].lat.should == 37.760350000000003
117
+ records[0].lon.should == -122.419043
118
+ records[0].properties.should == {
119
+ :state => "CA",
120
+ :census_block_group => "2",
121
+ :street_type => "St",
122
+ :city => "San Francisco",
123
+ :census_block_id => "002",
124
+ :plus4 => "1811",
125
+ :cbsa => "41860",
126
+ :time_zone => "4",
127
+ :censustract => "020800",
128
+ :pubdate => "2009-12-01",
129
+ :std_name => "Beauty Bar",
130
+ :phone_number => "0323",
131
+ :state_fips => "06",
132
+ :company_sics => [
133
+ {
134
+ :sic => "72310000",
135
+ :industry_class => "7",
136
+ :relevancy => "1",
137
+ :naics_description => "BEAUTY SALONS",
138
+ :naics => "812112",
139
+ :sic_4 => "7231",
140
+ :description => "BEAUTY SHOPS",
141
+ :sic_4_description => "BEAUTY SHOPS"
142
+ },
143
+ {
144
+ :sic => "58130101",
145
+ :industry_class => "5",
146
+ :relevancy => "2",
147
+ :naics_description => "DRINKING PLACES (ALCOHOLIC BEVERAGES)",
148
+ :naics => "72241",
149
+ :sic_4 => "5813",
150
+ :description => "BAR (DRINKING PLACES)",
151
+ :sic_4_description => "DRINKING PLACES"
152
+ },
153
+ {
154
+ :sic => "58120310",
155
+ :industry_class => "5",
156
+ :relevancy => "3",
157
+ :naics_description => "LIMITED-SERVICE RESTAURANTS",
158
+ :naics => "722211",
159
+ :sic_4 => "5812",
160
+ :description => "GRILLS, ( EATING PLACES)",
161
+ :sic_4_description => "EATING PLACES"
162
+ }
163
+ ],
164
+ :dpv_confirm => "Y",
165
+ :zip => "94110",
166
+ :dpc => "996",
167
+ :street_name => "Mission",
168
+ :carrier_route => "C036",
169
+ :area_code => "415",
170
+ :company_headings => [
171
+ {
172
+ :category_name => "Bars, Taverns & Cocktail Lounges",
173
+ :condensed_name => "BARS GRILLS & PUBS",
174
+ :normalized_id => "138001000",
175
+ :category_id => "138000000",
176
+ :normalized_name => "BARS GRILLS & PUBS",
177
+ :condensed_id => "138001000"
178
+ }
179
+ ],
180
+ :mlsc => "4",
181
+ :val_date => "2010-03-22",
182
+ :confidence_score => "100",
183
+ :exppubcity => "San Francisco",
184
+ :housenumber => "2299",
185
+ :z4_type => "S",
186
+ :exchange => "285",
187
+ :business_name => "Beauty Bar",
188
+ :county_fips => "075",
189
+ :ll_match_level => "R",
190
+ :dso => "1",
191
+ :company_phones => [
192
+ {
193
+ :val_flag => "C",
194
+ :val_date => "2010-03-22",
195
+ :phone_type => "P",
196
+ :dnc => "",
197
+ :exchange => "285",
198
+ :phone_number => "0323",
199
+ :areacode => "415"
200
+ }
201
+ ],
202
+ :msa => "7360",
203
+ :val_flag => "C"
204
+ }
205
+ records[1].id.should == '41531696'
206
+ records[1].type.should == 'place'
207
+ records[1].layer.should == 'com.simplegeo.us.business'
208
+ records[1].created.should == Time.at(1271985146)
209
+ records[1].lat.should == 37.755470000000003
210
+ records[1].lon.should == -122.420646
211
+ records[1].properties.should == {
212
+ :carrier_route => "C010",
213
+ :pubdate => "2009-12-01",
214
+ :ll_match_level => "R",
215
+ :street_name => "22nd",
216
+ :std_name => "Latin American Club",
217
+ :val_flag => "C",
218
+ :census_block_id => "004",
219
+ :company_headings => [
220
+ {
221
+ :normalized_id => "138004000",
222
+ :condensed_name => "NIGHT CLUBS",
223
+ :condensed_id => "138004000",
224
+ :normalized_name => "NIGHT CLUBS",
225
+ :category_id => "138000000",
226
+ :category_name => "Bars, Taverns & Cocktail Lounges"
227
+ }
228
+ ],
229
+ :company_sics => [
230
+ {
231
+ :sic_4 => "5813",
232
+ :relevancy => "1",
233
+ :description => "NIGHT CLUBS",
234
+ :naics => "72241",
235
+ :sic => "58130200",
236
+ :industry_class => "5",
237
+ :sic_4_description => "DRINKING PLACES",
238
+ :naics_description => "DRINKING PLACES (ALCOHOLIC BEVERAGES)"
239
+ }
240
+ ],
241
+ :city => "San Francisco",
242
+ :county_fips => "075",
243
+ :zip => "94110",
244
+ :mlsc => "4",
245
+ :dso => "1",
246
+ :state => "CA",
247
+ :dpv_confirm => "Y",
248
+ :housenumber => "3286",
249
+ :msa => "7360",
250
+ :phone_number => "2732",
251
+ :exchange => "647",
252
+ :area_code => "415",
253
+ :censustract => "020800",
254
+ :state_fips => "06",
255
+ :street_type => "St",
256
+ :business_name => "Latin American Club",
257
+ :plus4 => "3033",
258
+ :val_date => "2010-03-22",
259
+ :dnc => "T",
260
+ :confidence_score => "100",
261
+ :time_zone => "4",
262
+ :cbsa => "41860",
263
+ :dpc => "862",
264
+ :company_phones => [
265
+ {
266
+ :phone_number => "2732",
267
+ :phone_type => "P",
268
+ :val_date => "2010-03-22",
269
+ :dnc => "T",
270
+ :exchange => "647",
271
+ :areacode => "415",
272
+ :val_flag => "C"
273
+ }
274
+ ],
275
+ :census_block_group => "4",
276
+ :z4_type => "S"
277
+ }
278
+ end
279
+ end
280
+
281
+ context "with ids for nonexistant records" do
282
+ before do
283
+ stub_request :get,
284
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/foo,bar.json',
285
+ :fixture_file => 'nonetype_not_iterable.json', :status => 500
286
+ end
287
+
288
+ it "should raise a NotFound exception" do
289
+ lambda {
290
+ SimpleGeo::Client.get_records('com.simplegeo.global.geonames', ['foo', 'bar'])
291
+ }.should raise_exception(SimpleGeo::ServerError)
292
+ end
293
+ end
294
+ end
295
+
296
+ context "adding multiple records" do
297
+ before do
298
+ stub_request :post,
299
+ 'http://api.simplegeo.com/0.1/records/io.path.testlayer.json',
300
+ :status => 202
301
+ end
302
+
303
+ it "should create or update the record" do
304
+ layer = 'io.path.testlayer'
305
+ lambda {
306
+ records = [
307
+ SimpleGeo::Record.new({
308
+ :id => '1234',
309
+ :created => Time.at(1269832510),
310
+ :lat => 37.759650000000001,
311
+ :lon => -122.42608,
312
+ :layer => layer,
313
+ :properties => {
314
+ :test_property => 'foobar'
315
+ }
316
+ }),
317
+ SimpleGeo::Record.new({
318
+ :id => '5678',
319
+ :created => Time.at(1269832510),
320
+ :lat => 37.755470000000003,
321
+ :lon => -122.420646,
322
+ :layer => layer,
323
+ :properties => {
324
+ :mad_prop => 'baz'
325
+ }
326
+ })
327
+ ]
328
+ SimpleGeo::Client.add_records(layer, records)
329
+ }.should_not raise_exception
330
+ end
331
+ end
332
+
333
+ context "getting a record's history" do
334
+ before do
335
+ stub_request :get,
336
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/5373629/history.json',
337
+ :fixture_file => 'get_history.json'
338
+ end
339
+
340
+ it "should create or update the record" do
341
+ history = SimpleGeo::Client.get_history('com.simplegeo.global.geonames', '5373629')
342
+ history.should == [
343
+ {
344
+ :created => Time.at(1269832510),
345
+ :lat => 37.759650000000001,
346
+ :lon => -122.42608
347
+ }
348
+ ]
349
+ end
350
+ end
351
+
352
+ context "getting nearby records" do
353
+ before do
354
+ @expected_records = {
355
+ :next_cursor => "QVSEifz7gri4J0w8FSQJ06Z5S5lOw6gZ75Co-fBbBQJEr7XMqN32bjMKNc9kwLKqKyqtVvxR_t5hgWW6XDgPnPTY",
356
+ :records => [
357
+ {
358
+ :distance => 0,
359
+ :record => SimpleGeo::Record.new(
360
+ :id => "5373629",
361
+ :lon => -122.42608,
362
+ :lat => 37.75965,
363
+ :type => "place",
364
+ :layer => "com.simplegeo.global.geonames",
365
+ :created => Time.at(1269832510),
366
+ :properties => {
367
+ :admin4 => "",
368
+ :feature_code => "PRK",
369
+ :feature_class => "L",
370
+ :last_modified => "2006-01-15",
371
+ :asciiname => "Mission Dolores Park",
372
+ :cc2 => "",
373
+ :country_code => "US",
374
+ :admin1 => "CA",
375
+ :alternatenames => "",
376
+ :admin3 => "",
377
+ :elevation => "22",
378
+ :layer => "com.simplegeo.global.geonames",
379
+ :timezone => "America/Los_Angeles",
380
+ :name => "Mission Dolores Park",
381
+ :gtopo30 => "60",
382
+ :admin2 => "075",
383
+ :population => "0"
384
+ }
385
+ )
386
+ },
387
+ {
388
+ :distance => 57.557068918956581,
389
+ :record => SimpleGeo::Record.new(
390
+ :id => "5352852",
391
+ :lon => -122.42553,
392
+ :lat => 37.75937,
393
+ :type => "place",
394
+ :layer => "com.simplegeo.global.geonames",
395
+ :created => Time.at(1269832039),
396
+ :properties => {
397
+ :admin4 => "",
398
+ :feature_code => "CH",
399
+ :feature_class => "S",
400
+ :last_modified => "2006-01-15",
401
+ :asciiname => "Golden Gate Lutheran Church",
402
+ :cc2 => "",
403
+ :country_code => "US",
404
+ :admin1 => "CA",
405
+ :alternatenames => "",
406
+ :admin3 => "",
407
+ :elevation => "23",
408
+ :layer => "com.simplegeo.global.geonames",
409
+ :timezone => "America/Los_Angeles",
410
+ :name=> "Golden Gate Lutheran Church",
411
+ :gtopo30 => "60",
412
+ :admin2 => "075",
413
+ :population => "0"
414
+ }
415
+ )
416
+ }
417
+ ]
418
+ }
419
+ end
420
+
421
+ context "by lat and lon" do
422
+ before do
423
+ stub_request :get,
424
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/nearby/37.75965,-122.42608.json',
425
+ :fixture_file => 'get_nearby.json'
426
+ end
427
+
428
+ it "should return a hash of nearby records" do
429
+ records = SimpleGeo::Client.get_nearby_records('com.simplegeo.global.geonames',
430
+ :lat => 37.759650000000001,
431
+ :lon => -122.42608)
432
+ records.should == @expected_records
433
+ end
434
+ end
435
+
436
+ context "by geohash" do
437
+ before do
438
+ stub_request :get,
439
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/nearby/9q8yy1ujcsfm.json',
440
+ :fixture_file => 'get_nearby.json'
441
+ end
442
+
443
+ it "should return a hash of nearby records" do
444
+ records = SimpleGeo::Client.get_nearby_records('com.simplegeo.global.geonames',
445
+ :geohash => '9q8yy1ujcsfm')
446
+ records.should == @expected_records
447
+ end
448
+ end
449
+
450
+ context "with no nearby records" do
451
+ before do
452
+ stub_request :get,
453
+ 'http://api.simplegeo.com/0.1/records/com.simplegeo.global.geonames/nearby/37.75965,-122.42608.json',
454
+ :fixture_file => 'empty_feature_collection.json'
455
+ end
456
+
457
+ it "should return a hash of nearby records" do
458
+ records = SimpleGeo::Client.get_nearby_records('com.simplegeo.global.geonames',
459
+ :lat => 37.759650000000001,
460
+ :lon => -122.42608)
461
+ records.should == { :next_cursor => nil, :records => [] }
462
+ end
463
+ end
464
+ end
465
+
466
+ context "getting a nearby address" do
467
+ before do
468
+ stub_request :get,
469
+ 'http://api.simplegeo.com/0.1/nearby/address/37.75965,-122.42608.json',
470
+ :fixture_file => 'nearby_address.json'
471
+ end
472
+
473
+ it "should return a hash with the address information" do
474
+ nearby_address = SimpleGeo::Client.get_nearby_address(37.759650000000001, -122.42608)
475
+ nearby_address.should == {
476
+ :state_name => "California",
477
+ :street_number => "580",
478
+ :country => "US",
479
+ :street => "Dolores St",
480
+ :postal_code => "",
481
+ :county_name => "San Francisco",
482
+ :county_code => "075",
483
+ :state_code => "CA",
484
+ :place_name => "San Francisco"
485
+ }
486
+ end
487
+ end
488
+
489
+ context "getting layer information" do
490
+ context "for an existing layer" do
491
+ before do
492
+ stub_request :get,
493
+ 'http://api.simplegeo.com/0.1/layer/io.path.testlayer.json',
494
+ :fixture_file => 'layer_info.json'
495
+ end
496
+
497
+ it "should return a hash containing the layer information" do
498
+ layer_info = SimpleGeo::Client.get_layer_information('io.path.testlayer')
499
+ layer_info.should == {
500
+ :name => "io.path.testlayer",
501
+ :public => false,
502
+ :callback_urls => []
503
+ }
504
+ end
505
+ end
506
+
507
+ context "for a nonexistant layer" do
508
+ before do
509
+ stub_request :get,
510
+ 'http://api.simplegeo.com/0.1/layer/io.path.testlayer.json',
511
+ :status => 404
512
+ end
513
+
514
+ it "should raise a NotFound exception" do
515
+ lambda {
516
+ SimpleGeo::Client.get_layer_information('io.path.testlayer')
517
+ }.should raise_exception(SimpleGeo::NotFound)
518
+ end
519
+ end
520
+ end
521
+
522
+ context "getting SpotRank information for a day, hour and location" do
523
+ before do
524
+ stub_request :get,
525
+ 'http://api.simplegeo.com/0.1/density/sat/16/37.75965,-122.42608.json',
526
+ :fixture_file => 'get_density_by_hour.json'
527
+ end
528
+
529
+ it "should return a hash containing the density information" do
530
+ density_info = SimpleGeo::Client.get_density(37.75965, -122.42608, 'sat', '16' )
531
+ density_info.should == {
532
+ :city_rank => 10,
533
+ :local_rank => 8,
534
+ :trending_rank => 0,
535
+ :dayname => "sat",
536
+ :hour => 16,
537
+ :worldwide_rank => 8,
538
+ :geometry => {
539
+ :type => "Polygon",
540
+ :coordinates => [
541
+ [ 37.7587890625, -122.4267578125 ],
542
+ [ 37.759765625, -122.4267578125 ],
543
+ [ 37.759765625, -122.42578125 ],
544
+ [ 37.7587890625, -122.42578125 ],
545
+ [ 37.7587890625, -122.4267578125 ]
546
+ ]
547
+ }
548
+ }
549
+ end
550
+ end
551
+
552
+ context "getting SpotRank information for a day and location" do
553
+ before do
554
+ stub_request :get,
555
+ 'http://api.simplegeo.com/0.1/density/sat/37.75965,-122.42608.json',
556
+ :fixture_file => 'get_density_by_day.json'
557
+ end
558
+
559
+ it "should return an array of hashes containing the density information" do
560
+ density_info = SimpleGeo::Client.get_density(37.75965, -122.42608, 'sat')
561
+ density_info.should == [
562
+ {
563
+ :geometry => {
564
+ :type => "Polygon",
565
+ :coordinates => [
566
+ [ 37.7587890625, -122.4267578125 ],
567
+ [ 37.759765625, -122.4267578125 ],
568
+ [ 37.759765625, -122.42578125 ],
569
+ [ 37.7587890625, -122.42578125 ],
570
+ [ 37.7587890625, -122.4267578125 ]
571
+ ]
572
+ },
573
+ :hour => 0,
574
+ :trending_rank => 2,
575
+ :local_rank => 4,
576
+ :city_rank => 10,
577
+ :worldwide_rank => 4,
578
+ :dayname => "sat"
579
+ },
580
+ {
581
+ :geometry => {
582
+ :type => "Polygon",
583
+ :coordinates => [
584
+ [ 37.7587890625, -122.4267578125 ],
585
+ [ 37.759765625, -122.4267578125 ],
586
+ [ 37.759765625, -122.42578125 ],
587
+ [ 37.7587890625, -122.42578125 ],
588
+ [ 37.7587890625, -122.4267578125 ]
589
+ ]
590
+ },
591
+ :hour => 1,
592
+ :trending_rank => -2,
593
+ :local_rank => 6,
594
+ :city_rank => 10,
595
+ :worldwide_rank => 6,
596
+ :dayname => "sat"
597
+ },
598
+ {
599
+ :geometry => {
600
+ :type => "Polygon",
601
+ :coordinates => [
602
+ [ 37.7587890625, -122.4267578125 ],
603
+ [ 37.759765625, -122.4267578125 ],
604
+ [ 37.759765625, -122.42578125 ],
605
+ [ 37.7587890625, -122.42578125 ],
606
+ [ 37.7587890625, -122.4267578125 ]
607
+ ]
608
+ },
609
+ :hour => 2,
610
+ :trending_rank => 2,
611
+ :local_rank => 2,
612
+ :city_rank => 10,
613
+ :worldwide_rank => 2,
614
+ :dayname => "sat"
615
+ },
616
+ {
617
+ :geometry => {
618
+ :type => "Polygon",
619
+ :coordinates => [
620
+ [ 37.7587890625, -122.4267578125 ],
621
+ [ 37.759765625, -122.4267578125 ],
622
+ [ 37.759765625, -122.42578125 ],
623
+ [ 37.7587890625, -122.42578125 ],
624
+ [ 37.7587890625, -122.4267578125 ]
625
+ ]
626
+ },
627
+ :hour => 3,
628
+ :trending_rank => -2,
629
+ :local_rank => 6,
630
+ :city_rank => 10,
631
+ :worldwide_rank => 6,
632
+ :dayname => "sat"
633
+ },
634
+ {
635
+ :geometry => {
636
+ :type => "Polygon",
637
+ :coordinates => [
638
+ [ 37.7587890625, -122.4267578125 ],
639
+ [ 37.759765625, -122.4267578125 ],
640
+ [ 37.759765625, -122.42578125 ],
641
+ [ 37.7587890625, -122.42578125 ],
642
+ [ 37.7587890625, -122.4267578125 ]
643
+ ]
644
+ },
645
+ :hour => 4,
646
+ :trending_rank => -2,
647
+ :local_rank => 4,
648
+ :city_rank => 10,
649
+ :worldwide_rank => 4,
650
+ :dayname => "sat"
651
+ },
652
+ {
653
+ :geometry => {
654
+ :type => "Polygon",
655
+ :coordinates => [
656
+ [ 37.7587890625, -122.4267578125 ],
657
+ [ 37.759765625, -122.4267578125 ],
658
+ [ 37.759765625, -122.42578125 ],
659
+ [ 37.7587890625, -122.42578125 ],
660
+ [ 37.7587890625, -122.4267578125 ]
661
+ ]
662
+ },
663
+ :hour => 6,
664
+ :trending_rank => 2,
665
+ :local_rank => 2,
666
+ :city_rank => 10,
667
+ :worldwide_rank => 2,
668
+ :dayname => "sat"
669
+ },
670
+ {
671
+ :geometry => {
672
+ :type => "Polygon",
673
+ :coordinates => [
674
+ [ 37.7587890625, -122.4267578125 ],
675
+ [ 37.759765625, -122.4267578125 ],
676
+ [ 37.759765625, -122.42578125 ],
677
+ [ 37.7587890625, -122.42578125 ],
678
+ [ 37.7587890625, -122.4267578125 ]
679
+ ]
680
+ },
681
+ :hour => 7,
682
+ :trending_rank => 1,
683
+ :local_rank => 5,
684
+ :city_rank => 10,
685
+ :worldwide_rank => 5,
686
+ :dayname => "sat"
687
+ },
688
+ {
689
+ :geometry => {
690
+ :type => "Polygon",
691
+ :coordinates => [
692
+ [ 37.7587890625, -122.4267578125 ],
693
+ [ 37.759765625, -122.4267578125 ],
694
+ [ 37.759765625, -122.42578125 ],
695
+ [ 37.7587890625, -122.42578125 ],
696
+ [ 37.7587890625, -122.4267578125 ]
697
+ ]
698
+ },
699
+ :hour => 8,
700
+ :trending_rank => 0,
701
+ :local_rank => 6,
702
+ :city_rank => 10,
703
+ :worldwide_rank => 6,
704
+ :dayname => "sat"
705
+ },
706
+ {
707
+ :geometry => {
708
+ :type => "Polygon",
709
+ :coordinates => [
710
+ [ 37.7587890625, -122.4267578125 ],
711
+ [ 37.759765625, -122.4267578125 ],
712
+ [ 37.759765625, -122.42578125 ],
713
+ [ 37.7587890625, -122.42578125 ],
714
+ [ 37.7587890625, -122.4267578125 ]
715
+ ]
716
+ },
717
+ :hour => 9,
718
+ :trending_rank => 0,
719
+ :local_rank => 6,
720
+ :city_rank => 10,
721
+ :worldwide_rank => 6,
722
+ :dayname => "sat"
723
+ },
724
+ {
725
+ :geometry => {
726
+ :type => "Polygon",
727
+ :coordinates => [
728
+ [ 37.7587890625, -122.4267578125 ],
729
+ [ 37.759765625, -122.4267578125 ],
730
+ [ 37.759765625, -122.42578125 ],
731
+ [ 37.7587890625, -122.42578125 ],
732
+ [ 37.7587890625, -122.4267578125 ]
733
+ ]
734
+ },
735
+ :hour => 10,
736
+ :trending_rank => 2,
737
+ :local_rank => 6,
738
+ :city_rank => 10,
739
+ :worldwide_rank => 6,
740
+ :dayname => "sat"
741
+ },
742
+ {
743
+ :geometry => {
744
+ :type => "Polygon",
745
+ :coordinates => [
746
+ [ 37.7587890625, -122.4267578125 ],
747
+ [ 37.759765625, -122.4267578125 ],
748
+ [ 37.759765625, -122.42578125 ],
749
+ [ 37.7587890625, -122.42578125 ],
750
+ [ 37.7587890625, -122.4267578125 ]
751
+ ]
752
+ },
753
+ :hour => 11,
754
+ :trending_rank => -1,
755
+ :local_rank => 8,
756
+ :city_rank => 10,
757
+ :worldwide_rank => 8,
758
+ :dayname => "sat"
759
+ },
760
+ {
761
+ :geometry => {
762
+ :type => "Polygon",
763
+ :coordinates => [
764
+ [ 37.7587890625, -122.4267578125 ],
765
+ [ 37.759765625, -122.4267578125 ],
766
+ [ 37.759765625, -122.42578125 ],
767
+ [ 37.7587890625, -122.42578125 ],
768
+ [ 37.7587890625, -122.4267578125 ]
769
+ ]
770
+ },
771
+ :hour => 12,
772
+ :trending_rank => 1,
773
+ :local_rank => 7,
774
+ :city_rank => 10,
775
+ :worldwide_rank => 7,
776
+ :dayname => "sat"
777
+ },
778
+ {
779
+ :geometry => {
780
+ :type => "Polygon",
781
+ :coordinates => [
782
+ [ 37.7587890625, -122.4267578125 ],
783
+ [ 37.759765625, -122.4267578125 ],
784
+ [ 37.759765625, -122.42578125 ],
785
+ [ 37.7587890625, -122.42578125 ],
786
+ [ 37.7587890625, -122.4267578125 ]
787
+ ]
788
+ },
789
+ :hour => 13,
790
+ :trending_rank => 0,
791
+ :local_rank => 8,
792
+ :city_rank => 10,
793
+ :worldwide_rank => 8,
794
+ :dayname => "sat"
795
+ },
796
+ {
797
+ :geometry => {
798
+ :type => "Polygon",
799
+ :coordinates => [
800
+ [ 37.7587890625, -122.4267578125 ],
801
+ [ 37.759765625, -122.4267578125 ],
802
+ [ 37.759765625, -122.42578125 ],
803
+ [ 37.7587890625, -122.42578125 ],
804
+ [ 37.7587890625, -122.4267578125 ]
805
+ ]
806
+ },
807
+ :hour => 14,
808
+ :trending_rank => 0,
809
+ :local_rank => 8,
810
+ :city_rank => 10,
811
+ :worldwide_rank => 8,
812
+ :dayname => "sat"
813
+ },
814
+ {
815
+ :geometry => {
816
+ :type => "Polygon",
817
+ :coordinates => [
818
+ [ 37.7587890625, -122.4267578125 ],
819
+ [ 37.759765625, -122.4267578125 ],
820
+ [ 37.759765625, -122.42578125 ],
821
+ [ 37.7587890625, -122.42578125 ],
822
+ [ 37.7587890625, -122.4267578125 ]
823
+ ]
824
+ },
825
+ :hour => 15,
826
+ :trending_rank => 0,
827
+ :local_rank => 8,
828
+ :city_rank => 10,
829
+ :worldwide_rank => 8,
830
+ :dayname => "sat"
831
+ },
832
+ {
833
+ :geometry => {
834
+ :type => "Polygon",
835
+ :coordinates => [
836
+ [ 37.7587890625, -122.4267578125 ],
837
+ [ 37.759765625, -122.4267578125 ],
838
+ [ 37.759765625, -122.42578125 ],
839
+ [ 37.7587890625, -122.42578125 ],
840
+ [ 37.7587890625, -122.4267578125 ]
841
+ ]
842
+ },
843
+ :hour => 16,
844
+ :trending_rank => 0,
845
+ :local_rank => 8,
846
+ :city_rank => 10,
847
+ :worldwide_rank => 8,
848
+ :dayname => "sat"
849
+ },
850
+ {
851
+ :geometry => {
852
+ :type => "Polygon",
853
+ :coordinates => [
854
+ [ 37.7587890625, -122.4267578125 ],
855
+ [ 37.759765625, -122.4267578125 ],
856
+ [ 37.759765625, -122.42578125 ],
857
+ [ 37.7587890625, -122.42578125 ],
858
+ [ 37.7587890625, -122.4267578125 ]
859
+ ]
860
+ },
861
+ :hour => 17,
862
+ :trending_rank => 0,
863
+ :local_rank => 8,
864
+ :city_rank => 10,
865
+ :worldwide_rank => 8,
866
+ :dayname => "sat"
867
+ },
868
+ {
869
+ :geometry => {
870
+ :type => "Polygon",
871
+ :coordinates => [
872
+ [ 37.7587890625, -122.4267578125 ],
873
+ [ 37.759765625, -122.4267578125 ],
874
+ [ 37.759765625, -122.42578125 ],
875
+ [ 37.7587890625, -122.42578125 ],
876
+ [ 37.7587890625, -122.4267578125 ]
877
+ ]
878
+ },
879
+ :hour => 18,
880
+ :trending_rank => 0,
881
+ :local_rank => 8,
882
+ :city_rank => 10,
883
+ :worldwide_rank => 8,
884
+ :dayname => "sat"
885
+ },
886
+ {
887
+ :geometry => {
888
+ :type => "Polygon",
889
+ :coordinates => [
890
+ [ 37.7587890625, -122.4267578125 ],
891
+ [ 37.759765625, -122.4267578125 ],
892
+ [ 37.759765625, -122.42578125 ],
893
+ [ 37.7587890625, -122.42578125 ],
894
+ [ 37.7587890625, -122.4267578125 ]
895
+ ]
896
+ },
897
+ :hour => 19,
898
+ :trending_rank => 0,
899
+ :local_rank => 8,
900
+ :city_rank => 10,
901
+ :worldwide_rank => 8,
902
+ :dayname => "sat"
903
+ },
904
+ {
905
+ :geometry => {
906
+ :type => "Polygon",
907
+ :coordinates => [
908
+ [ 37.7587890625, -122.4267578125 ],
909
+ [ 37.759765625, -122.4267578125 ],
910
+ [ 37.759765625, -122.42578125 ],
911
+ [ 37.7587890625, -122.42578125 ],
912
+ [ 37.7587890625, -122.4267578125 ]
913
+ ]
914
+ },
915
+ :hour => 20,
916
+ :trending_rank => 0,
917
+ :local_rank => 8,
918
+ :city_rank => 10,
919
+ :worldwide_rank => 8,
920
+ :dayname => "sat"
921
+ },
922
+ {
923
+ :geometry => {
924
+ :type => "Polygon",
925
+ :coordinates => [
926
+ [ 37.7587890625, -122.4267578125 ],
927
+ [ 37.759765625, -122.4267578125 ],
928
+ [ 37.759765625, -122.42578125 ],
929
+ [ 37.7587890625, -122.42578125 ],
930
+ [ 37.7587890625, -122.4267578125 ]
931
+ ]
932
+ },
933
+ :hour => 21,
934
+ :trending_rank => -2,
935
+ :local_rank => 8,
936
+ :city_rank => 10,
937
+ :worldwide_rank => 8,
938
+ :dayname => "sat"
939
+ },
940
+ {
941
+ :geometry => {
942
+ :type => "Polygon",
943
+ :coordinates => [
944
+ [ 37.7587890625, -122.4267578125 ],
945
+ [ 37.759765625, -122.4267578125 ],
946
+ [ 37.759765625, -122.42578125 ],
947
+ [ 37.7587890625, -122.42578125 ],
948
+ [ 37.7587890625, -122.4267578125 ]
949
+ ]
950
+ },
951
+ :hour => 22,
952
+ :trending_rank => 0,
953
+ :local_rank => 5,
954
+ :city_rank => 10,
955
+ :worldwide_rank => 6,
956
+ :dayname => "sat"
957
+ },
958
+ {
959
+ :geometry => {
960
+ :type => "Polygon",
961
+ :coordinates => [
962
+ [ 37.7587890625, -122.4267578125 ],
963
+ [ 37.759765625, -122.4267578125 ],
964
+ [ 37.759765625, -122.42578125 ],
965
+ [ 37.7587890625, -122.42578125 ],
966
+ [ 37.7587890625, -122.4267578125 ]
967
+ ]
968
+ },
969
+ :hour => 23,
970
+ :trending_rank => 1,
971
+ :local_rank => 5,
972
+ :city_rank => 10,
973
+ :worldwide_rank => 5,
974
+ :dayname => "sat"
975
+ }
976
+ ]
977
+ end
978
+ end
979
+
980
+ context "getting contains info for a set of coordinates" do
981
+ before do
982
+ stub_request :get,
983
+ 'http://api.simplegeo.com/0.1/contains/37.7587890625,-122.4267578125.json',
984
+ :fixture_file => 'contains.json'
985
+ end
986
+
987
+ it "should return a hash with the correct info" do
988
+ info = SimpleGeo::Client.get_contains(37.7587890625, -122.4267578125)
989
+ info.should == [
990
+ {
991
+ :bounds =>
992
+ [
993
+ -122.435188,
994
+ 37.756093,
995
+ -122.42555,
996
+ 37.763030999999998
997
+ ],
998
+ :type => "Census Tract",
999
+ :id => "Census_Tract:06075020600:9q8yy1",
1000
+ :abbr => "",
1001
+ :name => "06075020600"
1002
+ },
1003
+ {
1004
+ :bounds =>
1005
+ [
1006
+ -123.17382499999999,
1007
+ 37.639829999999996,
1008
+ -122.28178,
1009
+ 37.929823999999996
1010
+ ],
1011
+ :type => "County",
1012
+ :id => "County:San_Francisco:9q8yvv",
1013
+ :abbr => "",
1014
+ :name => "San Francisco"
1015
+ },
1016
+ {
1017
+ :bounds =>
1018
+ [
1019
+ -123.17382499999999,
1020
+ 37.639829999999996,
1021
+ -122.28178,
1022
+ 37.929823999999996
1023
+ ],
1024
+ :type => "City",
1025
+ :id => "City:San_Francisco:9q8yvv",
1026
+ :abbr => "",
1027
+ :name => "San Francisco"
1028
+ },
1029
+ {
1030
+ :bounds =>
1031
+ [
1032
+ -122.612285,
1033
+ 37.708131000000002,
1034
+ -122.28178,
1035
+ 37.929823999999996
1036
+ ],
1037
+ :type => "Congressional District",
1038
+ :id => "Congressional_District:Congressional_Di:9q8yyn",
1039
+ :abbr => "",
1040
+ :name => "Congressional District 8"
1041
+ },
1042
+ {
1043
+ :bounds =>
1044
+ [
1045
+ -179.14247147726383,
1046
+ 18.930137634111077,
1047
+ 179.78114994357418,
1048
+ 71.412179667308919
1049
+ ],
1050
+ :type => "Country",
1051
+ :id => "Country:United_States_of:9z12zg",
1052
+ :abbr => "",
1053
+ :name => "United States of America"
1054
+ },
1055
+ {
1056
+ :bounds =>
1057
+ [
1058
+ -122.428882,
1059
+ 37.758029999999998,
1060
+ -122.42138199999999,
1061
+ 37.772263000000002
1062
+ ],
1063
+ :type => "Neighborhood",
1064
+ :id => "Neighborhood:Mission_Dolores:9q8yy4",
1065
+ :abbr => "",
1066
+ :name => "Mission Dolores"
1067
+ },
1068
+ {
1069
+ :bounds =>
1070
+ [
1071
+ -122.51666666668193,
1072
+ 37.191666666628507,
1073
+ -121.73333333334497,
1074
+ 38.041666666640907
1075
+ ],
1076
+ :type => "Urban Area",
1077
+ :id => "Urban_Area:San_Francisco1:9q9jsg",
1078
+ :abbr => "",
1079
+ :name => "San Francisco1"
1080
+ },
1081
+ {
1082
+ :bounds =>
1083
+ [
1084
+ -122.451553,
1085
+ 37.746687000000001,
1086
+ -122.424773,
1087
+ 37.770451999999999
1088
+ ],
1089
+ :type => "Postal",
1090
+ :id => "Postal:94114:9q8yvc",
1091
+ :abbr => "",
1092
+ :name => "94114"
1093
+ },
1094
+ {
1095
+ :bounds =>
1096
+ [
1097
+ -124.48200299999999,
1098
+ 32.528832000000001,
1099
+ -114.13121099999999,
1100
+ 42.009516999999995
1101
+ ],
1102
+ :type => "Province",
1103
+ :id => "Province:CA:9qdguu",
1104
+ :abbr => "CA",
1105
+ :name => "California"
1106
+ }
1107
+ ]
1108
+ end
1109
+ end
1110
+
1111
+ context "getting overlaps info for a set of coordinates" do
1112
+ before do
1113
+ stub_request :get,
1114
+ 'http://api.simplegeo.com/0.1/overlaps/32.528832,-124.482003,42.009517,-114.131211.json',
1115
+ :fixture_file => 'overlaps.json'
1116
+ end
1117
+
1118
+ it "should return a hash with the correct info" do
1119
+ info = SimpleGeo::Client.get_overlaps(32.528832000000001, -124.48200299999999,
1120
+ 42.009516999999995, -114.13121099999999)
1121
+ info.should == [
1122
+ {
1123
+ :bounds =>
1124
+ [
1125
+ -122.998802,
1126
+ 42.002634,
1127
+ -122.597843,
1128
+ 42.266379000000001
1129
+ ],
1130
+ :type => "Census Tract",
1131
+ :id => "Census_Tract:41029002300:9r2xt4",
1132
+ :abbr => "",
1133
+ :name => "41029002300"
1134
+ },
1135
+ {
1136
+ :bounds =>
1137
+ [
1138
+ -123.858086,
1139
+ 41.995095999999997,
1140
+ -123.22998200000001,
1141
+ 42.272435999999999
1142
+ ],
1143
+ :type => "Census Tract",
1144
+ :id => "Census_Tract:41033361600:9r2psc",
1145
+ :abbr => "",
1146
+ :name => "41033361600"
1147
+ },
1148
+ {
1149
+ :bounds =>
1150
+ [
1151
+ -123.231629,
1152
+ 42.003022000000001,
1153
+ -122.907515,
1154
+ 42.433349
1155
+ ],
1156
+ :type => "Census Tract",
1157
+ :id => "Census_Tract:41029003002:9r2ryf",
1158
+ :abbr => "",
1159
+ :name => "41029003002"
1160
+ }
1161
+ ]
1162
+ end
1163
+ end
1164
+
1165
+ # this API call seems to always return a 404
1166
+ # context "getting boundary info by id" do
1167
+ # before do
1168
+ # stub_request :get,
1169
+ # 'http://api.simplegeo.com/0.1/boundary/Neighborhood:Mission_Dolores:9q8yy4.json',
1170
+ # :fixture_file => 'boundary.json'
1171
+ # end
1172
+ #
1173
+ # it "should return a hash with the correct info" do
1174
+ # info = SimpleGeo::Client.get_boundary("Neighborhood:Mission_Dolores:9q8yy4")
1175
+ # info.should == [
1176
+ #
1177
+ # ]
1178
+ # end
1179
+ # end
1180
+ end