nyc_geo_client 0.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 00aa43b9e742e2fd169a884a4acbc6d79f749d27
4
- data.tar.gz: 38a637417667ae915ec8bc510bcfd1d30d551956
2
+ SHA256:
3
+ metadata.gz: d67887dee4749084a26e14d54c176afaf9c69048715eaf920ec99cee21661e53
4
+ data.tar.gz: a122a47fc1b18f062d73f7801fa5f9cd1c4a4db9d809e8e14ef6707a090a530e
5
5
  SHA512:
6
- metadata.gz: 97a2bf6058b91ff52f9ffbb33b520a20aedd375ebb3dbd6612a41fa055b8b0130ae1f8ccabe3587cc0651e44ec59ea7e716492f193bb0312d3771c1ee67a834a
7
- data.tar.gz: 620488b63ee0dc625f267124be32347e407e4f516296c544a48c6a815b3634cf6ca48185d5efb687657598ed2d30893c87ceba8c31b4cd8272b96a50420804c4
6
+ metadata.gz: c517c118646ba63a84440422a4ca7157f6dfb90c870aed3f9a84928215334973c2f78a5f7ffda14bb63b699ba3d56b8c4c82fa29e6f0dae8567b6723f2889db7
7
+ data.tar.gz: f452f09c95b766e1e524af83075b472a4237b05d98896d7979d99985ed33e7ca9f587532673f1c1ed4ed1f792aac375b49541d92ff374c51bb689379c12ed05f
data/.travis.yml CHANGED
@@ -3,7 +3,12 @@ matrix:
3
3
  allow_failures:
4
4
  - rvm: ruby-head
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1.0
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+ - 2.7
9
10
  - ruby-head
11
+ before_install:
12
+ # need this for ruby 1.9.3 and rspec
13
+ - gem update --system
14
+ - gem update bundler --force
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # NYCGeoClient [![Build Status](https://travis-ci.org/edgar/NYCGeoClient.png?branch=master)](https://travis-ci.org/edgar/NYCGeoClient)
2
- A ruby gem for the NYC GeoClient API - https://developer.cityofnewyork.us/api/geoclient-api-beta
1
+ # NYCGeoClient [![Build Status](https://app.travis-ci.com/edgar/NYCGeoClient.svg?branch=master)](https://app.travis-ci.com/edgar/NYCGeoClient) [![Gem Version](https://badge.fury.io/rb/nyc_geo_client.svg)](http://badge.fury.io/rb/nyc_geo_client)
2
+ A ruby gem for the NYC GeoClient API - https://api-portal.nyc.gov/docs/services/geoclient/operations/geoclient
3
3
 
4
4
  ## Installation
5
5
 
@@ -16,32 +16,41 @@ Or install it yourself as:
16
16
  $ gem install nyc_geo_client
17
17
 
18
18
 
19
- *NOTE:* You will need to register an application with the [NYC Developer Portal](https://developer.cityofnewyork.us/), and make sure that you check off access to the Geoclient API for the application. Take note of the Application's ID and key.
19
+ *NOTE:* You will need to register an application with the [NYC API Portal](https://api-portal.nyc.gov/), and make sure that you check off access to the Geoclient API for the application. Take note of the Application's subscription key.
20
20
 
21
21
  ## API Usage Examples
22
22
 
23
23
  require "rubygems"
24
24
  require "nyc_geo_client"
25
25
 
26
- client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY')
26
+ client = NYCGeoClient::Client.new(subscription_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('34 st', 'fifth ave', 'sixth ave', 'manhattan')
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('34 st', 'fifth ave', 'manhattan')
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,8 +78,16 @@ 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
 
83
+ ## Ruby versions supported
84
+
85
+ * 2.4
86
+ * 2.5
87
+ * 2.6
88
+ * 2.7
89
+
90
+ Check the [.travis.yml](.travis.yml) to see the current supported ruby versions.
74
91
 
75
92
  ## Contributing
76
93
 
data/Rakefile CHANGED
@@ -26,5 +26,5 @@ end
26
26
 
27
27
  desc "Open an irb session preloaded with this library"
28
28
  task :console do
29
- sh "irb -rubygems -I lib -r nyc_geo_client.rb"
30
- end
29
+ sh "irb -r rubygems -I lib -r nyc_geo_client.rb"
30
+ end
@@ -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, street, borough)
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, block, lot)
15
+ def bbl(borough:, block:, lot:)
16
16
  options = {
17
17
  block: block,
18
18
  lot: lot,
@@ -10,7 +10,7 @@ module NYCGeoClient
10
10
  # @example property level information about a building
11
11
  # NYCGeoClient.bin('1003041')
12
12
  # @format :json, :xml
13
- def bin(bin)
13
+ def bin(bin:)
14
14
  options = {
15
15
  bin: bin
16
16
  }
@@ -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, cross_street_one, cross_street_two, borough, extra = {})
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
- }.merge(extra)
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, cross_street_two, borough, extra = {})
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
- }.merge(extra)
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, borough)
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
 
@@ -7,8 +7,7 @@ module NYCGeoClient
7
7
  # An array of valid keys in the options hash when configuring a {NYCGeoClient::API}
8
8
  VALID_OPTIONS_KEYS = [
9
9
  :adapter,
10
- :app_id,
11
- :app_key,
10
+ :subscription_key,
12
11
  :endpoint,
13
12
  :format,
14
13
  :user_agent,
@@ -24,16 +23,13 @@ module NYCGeoClient
24
23
  # @note The default faraday adapter is Net::HTTP.
25
24
  DEFAULT_ADAPTER = Faraday.default_adapter
26
25
 
27
- # By default, don't set an application ID
28
- DEFAULT_APP_ID = nil
29
-
30
26
  # By default, don't set an application KEY
31
- DEFAULT_APP_KEY = nil
27
+ DEFAULT_SUBSCRIPTION_KEY = nil
32
28
 
33
29
  # The endpoint that will be used to connect if none is set
34
30
  #
35
31
  # @note There is no reason to use any other endpoint at this time
36
- DEFAULT_ENDPOINT = 'https://api.cityofnewyork.us/geoclient/v1/'.freeze
32
+ DEFAULT_ENDPOINT = 'https://api.nyc.gov/geo/geoclient/v1/'.freeze
37
33
 
38
34
  # The response format appended to the path and sent in the 'Accept' header if none is set
39
35
  #
@@ -71,14 +67,13 @@ module NYCGeoClient
71
67
 
72
68
  # Reset all configuration options to defaults
73
69
  def reset
74
- self.adapter = DEFAULT_ADAPTER
75
- self.app_id = DEFAULT_APP_ID
76
- self.app_key = DEFAULT_APP_KEY
77
- self.endpoint = DEFAULT_ENDPOINT
78
- self.format = DEFAULT_FORMAT
79
- self.user_agent = DEFAULT_USER_AGENT
80
- self.proxy = DEFAULT_PROXY
81
- self.debug = DEFAULT_DEBUG
70
+ self.adapter = DEFAULT_ADAPTER
71
+ self.subscription_key = DEFAULT_SUBSCRIPTION_KEY
72
+ self.endpoint = DEFAULT_ENDPOINT
73
+ self.format = DEFAULT_FORMAT
74
+ self.user_agent = DEFAULT_USER_AGENT
75
+ self.proxy = DEFAULT_PROXY
76
+ self.debug = DEFAULT_DEBUG
82
77
  end
83
78
  end
84
- end
79
+ end
@@ -8,10 +8,14 @@ module NYCGeoClient
8
8
 
9
9
  def connection(raw=false)
10
10
  options = {
11
- :headers => {'Accept' => "application/json; charset=utf-8", 'User-Agent' => user_agent},
12
- :proxy => proxy,
13
- :ssl => {:verify => false},
14
- :url => endpoint,
11
+ headers: {
12
+ 'Accept' => "application/json; charset=utf-8",
13
+ 'User-Agent' => user_agent,
14
+ 'Ocp-Apim-Subscription-Key' => subscription_key
15
+ },
16
+ proxy: proxy,
17
+ ssl: {verify: false},
18
+ url: endpoint
15
19
  }
16
20
 
17
21
  Faraday::Connection.new(options) do |connection|
@@ -27,4 +31,4 @@ module NYCGeoClient
27
31
  end
28
32
  end
29
33
  end
30
- end
34
+ end
@@ -25,15 +25,14 @@ module NYCGeoClient
25
25
 
26
26
  # Perform an HTTP request
27
27
  def request(method, path, options, raw=false)
28
- new_options = access_params.merge(options)
29
28
  response = connection(raw).send(method) do |request|
30
29
  path = formatted_path(path)
31
30
  case method
32
31
  when :get, :delete
33
- request.url(path, new_options)
32
+ request.url(path, options)
34
33
  when :post, :put
35
34
  request.path = path
36
- request.body = new_options unless new_options.empty?
35
+ request.body = options unless options.empty?
37
36
  end
38
37
  end
39
38
  if raw
@@ -48,12 +47,5 @@ module NYCGeoClient
48
47
  def formatted_path(path)
49
48
  [path, format].compact.join('.')
50
49
  end
51
-
52
- def access_params
53
- hash = {}
54
- hash[:app_id] = app_id if app_id
55
- hash[:app_key] = app_key if app_key
56
- hash
57
- end
58
50
  end
59
- end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module NYCGeoClient
2
- VERSION = "0.0.1".freeze unless defined?(::NYCGeoClient::VERSION)
2
+ VERSION = "2.0.0".freeze unless defined?(::NYCGeoClient::VERSION)
3
3
  end
@@ -14,13 +14,13 @@ module NYCGeoClient
14
14
  end
15
15
 
16
16
  # Delegate to NYCGeoClient::Client
17
- def self.method_missing(method, *args, &block)
17
+ def self.method_missing(method, **kwargs, &block)
18
18
  return super unless client.respond_to?(method)
19
- client.send(method, *args, &block)
19
+ client.public_send(method, **kwargs, &block)
20
20
  end
21
21
 
22
22
  # Delegate to NYCGeoClient::Client
23
- def self.respond_to?(method)
23
+ def self.respond_to?(method, include_all=false)
24
24
  return client.respond_to?(method) || super
25
25
  end
26
26
  end
@@ -3,16 +3,15 @@ require File.expand_path('../lib/nyc_geo_client/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.add_development_dependency 'rake'
6
- gem.add_development_dependency('rspec', '~> 2.14.1')
7
- gem.add_development_dependency('webmock', '~> 1.17.1')
8
- gem.add_development_dependency('yard', '~> 0.8.7.3')
9
- gem.add_development_dependency('bluecloth', '~> 2.2.0')
6
+ gem.add_development_dependency('rspec', '~> 3.10.0')
7
+ gem.add_development_dependency('webmock', '~> 3.14.0')
8
+ gem.add_development_dependency('yard', '~> 0.9.26')
10
9
 
11
- gem.add_runtime_dependency('faraday', '~> 0.8.8')
12
- gem.add_runtime_dependency('faraday_middleware', '~> 0.9.0')
13
- gem.add_runtime_dependency('multi_json', '~> 1.8.4')
14
- gem.add_runtime_dependency('multi_xml', '~> 0.5.5')
15
- gem.add_runtime_dependency('hashie', '~> 2.0.5')
10
+ gem.add_runtime_dependency('faraday', '~> 1.7.2')
11
+ gem.add_runtime_dependency('faraday_middleware', '~> 1.1.0')
12
+ gem.add_runtime_dependency('multi_json', '~> 1.15.0')
13
+ gem.add_runtime_dependency('multi_xml', '~> 0.6.0')
14
+ gem.add_runtime_dependency('hashie', '~> 4.1.0')
16
15
  gem.authors = ["Edgar Gonzalez"]
17
16
  gem.email = ["edgargonzalez@gmail.com"]
18
17
  gem.description = %q{A ruby wrapper for NYCGeoClient API}
@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe Faraday::Response do
4
4
  before do
5
- @client = NYCGeoClient::Client.new(app_id: 'foo', app_key: 'bar')
5
+ @client = NYCGeoClient::Client.new(subscription_key: 'foo')
6
6
  end
7
7
 
8
8
  [403, 500, 503].each do |status|
@@ -11,8 +11,6 @@ describe Faraday::Response do
11
11
  stub_get("address.json").
12
12
  with(
13
13
  query: {
14
- app_id: @client.app_id,
15
- app_key: @client.app_key,
16
14
  houseNumber: '13',
17
15
  street: 'crosby',
18
16
  borough: 'manhattan'
@@ -21,21 +19,20 @@ describe Faraday::Response do
21
19
  end
22
20
 
23
21
  it "should raise a NYCGeoClient error" do
24
- lambda do
25
- @client.address('13','crosby','manhattan')
26
- end.should raise_error(NYCGeoClient::Error)
22
+ expect(lambda do
23
+ @client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
24
+ end).to raise_error(NYCGeoClient::Error)
27
25
  end
28
26
 
29
27
  it "should return the status and body" do
30
28
  begin
31
- @client.address('13','crosby','manhattan')
29
+ @client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
32
30
  rescue NYCGeoClient::Error => ex
33
- ex.status.should be == status
34
- ex.message.split(": ").should be == [
35
- "GET https://api.cityofnewyork.us/geoclient/v1/address.json?app_id=foo&app_key=bar&houseNumber=13&street=crosby&borough=manhattan",
36
- "#{status}",
37
- "some message"
38
- ]
31
+ expect(ex.status).to eq status
32
+ parts = ex.message.split(": ")
33
+ expect(parts[0]).to match /GET https:\/\/api.nyc.gov\/geo\/geoclient\/v1\/address.json/
34
+ expect(parts[1]).to eq "#{status}"
35
+ expect(parts[2]).to eq "some message"
39
36
  end
40
37
  end
41
38
  end
@@ -22,7 +22,7 @@ describe NYCGeoClient::API do
22
22
  it "should inherit module configuration" do
23
23
  api = NYCGeoClient::API.new
24
24
  @keys.each do |key|
25
- api.send(key).should == key
25
+ expect(api.send(key)).to eq key
26
26
  end
27
27
  end
28
28
 
@@ -30,8 +30,7 @@ describe NYCGeoClient::API do
30
30
 
31
31
  before do
32
32
  @configuration = {
33
- :app_id => 'ID',
34
- :app_key => 'KEY',
33
+ :subscription_key => 'KEY',
35
34
  :adapter => :typhoeus,
36
35
  :endpoint => 'http://tumblr.com/',
37
36
  :format => :xml,
@@ -46,7 +45,7 @@ describe NYCGeoClient::API do
46
45
  it "should override module configuration" do
47
46
  api = NYCGeoClient::API.new(@configuration)
48
47
  @keys.each do |key|
49
- api.send(key).should == @configuration[key]
48
+ expect(api.send(key)).to eq @configuration[key]
50
49
  end
51
50
  end
52
51
 
@@ -58,10 +57,10 @@ describe NYCGeoClient::API do
58
57
  api.send("#{key}=", value)
59
58
  end
60
59
  @keys.each do |key|
61
- api.send(key).should == @configuration[key]
60
+ expect(api.send(key)).to eq @configuration[key]
62
61
  end
63
62
  end
64
63
  end
65
64
  end
66
65
  end
67
- end
66
+ end
@@ -6,38 +6,64 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".address" do
13
- before do
14
- stub_get("address.#{format}").
15
- with(
16
- query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
13
+ context 'given a borough' do
14
+ before do
15
+ stub_get("address.#{format}").
16
+ with(
17
+ query: {
18
+ houseNumber: '13',
19
+ street: 'crosby',
20
+ borough: 'manhattan'
21
+ }).
22
+ to_return(body: fixture("address.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
23
+ end
24
+
25
+ it "should get the correct resource" do
26
+ @client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
27
+ expect(a_get("address.#{format}").
28
+ with(query: {
19
29
  houseNumber: '13',
20
30
  street: 'crosby',
21
31
  borough: 'manhattan'
22
- }).
23
- to_return(body: fixture("address.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
24
- end
32
+ })).to have_been_made
33
+ end
25
34
 
26
- it "should get the correct resource" do
27
- @client.address('13', 'crosby', 'manhattan')
28
- a_get("address.#{format}").
29
- with(query: {
30
- app_id: @client.app_id,
31
- app_key: @client.app_key,
32
- houseNumber: '13',
33
- street: 'crosby',
34
- borough: 'manhattan'
35
- }).should have_been_made
35
+ it "should return the address info" do
36
+ data = @client.address(house_number: '13', street: 'crosby', borough: 'manhattan')
37
+ expect(data.keys).to eq ["address"]
38
+ end
36
39
  end
37
40
 
38
- it "should return the address info" do
39
- data = @client.address('13', 'crosby', 'manhattan')
40
- data.keys.should be == ["address"]
41
+ context 'given a ZIP' do
42
+ before do
43
+ stub_get("address.#{format}").
44
+ with(
45
+ query: {
46
+ houseNumber: '13',
47
+ street: 'crosby',
48
+ zip: '10013'
49
+ }).
50
+ to_return(body: fixture("address.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
51
+ end
52
+
53
+ it "should get the correct resource" do
54
+ @client.address(house_number: '13', street: 'crosby', zip: '10013')
55
+ expect(a_get("address.#{format}").
56
+ with(query: {
57
+ houseNumber: '13',
58
+ street: 'crosby',
59
+ zip: '10013'
60
+ })).to have_been_made
61
+ end
62
+
63
+ it "should return the address info" do
64
+ data = @client.address(house_number: '13', street: 'crosby', zip: '10013')
65
+ expect(data.keys).to eq ["address"]
66
+ end
41
67
  end
42
68
  end
43
69
  end
@@ -6,7 +6,7 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".bbl" do
@@ -14,8 +14,6 @@ describe NYCGeoClient::Client do
14
14
  stub_get("bbl.#{format}").
15
15
  with(
16
16
  query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
19
17
  borough: 'manhattan',
20
18
  block: '00233',
21
19
  lot: '0004',
@@ -24,20 +22,18 @@ describe NYCGeoClient::Client do
24
22
  end
25
23
 
26
24
  it "should get the correct resource" do
27
- @client.bbl('manhattan', '00233', '0004')
28
- a_get("bbl.#{format}").
25
+ @client.bbl(borough: 'manhattan', block: '00233', lot: '0004')
26
+ expect(a_get("bbl.#{format}").
29
27
  with(query: {
30
- app_id: @client.app_id,
31
- app_key: @client.app_key,
32
28
  borough: 'manhattan',
33
29
  block: '00233',
34
30
  lot: '0004',
35
- }).should have_been_made
31
+ })).to have_been_made
36
32
  end
37
33
 
38
34
  it "should return the bbl info" do
39
- data = @client.bbl('manhattan', '00233', '0004')
40
- data.keys.should be == ["bbl"]
35
+ data = @client.bbl(borough: 'manhattan', block: '00233', lot: '0004')
36
+ expect(data.keys).to eq ["bbl"]
41
37
  end
42
38
  end
43
39
  end
@@ -6,7 +6,7 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".bin" do
@@ -14,26 +14,22 @@ describe NYCGeoClient::Client do
14
14
  stub_get("bin.#{format}").
15
15
  with(
16
16
  query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
19
17
  bin: '1003041',
20
18
  }).
21
19
  to_return(body: fixture("bin.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
22
20
  end
23
21
 
24
22
  it "should get the correct resource" do
25
- @client.bin('1003041')
26
- a_get("bin.#{format}").
23
+ @client.bin(bin: '1003041')
24
+ expect(a_get("bin.#{format}").
27
25
  with(query: {
28
- app_id: @client.app_id,
29
- app_key: @client.app_key,
30
26
  bin: '1003041',
31
- }).should have_been_made
27
+ })).to have_been_made
32
28
  end
33
29
 
34
30
  it "should return the bin info" do
35
- data = @client.bin('1003041')
36
- data.keys.should be == ["bin"]
31
+ data = @client.bin(bin: '1003041')
32
+ expect(data.keys).to eq ["bin"]
37
33
  end
38
34
  end
39
35
  end
@@ -6,7 +6,7 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".blockface" do
@@ -14,8 +14,6 @@ describe NYCGeoClient::Client do
14
14
  stub_get("blockface.#{format}").
15
15
  with(
16
16
  query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
19
17
  onStreet: '34 st',
20
18
  crossStreetOne: 'fifth ave',
21
19
  crossStreetTwo: 'sixth ave',
@@ -26,22 +24,34 @@ describe NYCGeoClient::Client do
26
24
  end
27
25
 
28
26
  it "should get the correct resource" do
29
- @client.blockface('34 st', 'fifth ave', 'sixth ave', 'manhattan', {compassDirection: 'north'})
30
- a_get("blockface.#{format}").
27
+ @client.blockface(
28
+ on_street: '34 st',
29
+ cross_street_one: 'fifth ave',
30
+ cross_street_two: 'sixth ave',
31
+ borough: 'manhattan',
32
+ compass_direction: 'north'
33
+ )
34
+
35
+ expect(a_get("blockface.#{format}").
31
36
  with(query: {
32
- app_id: @client.app_id,
33
- app_key: @client.app_key,
34
37
  onStreet: '34 st',
35
38
  crossStreetOne: 'fifth ave',
36
39
  crossStreetTwo: 'sixth ave',
37
40
  borough: 'manhattan',
38
41
  compassDirection: 'north'
39
- }).should have_been_made
42
+ })).to have_been_made
40
43
  end
41
44
 
42
45
  it "should return the blockface info" do
43
- data = @client.blockface('34 st', 'fifth ave', 'sixth ave', 'manhattan', {compassDirection: 'north'})
44
- data.keys.should be == ["blockface"]
46
+ data = @client.blockface(
47
+ on_street: '34 st',
48
+ cross_street_one: 'fifth ave',
49
+ cross_street_two: 'sixth ave',
50
+ borough: 'manhattan',
51
+ compass_direction: 'north'
52
+ )
53
+
54
+ expect(data.keys).to eq ["blockface"]
45
55
  end
46
56
  end
47
57
  end
@@ -6,7 +6,7 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".intersection" do
@@ -14,8 +14,6 @@ describe NYCGeoClient::Client do
14
14
  stub_get("intersection.#{format}").
15
15
  with(
16
16
  query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
19
17
  crossStreetOne: '34 st',
20
18
  crossStreetTwo: 'fifth ave',
21
19
  borough: 'manhattan',
@@ -25,21 +23,31 @@ describe NYCGeoClient::Client do
25
23
  end
26
24
 
27
25
  it "should get the correct resource" do
28
- @client.intersection('34 st', 'fifth ave', 'manhattan', {compassDirection: 'north'})
29
- a_get("intersection.#{format}").
26
+ @client.intersection(
27
+ cross_street_one: '34 st',
28
+ cross_street_two: 'fifth ave',
29
+ borough: 'manhattan',
30
+ compass_direction: 'north'
31
+ )
32
+
33
+ expect(a_get("intersection.#{format}").
30
34
  with(query: {
31
- app_id: @client.app_id,
32
- app_key: @client.app_key,
33
35
  crossStreetOne: '34 st',
34
36
  crossStreetTwo: 'fifth ave',
35
37
  borough: 'manhattan',
36
38
  compassDirection: 'north'
37
- }).should have_been_made
39
+ })).to have_been_made
38
40
  end
39
41
 
40
42
  it "should return the intersection info" do
41
- data = @client.intersection('34 st', 'fifth ave', 'manhattan', {compassDirection: 'north'})
42
- data.keys.should be == ["intersection"]
43
+ data = @client.intersection(
44
+ cross_street_one: '34 st',
45
+ cross_street_two: 'fifth ave',
46
+ borough: 'manhattan',
47
+ compass_direction: 'north'
48
+ )
49
+
50
+ expect(data.keys).to eq ["intersection"]
43
51
  end
44
52
  end
45
53
  end
@@ -6,36 +6,60 @@ describe NYCGeoClient::Client do
6
6
  context ".new(:format => '#{format}')" do
7
7
 
8
8
  before do
9
- @client = NYCGeoClient::Client.new(app_id: 'ID', app_key: 'KEY', format: format)
9
+ @client = NYCGeoClient::Client.new(subscription_key: 'KEY', format: format)
10
10
  end
11
11
 
12
12
  describe ".place" do
13
- before do
14
- stub_get("place.#{format}").
15
- with(
16
- query: {
17
- app_id: @client.app_id,
18
- app_key: @client.app_key,
13
+ context 'given a borough' do
14
+ before do
15
+ stub_get("place.#{format}").
16
+ with(
17
+ query: {
18
+ name: 'empire state building',
19
+ borough: 'manhattan'
20
+ }).
21
+ to_return(body: fixture("place.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
22
+ end
23
+
24
+ it "should get the correct resource" do
25
+ @client.place(name: 'empire state building', borough: 'manhattan')
26
+ expect(a_get("place.#{format}").
27
+ with(query: {
19
28
  name: 'empire state building',
20
29
  borough: 'manhattan'
21
- }).
22
- to_return(body: fixture("place.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
23
- end
30
+ })).to have_been_made
31
+ end
24
32
 
25
- it "should get the correct resource" do
26
- @client.place('empire state building', 'manhattan')
27
- a_get("place.#{format}").
28
- with(query: {
29
- app_id: @client.app_id,
30
- app_key: @client.app_key,
31
- name: 'empire state building',
32
- borough: 'manhattan'
33
- }).should have_been_made
33
+ it "should return the place info" do
34
+ data = @client.place(name: 'empire state building', borough: 'manhattan')
35
+ expect(data.keys).to eq ["place"]
36
+ end
34
37
  end
35
38
 
36
- it "should return the place info" do
37
- data = @client.place('empire state building', 'manhattan')
38
- data.keys.should be == ["place"]
39
+ context 'given a zip' do
40
+ before do
41
+ stub_get("place.#{format}").
42
+ with(
43
+ query: {
44
+ name: 'empire state building',
45
+ zip: '10118'
46
+ }).
47
+ to_return(body: fixture("place.#{format}"), headers: {content_type: "application/#{format}; charset=utf-8"})
48
+ end
49
+
50
+ it "should get the correct resource" do
51
+ @client.place(name: 'empire state building', zip: '10118')
52
+ expect(a_get("place.#{format}").
53
+ with(query: {
54
+ name: 'empire state building',
55
+ zip: '10118'
56
+ })).to have_been_made
57
+ end
58
+
59
+ it "should return the place info" do
60
+ data = @client.place(name: 'empire state building', zip: '10118')
61
+ expect(data.keys).to eq ["place"]
62
+ end
39
63
  end
40
64
  end
41
65
  end
@@ -5,7 +5,7 @@ describe NYCGeoClient::Client do
5
5
  client = NYCGeoClient::Client.new
6
6
  endpoint = URI.parse(client.endpoint)
7
7
  connection = client.send(:connection).build_url(nil).to_s
8
- (connection + '/').should == endpoint.to_s
8
+ expect(connection).to eq endpoint.to_s
9
9
  end
10
10
 
11
11
  end
@@ -19,76 +19,86 @@ describe NYCGeoClient do
19
19
  end
20
20
 
21
21
  it "should get the correct resource" do
22
- NYCGeoClient.address('13', 'crosby', 'manhattan')
23
- a_get("address.json").
22
+ NYCGeoClient.address(house_number: '13', street: 'crosby', borough: 'manhattan')
23
+ expect(a_get("address.json").
24
24
  with(query: {
25
25
  houseNumber: '13',
26
26
  street: 'crosby',
27
27
  borough: 'manhattan'
28
- }).should have_been_made
28
+ })).to have_been_made
29
29
  end
30
30
 
31
31
  it "should return the same results as a client" do
32
- NYCGeoClient.address('13', 'crosby', 'manhattan').should == NYCGeoClient::Client.new.address('13', 'crosby', 'manhattan')
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
36
46
 
37
47
  describe ".client" do
38
48
  it "should be a NYCGeoClient::Client" do
39
- NYCGeoClient.client.should be_a NYCGeoClient::Client
49
+ expect(NYCGeoClient.client).to be_a NYCGeoClient::Client
40
50
  end
41
51
  end
42
52
 
43
53
  describe ".adapter" do
44
54
  it "should return the default adapter" do
45
- NYCGeoClient.adapter.should == NYCGeoClient::Configuration::DEFAULT_ADAPTER
55
+ expect(NYCGeoClient.adapter).to eq NYCGeoClient::Configuration::DEFAULT_ADAPTER
46
56
  end
47
57
  end
48
58
 
49
59
  describe ".adapter=" do
50
60
  it "should set the adapter" do
51
61
  NYCGeoClient.adapter = :typhoeus
52
- NYCGeoClient.adapter.should == :typhoeus
62
+ expect(NYCGeoClient.adapter).to eq :typhoeus
53
63
  end
54
64
  end
55
65
 
56
66
  describe ".endpoint" do
57
67
  it "should return the default endpoint" do
58
- NYCGeoClient.endpoint.should == NYCGeoClient::Configuration::DEFAULT_ENDPOINT
68
+ expect(NYCGeoClient.endpoint).to eq NYCGeoClient::Configuration::DEFAULT_ENDPOINT
59
69
  end
60
70
  end
61
71
 
62
72
  describe ".endpoint=" do
63
73
  it "should set the endpoint" do
64
74
  NYCGeoClient.endpoint = 'http://tumblr.com'
65
- NYCGeoClient.endpoint.should == 'http://tumblr.com'
75
+ expect(NYCGeoClient.endpoint).to eq 'http://tumblr.com'
66
76
  end
67
77
  end
68
78
 
69
79
  describe ".format" do
70
80
  it "should return the default format" do
71
- NYCGeoClient.format.should == NYCGeoClient::Configuration::DEFAULT_FORMAT
81
+ expect(NYCGeoClient.format).to eq NYCGeoClient::Configuration::DEFAULT_FORMAT
72
82
  end
73
83
  end
74
84
 
75
85
  describe ".format=" do
76
86
  it "should set the format" do
77
87
  NYCGeoClient.format = 'xml'
78
- NYCGeoClient.format.should == 'xml'
88
+ expect(NYCGeoClient.format).to eq 'xml'
79
89
  end
80
90
  end
81
91
 
82
92
  describe ".user_agent" do
83
93
  it "should return the default user agent" do
84
- NYCGeoClient.user_agent.should == NYCGeoClient::Configuration::DEFAULT_USER_AGENT
94
+ expect(NYCGeoClient.user_agent).to eq NYCGeoClient::Configuration::DEFAULT_USER_AGENT
85
95
  end
86
96
  end
87
97
 
88
98
  describe ".user_agent=" do
89
99
  it "should set the user_agent" do
90
100
  NYCGeoClient.user_agent = 'Custom User Agent'
91
- NYCGeoClient.user_agent.should == 'Custom User Agent'
101
+ expect(NYCGeoClient.user_agent).to eq 'Custom User Agent'
92
102
  end
93
103
  end
94
104
 
@@ -99,10 +109,9 @@ describe NYCGeoClient do
99
109
  it "should set the #{key}" do
100
110
  NYCGeoClient.configure do |config|
101
111
  config.send("#{key}=", key)
102
- NYCGeoClient.send(key).should == key
112
+ expect(NYCGeoClient.send(key)).to eq key
103
113
  end
104
114
  end
105
115
  end
106
116
  end
107
-
108
- end
117
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,9 +4,6 @@ require 'rspec'
4
4
  require 'webmock/rspec'
5
5
 
6
6
  RSpec.configure do |config|
7
- config.treat_symbols_as_metadata_keys_with_true_values = true
8
- config.run_all_when_everything_filtered = true
9
- config.filter_run :focus
10
7
  config.include WebMock::API
11
8
  end
12
9
 
metadata CHANGED
@@ -1,155 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyc_geo_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 2.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: 2014-02-26 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.14.1
33
+ version: 3.10.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.14.1
40
+ version: 3.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.17.1
47
+ version: 3.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.17.1
54
+ version: 3.14.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.8.7.3
61
+ version: 0.9.26
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.7.3
69
- - !ruby/object:Gem::Dependency
70
- name: bluecloth
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: 2.2.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: 2.2.0
68
+ version: 0.9.26
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: faraday
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ~>
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 0.8.8
75
+ version: 1.7.2
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ~>
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 0.8.8
82
+ version: 1.7.2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: faraday_middleware
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ~>
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: 0.9.0
89
+ version: 1.1.0
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ~>
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: 0.9.0
96
+ version: 1.1.0
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: multi_json
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 1.8.4
103
+ version: 1.15.0
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - ~>
108
+ - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 1.8.4
110
+ version: 1.15.0
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: multi_xml
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - ~>
115
+ - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: 0.5.5
117
+ version: 0.6.0
132
118
  type: :runtime
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - ~>
122
+ - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: 0.5.5
124
+ version: 0.6.0
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: hashie
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
- - - ~>
129
+ - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: 2.0.5
131
+ version: 4.1.0
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
- - - ~>
136
+ - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: 2.0.5
138
+ version: 4.1.0
153
139
  description: A ruby wrapper for NYCGeoClient API
154
140
  email:
155
141
  - edgargonzalez@gmail.com
@@ -157,8 +143,8 @@ executables: []
157
143
  extensions: []
158
144
  extra_rdoc_files: []
159
145
  files:
160
- - .gitignore
161
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".travis.yml"
162
148
  - Gemfile
163
149
  - LICENSE
164
150
  - README.md
@@ -212,17 +198,16 @@ require_paths:
212
198
  - lib
213
199
  required_ruby_version: !ruby/object:Gem::Requirement
214
200
  requirements:
215
- - - '>='
201
+ - - ">="
216
202
  - !ruby/object:Gem::Version
217
203
  version: '0'
218
204
  required_rubygems_version: !ruby/object:Gem::Requirement
219
205
  requirements:
220
- - - '>='
206
+ - - ">="
221
207
  - !ruby/object:Gem::Version
222
208
  version: '0'
223
209
  requirements: []
224
- rubyforge_project:
225
- rubygems_version: 2.2.2
210
+ rubygems_version: 3.1.2
226
211
  signing_key:
227
212
  specification_version: 4
228
213
  summary: A ruby wrapper for NYCGeoClient API
@@ -251,4 +236,3 @@ test_files:
251
236
  - spec/nyc_geo_client/client_spec.rb
252
237
  - spec/nyc_geo_client_spec.rb
253
238
  - spec/spec_helper.rb
254
- has_rdoc: