nyc_geo_client 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -7
- data/README.md +21 -12
- data/lib/nyc_geo_client/client/address.rb +4 -3
- data/lib/nyc_geo_client/client/bbl.rb +1 -1
- data/lib/nyc_geo_client/client/bin.rb +1 -1
- data/lib/nyc_geo_client/client/blockface.rb +6 -3
- data/lib/nyc_geo_client/client/intersection.rb +5 -3
- data/lib/nyc_geo_client/client/place.rb +4 -3
- data/lib/nyc_geo_client/version.rb +1 -1
- data/spec/faraday/response_spec.rb +2 -2
- data/spec/nyc_geo_client/client/address_spec.rb +54 -20
- data/spec/nyc_geo_client/client/bbl_spec.rb +2 -2
- data/spec/nyc_geo_client/client/bin_spec.rb +2 -2
- data/spec/nyc_geo_client/client/blockface_spec.rb +16 -2
- data/spec/nyc_geo_client/client/intersection_spec.rb +14 -2
- data/spec/nyc_geo_client/client/place_spec.rb +51 -19
- data/spec/nyc_geo_client_spec.rb +12 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad49e5b8a47e390f27c6854468278926972d2887
|
4
|
+
data.tar.gz: 431451afcb992714945e5340cdefa117ea21881e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749b3bd51b957c25c17c36656cdbd2b8a966725e41fc93e0621b32f694e40ba2b62ec58056d34b331d016fc59c75ae9493d0533bf1af9c66cf23a41f1f7b309b
|
7
|
+
data.tar.gz: c6f723099e892e3836eba48a8fadfcd4621ce1c408766cb06e5ed4c8d0d385f4939f784d15fbc234c4fb73796724b99e1fdadc3b25d89cdd1259428a3f305347
|
data/.travis.yml
CHANGED
@@ -3,14 +3,13 @@ matrix:
|
|
3
3
|
allow_failures:
|
4
4
|
- rvm: ruby-head
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.3
|
10
|
-
- 2.
|
11
|
-
- 2.4.0
|
6
|
+
- 2.1.10
|
7
|
+
- 2.2.9
|
8
|
+
- 2.3.6
|
9
|
+
- 2.4.3
|
10
|
+
- 2.5.0
|
12
11
|
- ruby-head
|
13
12
|
before_install:
|
14
13
|
# need this for ruby 1.9.3 and rspec
|
15
14
|
- gem update --system
|
16
|
-
- gem update bundler
|
15
|
+
- gem update bundler --force
|
data/README.md
CHANGED
@@ -26,22 +26,31 @@ Or install it yourself as:
|
|
26
26
|
client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY')
|
27
27
|
|
28
28
|
# get block and property level information about an address
|
29
|
-
client.address('13', 'crosby', 'manhattan')
|
29
|
+
client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
30
30
|
|
31
31
|
# property level information about a tax lot
|
32
|
-
client.bbl('manhattan', '00233', '0004')
|
32
|
+
client.bbl(borough: 'manhattan', block: '00233', lot: '0004')
|
33
33
|
|
34
34
|
# get property level information about a building
|
35
|
-
client.bin('1003041')
|
35
|
+
client.bin(bin: '1003041')
|
36
36
|
|
37
37
|
# get information about a segment defined by an on street between two cross-streets
|
38
|
-
client.blockface(
|
38
|
+
client.blockface(
|
39
|
+
on_street: '34 st',
|
40
|
+
cross_street_one: 'fifth ave',
|
41
|
+
cross_street_two: 'sixth ave',
|
42
|
+
borough: 'manhattan'
|
43
|
+
)
|
39
44
|
|
40
45
|
# get information about a point defined by two cross streets
|
41
|
-
client.intersection(
|
46
|
+
client.intersection(
|
47
|
+
cross_street_one: '34 st',
|
48
|
+
cross_street_two: 'fifth ave',
|
49
|
+
borough: 'manhattan'
|
50
|
+
)
|
42
51
|
|
43
52
|
# get address information using a well-known place name
|
44
|
-
client.place('empire state building', 'manhattan')
|
53
|
+
client.place(name: 'empire state building', borough: 'manhattan')
|
45
54
|
|
46
55
|
|
47
56
|
For more information about the data returned by every method please check the specs folder
|
@@ -69,15 +78,15 @@ For instance:
|
|
69
78
|
require 'typhoeus/adapters/faraday' # You will need the typhoeus gem
|
70
79
|
|
71
80
|
client = NYCGeoClient.client(adapter: :typhoeus, user_agent: "foobar v1", debug: true, app_id: 'foo', app_key: 'bar')
|
72
|
-
client.address('13','crosby','manhattan')
|
81
|
+
client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
73
82
|
|
74
83
|
## Ruby versions supported
|
75
84
|
|
76
|
-
* 1
|
77
|
-
* 2.
|
78
|
-
* 2.
|
79
|
-
* 2.
|
80
|
-
* 2.
|
85
|
+
* 2.1
|
86
|
+
* 2.2
|
87
|
+
* 2.3
|
88
|
+
* 2.4
|
89
|
+
* 2.5
|
81
90
|
|
82
91
|
Check the [.travis.yml](.travis.yml) to see the current supported ruby versions.
|
83
92
|
|
@@ -15,12 +15,13 @@ module NYCGeoClient
|
|
15
15
|
# @example block and property level information about an address
|
16
16
|
# NYCGeoClient.address('13', 'crosby', 'manhattan')
|
17
17
|
# @format :json, :xml
|
18
|
-
def address(house_number
|
18
|
+
def address(house_number:, street:, borough: nil, zip: nil)
|
19
19
|
options = {
|
20
20
|
houseNumber: house_number,
|
21
21
|
street: street,
|
22
|
-
borough: borough
|
23
|
-
|
22
|
+
borough: borough,
|
23
|
+
zip: zip
|
24
|
+
}.reject { |k, v| v.nil? }
|
24
25
|
get(address_path, options)
|
25
26
|
end
|
26
27
|
|
@@ -12,7 +12,7 @@ module NYCGeoClient
|
|
12
12
|
# @example property level information about a tax lot
|
13
13
|
# NYCGeoClient.bbl('manhattan','00233', '0004')
|
14
14
|
# @format :json, :xml
|
15
|
-
def bbl(borough
|
15
|
+
def bbl(borough:, block:, lot:)
|
16
16
|
options = {
|
17
17
|
block: block,
|
18
18
|
lot: lot,
|
@@ -17,13 +17,16 @@ module NYCGeoClient
|
|
17
17
|
# @example information about a segment defined by an on street between two cross-streets
|
18
18
|
# NYCGeoClient.blockface('34 st', 'fifht ave', 'sixth ave', 'manhattan')
|
19
19
|
# @format :json, :xml
|
20
|
-
def blockface(on_street
|
20
|
+
def blockface(on_street:, cross_street_one:, cross_street_two:, borough:, borough_cross_street_one: nil, borough_cross_street_two: nil, compass_direction: nil)
|
21
21
|
options = {
|
22
22
|
onStreet: on_street,
|
23
23
|
crossStreetOne: cross_street_one,
|
24
24
|
crossStreetTwo: cross_street_two,
|
25
|
-
borough: borough
|
26
|
-
|
25
|
+
borough: borough,
|
26
|
+
boroughCrossStreetOne: borough_cross_street_one,
|
27
|
+
boroughCrossStreetTwo: borough_cross_street_two,
|
28
|
+
compassDirection: compass_direction
|
29
|
+
}.reject { |k, v| v.nil? }
|
27
30
|
get(blockface_path, options)
|
28
31
|
end
|
29
32
|
|
@@ -15,12 +15,14 @@ module NYCGeoClient
|
|
15
15
|
# @example information about a segment defined by an on street between two cross-streets
|
16
16
|
# NYCGeoClient.blockface('34 st', 'fifht ave', 'manhattan')
|
17
17
|
# @format :json, :xml
|
18
|
-
def intersection(cross_street_one
|
18
|
+
def intersection(cross_street_one:, cross_street_two:, borough:, borough_cross_street_two: nil, compass_direction: nil)
|
19
19
|
options = {
|
20
20
|
crossStreetOne: cross_street_one,
|
21
21
|
crossStreetTwo: cross_street_two,
|
22
|
-
borough: borough
|
23
|
-
|
22
|
+
borough: borough,
|
23
|
+
boroughCrossStreetTwo: borough_cross_street_two,
|
24
|
+
compassDirection: compass_direction
|
25
|
+
}.reject { |k, v| v.nil? }
|
24
26
|
get(intersection_path, options)
|
25
27
|
end
|
26
28
|
|
@@ -11,11 +11,12 @@ module NYCGeoClient
|
|
11
11
|
# @example address information using a well-known place name
|
12
12
|
# NYCGeoClient.place('empire state building')
|
13
13
|
# @format :json, :xml
|
14
|
-
def place(name,
|
14
|
+
def place(name:, borough: nil, zip: nil)
|
15
15
|
options = {
|
16
16
|
name: name,
|
17
|
-
borough: borough
|
18
|
-
|
17
|
+
borough: borough,
|
18
|
+
zip: zip
|
19
|
+
}.reject { |k, v| v.nil? }
|
19
20
|
get(place_path, options)
|
20
21
|
end
|
21
22
|
|
@@ -22,13 +22,13 @@ describe Faraday::Response do
|
|
22
22
|
|
23
23
|
it "should raise a NYCGeoClient error" do
|
24
24
|
expect(lambda do
|
25
|
-
@client.address('13','crosby','manhattan')
|
25
|
+
@client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
26
26
|
end).to raise_error(NYCGeoClient::Error)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should return the status and body" do
|
30
30
|
begin
|
31
|
-
@client.address('13','crosby','manhattan')
|
31
|
+
@client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
32
32
|
rescue NYCGeoClient::Error => ex
|
33
33
|
expect(ex.status).to eq status
|
34
34
|
parts = ex.message.split(": ")
|
@@ -10,34 +10,68 @@ describe NYCGeoClient::Client do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".address" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
context 'given a borough' do
|
14
|
+
before do
|
15
|
+
stub_get("address.#{format}").
|
16
|
+
with(
|
17
|
+
query: {
|
18
|
+
app_id: @client.app_id,
|
19
|
+
app_key: @client.app_key,
|
20
|
+
houseNumber: '13',
|
21
|
+
street: 'crosby',
|
22
|
+
borough: 'manhattan'
|
23
|
+
}).
|
24
|
+
to_return(body: fixture("address.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should get the correct resource" do
|
28
|
+
@client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
29
|
+
expect(a_get("address.#{format}").
|
30
|
+
with(query: {
|
17
31
|
app_id: @client.app_id,
|
18
32
|
app_key: @client.app_key,
|
19
33
|
houseNumber: '13',
|
20
34
|
street: 'crosby',
|
21
35
|
borough: 'manhattan'
|
22
|
-
}).
|
23
|
-
|
24
|
-
end
|
36
|
+
})).to have_been_made
|
37
|
+
end
|
25
38
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
app_id: @client.app_id,
|
31
|
-
app_key: @client.app_key,
|
32
|
-
houseNumber: '13',
|
33
|
-
street: 'crosby',
|
34
|
-
borough: 'manhattan'
|
35
|
-
})).to have_been_made
|
39
|
+
it "should return the address info" do
|
40
|
+
data = @client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
41
|
+
expect(data.keys).to eq ["address"]
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
context 'given a ZIP' do
|
46
|
+
before do
|
47
|
+
stub_get("address.#{format}").
|
48
|
+
with(
|
49
|
+
query: {
|
50
|
+
app_id: @client.app_id,
|
51
|
+
app_key: @client.app_key,
|
52
|
+
houseNumber: '13',
|
53
|
+
street: 'crosby',
|
54
|
+
zip: '10013'
|
55
|
+
}).
|
56
|
+
to_return(body: fixture("address.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should get the correct resource" do
|
60
|
+
@client.address(house_number: '13', street: 'crosby', zip: '10013')
|
61
|
+
expect(a_get("address.#{format}").
|
62
|
+
with(query: {
|
63
|
+
app_id: @client.app_id,
|
64
|
+
app_key: @client.app_key,
|
65
|
+
houseNumber: '13',
|
66
|
+
street: 'crosby',
|
67
|
+
zip: '10013'
|
68
|
+
})).to have_been_made
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return the address info" do
|
72
|
+
data = @client.address(house_number: '13', street: 'crosby', zip: '10013')
|
73
|
+
expect(data.keys).to eq ["address"]
|
74
|
+
end
|
41
75
|
end
|
42
76
|
end
|
43
77
|
end
|
@@ -24,7 +24,7 @@ describe NYCGeoClient::Client do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should get the correct resource" do
|
27
|
-
@client.bbl('manhattan', '00233', '0004')
|
27
|
+
@client.bbl(borough: 'manhattan', block: '00233', lot: '0004')
|
28
28
|
expect(a_get("bbl.#{format}").
|
29
29
|
with(query: {
|
30
30
|
app_id: @client.app_id,
|
@@ -36,7 +36,7 @@ describe NYCGeoClient::Client do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return the bbl info" do
|
39
|
-
data = @client.bbl('manhattan', '00233', '0004')
|
39
|
+
data = @client.bbl(borough: 'manhattan', block: '00233', lot: '0004')
|
40
40
|
expect(data.keys).to eq ["bbl"]
|
41
41
|
end
|
42
42
|
end
|
@@ -22,7 +22,7 @@ describe NYCGeoClient::Client do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should get the correct resource" do
|
25
|
-
@client.bin('1003041')
|
25
|
+
@client.bin(bin: '1003041')
|
26
26
|
expect(a_get("bin.#{format}").
|
27
27
|
with(query: {
|
28
28
|
app_id: @client.app_id,
|
@@ -32,7 +32,7 @@ describe NYCGeoClient::Client do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return the bin info" do
|
35
|
-
data = @client.bin('1003041')
|
35
|
+
data = @client.bin(bin: '1003041')
|
36
36
|
expect(data.keys).to eq ["bin"]
|
37
37
|
end
|
38
38
|
end
|
@@ -26,7 +26,14 @@ describe NYCGeoClient::Client do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should get the correct resource" do
|
29
|
-
@client.blockface(
|
29
|
+
@client.blockface(
|
30
|
+
on_street: '34 st',
|
31
|
+
cross_street_one: 'fifth ave',
|
32
|
+
cross_street_two: 'sixth ave',
|
33
|
+
borough: 'manhattan',
|
34
|
+
compass_direction: 'north'
|
35
|
+
)
|
36
|
+
|
30
37
|
expect(a_get("blockface.#{format}").
|
31
38
|
with(query: {
|
32
39
|
app_id: @client.app_id,
|
@@ -40,7 +47,14 @@ describe NYCGeoClient::Client do
|
|
40
47
|
end
|
41
48
|
|
42
49
|
it "should return the blockface info" do
|
43
|
-
data = @client.blockface(
|
50
|
+
data = @client.blockface(
|
51
|
+
on_street: '34 st',
|
52
|
+
cross_street_one: 'fifth ave',
|
53
|
+
cross_street_two: 'sixth ave',
|
54
|
+
borough: 'manhattan',
|
55
|
+
compass_direction: 'north'
|
56
|
+
)
|
57
|
+
|
44
58
|
expect(data.keys).to eq ["blockface"]
|
45
59
|
end
|
46
60
|
end
|
@@ -25,7 +25,13 @@ describe NYCGeoClient::Client do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should get the correct resource" do
|
28
|
-
@client.intersection(
|
28
|
+
@client.intersection(
|
29
|
+
cross_street_one: '34 st',
|
30
|
+
cross_street_two: 'fifth ave',
|
31
|
+
borough: 'manhattan',
|
32
|
+
compass_direction: 'north'
|
33
|
+
)
|
34
|
+
|
29
35
|
expect(a_get("intersection.#{format}").
|
30
36
|
with(query: {
|
31
37
|
app_id: @client.app_id,
|
@@ -38,7 +44,13 @@ describe NYCGeoClient::Client do
|
|
38
44
|
end
|
39
45
|
|
40
46
|
it "should return the intersection info" do
|
41
|
-
data = @client.intersection(
|
47
|
+
data = @client.intersection(
|
48
|
+
cross_street_one: '34 st',
|
49
|
+
cross_street_two: 'fifth ave',
|
50
|
+
borough: 'manhattan',
|
51
|
+
compass_direction: 'north'
|
52
|
+
)
|
53
|
+
|
42
54
|
expect(data.keys).to eq ["intersection"]
|
43
55
|
end
|
44
56
|
end
|
@@ -10,32 +10,64 @@ describe NYCGeoClient::Client do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".place" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
context 'given a borough' do
|
14
|
+
before do
|
15
|
+
stub_get("place.#{format}").
|
16
|
+
with(
|
17
|
+
query: {
|
18
|
+
app_id: @client.app_id,
|
19
|
+
app_key: @client.app_key,
|
20
|
+
name: 'empire state building',
|
21
|
+
borough: 'manhattan'
|
22
|
+
}).
|
23
|
+
to_return(body: fixture("place.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should get the correct resource" do
|
27
|
+
@client.place(name: 'empire state building', borough: 'manhattan')
|
28
|
+
expect(a_get("place.#{format}").
|
29
|
+
with(query: {
|
17
30
|
app_id: @client.app_id,
|
18
31
|
app_key: @client.app_key,
|
19
32
|
name: 'empire state building',
|
20
33
|
borough: 'manhattan'
|
21
|
-
}).
|
22
|
-
|
23
|
-
end
|
34
|
+
})).to have_been_made
|
35
|
+
end
|
24
36
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
app_id: @client.app_id,
|
30
|
-
app_key: @client.app_key,
|
31
|
-
name: 'empire state building',
|
32
|
-
borough: 'manhattan'
|
33
|
-
})).to have_been_made
|
37
|
+
it "should return the place info" do
|
38
|
+
data = @client.place(name: 'empire state building', borough: 'manhattan')
|
39
|
+
expect(data.keys).to eq ["place"]
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
context 'given a zip' do
|
44
|
+
before do
|
45
|
+
stub_get("place.#{format}").
|
46
|
+
with(
|
47
|
+
query: {
|
48
|
+
app_id: @client.app_id,
|
49
|
+
app_key: @client.app_key,
|
50
|
+
name: 'empire state building',
|
51
|
+
zip: '10118'
|
52
|
+
}).
|
53
|
+
to_return(body: fixture("place.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should get the correct resource" do
|
57
|
+
@client.place(name: 'empire state building', zip: '10118')
|
58
|
+
expect(a_get("place.#{format}").
|
59
|
+
with(query: {
|
60
|
+
app_id: @client.app_id,
|
61
|
+
app_key: @client.app_key,
|
62
|
+
name: 'empire state building',
|
63
|
+
zip: '10118'
|
64
|
+
})).to have_been_made
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return the place info" do
|
68
|
+
data = @client.place(name: 'empire state building', zip: '10118')
|
69
|
+
expect(data.keys).to eq ["place"]
|
70
|
+
end
|
39
71
|
end
|
40
72
|
end
|
41
73
|
end
|
data/spec/nyc_geo_client_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe NYCGeoClient do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should get the correct resource" do
|
22
|
-
NYCGeoClient.address('13', 'crosby', 'manhattan')
|
22
|
+
NYCGeoClient.address(house_number: '13', street: 'crosby', borough: 'manhattan')
|
23
23
|
expect(a_get("address.json").
|
24
24
|
with(query: {
|
25
25
|
houseNumber: '13',
|
@@ -29,7 +29,17 @@ describe NYCGeoClient do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should return the same results as a client" do
|
32
|
-
|
32
|
+
expect(
|
33
|
+
NYCGeoClient.address(
|
34
|
+
house_number: '13',
|
35
|
+
street: 'crosby',
|
36
|
+
borough: 'manhattan'
|
37
|
+
)
|
38
|
+
).to eq NYCGeoClient::Client.new.address(
|
39
|
+
house_number: '13',
|
40
|
+
street: 'crosby',
|
41
|
+
borough: 'manhattan'
|
42
|
+
)
|
33
43
|
end
|
34
44
|
|
35
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyc_geo_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.6.14
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: A ruby wrapper for NYCGeoClient API
|