phl-opa 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 302a66b3a6f0431602db8a3c835f641205173952
4
+ data.tar.gz: db7ee91c1eab40d715cc8fa224d26ce8a26c6eca
5
+ SHA512:
6
+ metadata.gz: d4241aad37b90711fbecc1360bcf3cacb02ed370c82aa9bdd139a7f50b675008b3eed6c3ba82dc34e1bdb16bd13c50a7c6ed6c33dfae2aa5b5daf9dfecc9ed67
7
+ data.tar.gz: 54a207d6ac96f3364a4c7f56060ff25ea05b12db45eb2db489395760ea7fd31b3993675056fe95495f37ba29e182bb795b8f366a134ce86e9518306b68c10c65
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'rake'
7
+ gem 'rake', '>=10.3'
8
8
  end
9
9
 
10
10
  group :development do
data/README.md CHANGED
@@ -20,13 +20,15 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ Require the module
24
+
25
+ require 'phl_opa'
26
+
23
27
  **#get_by_account**
24
28
 
25
29
  Returns the property details for the provided OPA account number. This method returns the most amount of data about a given property. If you have an address, but not an OPA account number. Use the `#search_by_address` method to find the OPA account number, then this method to get all the details about the property.
26
30
 
27
- require 'phl_opa'
28
- phl_opa = PHLopa::API.new
29
- phl_opa.get_by_account(883309000)
31
+ PHLopa.get_by_account(883309000)
30
32
 
31
33
  Response:
32
34
 
@@ -54,9 +56,7 @@ Response:
54
56
 
55
57
  Searches for properties that match the provided address. In the response, the `data.properties` key is always an array, even if there is only one result
56
58
 
57
- require 'phl_opa'
58
- phl_opa = PHLopa::API.new
59
- phl_opa.search_by_address('1234 Market St')
59
+ PHLopa.search_by_address('1234 Market St')
60
60
 
61
61
  Response
62
62
 
@@ -84,9 +84,7 @@ Response
84
84
 
85
85
  Searches for properties that are located on the provided block. In the response, the `data.properties` key is always an array, even if there is only one result.
86
86
 
87
- require 'phl_opa'
88
- phl_opa = PHLopa::API.new
89
- phl_opa.search_by_block('1234 Market St')
87
+ PHLopa.search_by_block('1234 Market St')
90
88
 
91
89
  Response
92
90
 
@@ -114,9 +112,7 @@ Response
114
112
 
115
113
  Searches for properties that are near the provided the intersection. In the response, the `data.properties` key is always an array, even if there is only one result.
116
114
 
117
- require 'phl_opa'
118
- phl_opa = PHLopa::API.new
119
- phl_opa.search_by_intersection('Market St', '12th')
115
+ PHLopa.search_by_intersection('Market St', '12th')
120
116
 
121
117
  Response
122
118
 
@@ -144,9 +140,7 @@ Response
144
140
 
145
141
  Searches for properties that are near the provide latitude/longitude coordinate, and within the provided radius. The default distance for `radius` is 200 feet, and is not required. In the response, the `data.properties` key is always an array, even if there is only one result.
146
142
 
147
- require 'phl_opa'
148
- phl_opa = PHLopa::API.new
149
- phl_opa.search_nearby(-75.16097, 39.95166, 400)
143
+ PHLopa.search_nearby(-75.16097, 39.95166, 400)
150
144
 
151
145
  Response
152
146
 
@@ -3,15 +3,11 @@ require "open-uri"
3
3
  require "net/http"
4
4
 
5
5
  module PHLopa
6
- class API
7
- attr_accessor :settings
8
-
9
- def initialize(options={})
10
- @settings = {
11
- :api_base => "http://api.phila.gov/opa/v1.0/",
12
- :default_query_string => "?format=json"
13
- }.merge(options)
14
- end
6
+
7
+ API_BASE = "http://api.phila.gov/opa/v1.0/"
8
+ DEFAULT_QUERY_STRING = "?format=json"
9
+
10
+ class << self
15
11
 
16
12
  def get_by_account(account=nil)
17
13
  raise ArgumentError("Account Number must be 9 digits long") unless account.length == 9
@@ -66,6 +62,8 @@ module PHLopa
66
62
  data
67
63
  end
68
64
 
65
+ private
66
+
69
67
  def parse_response(response)
70
68
  json = JSON.parse(response.body)
71
69
 
@@ -74,7 +72,7 @@ module PHLopa
74
72
 
75
73
  def invoke_api(path, parameter)
76
74
  encoded = URI::encode(parameter)
77
- url = URI.parse("#{@settings[:api_base]}#{path}#{encoded}#{@settings[:default_query_string]}")
75
+ url = URI.parse("#{API_BASE}#{path}#{encoded}#{DEFAULT_QUERY_STRING}")
78
76
 
79
77
  Net::HTTP.get_response(url)
80
78
  end
@@ -1,3 +1,3 @@
1
1
  module PHLopa
2
- VERSION = '0.0.5'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rake", "~> 10.3"
23
23
  end
@@ -2,114 +2,88 @@ require 'spec_helper'
2
2
 
3
3
  describe PHLopa do
4
4
 
5
- describe "#new" do
6
- before :each do
7
- @phl_opa = PHLopa::API.new
8
- end
9
- end
10
-
11
5
  describe "#get_by_account" do
12
- before :each do
13
- @phl_opa = PHLopa::API.new
14
- end
15
-
16
6
  it "returns the property details for the OPA account that is passed" do
17
- @phl_opa.get_by_account('883309000')['data']['property']['full_address'] = '1234 MARKET ST'
7
+ PHLopa.get_by_account('883309000')['data']['property']['full_address'] = '1234 MARKET ST'
18
8
  end
19
9
 
20
10
  it "raises an error if the account argument is not a string" do
21
- lambda { @phl_opa.get_by_account(123456780) }.should raise_error
22
- lambda { @phl_opa.get_by_account([123456780]) }.should raise_error
11
+ lambda { PHLopa.get_by_account(123456780) }.should raise_error
12
+ lambda { PHLopa.get_by_account([123456780]) }.should raise_error
23
13
  end
24
14
 
25
15
  it "raises an error if the length of the account argument is not exactly 9" do
26
- lambda { @phl_opa.get_by_account('12345678') }.should raise_error
27
- lambda { @phl_opa.get_by_account('12345678910') }.should raise_error
16
+ lambda { PHLopa.get_by_account('12345678') }.should raise_error
17
+ lambda { PHLopa.get_by_account('12345678910') }.should raise_error
28
18
  end
29
19
 
30
20
  it "raises an error if the account argument contains anything but numbers" do
31
- lambda { @phl_opa.get_by_account('123456780z') }.should raise_error
32
- lambda { @phl_opa.get_by_account('12345ddfdf6780') }.should raise_error
21
+ lambda { PHLopa.get_by_account('123456780z') }.should raise_error
22
+ lambda { PHLopa.get_by_account('12345ddfdf6780') }.should raise_error
33
23
  end
34
24
  end
35
25
 
36
26
  describe "#search_by_address" do
37
- before :each do
38
- @phl_opa = PHLopa::API.new
39
- end
40
-
41
27
  it "returns the property details for the adress that is passed" do
42
- @phl_opa.search_by_address('1234 Market St')['data']['properties'][0]['account_number'] = '883309000'
28
+ PHLopa.search_by_address('1234 Market St')['data']['properties'][0]['account_number'] = '883309000'
43
29
  end
44
30
 
45
31
  it "raises an error if the address argument is not a string" do
46
- lambda { @phl_opa.search_by_address(123456780) }.should raise_error
47
- lambda { @phl_opa.search_by_address(['1234 Market St']) }.should raise_error
32
+ lambda { PHLopa.search_by_address(123456780) }.should raise_error
33
+ lambda { PHLopa.search_by_address(['1234 Market St']) }.should raise_error
48
34
  end
49
35
  end
50
36
 
51
37
  describe "#search_by_block" do
52
- before :each do
53
- @phl_opa = PHLopa::API.new
54
- end
55
-
56
38
  it "returns the property details for all the properties on the searched block" do
57
- @phl_opa.search_by_block('1200 Market St')['total'] = 3
39
+ PHLopa.search_by_block('1200 Market St')['total'] = 3
58
40
  end
59
41
 
60
42
  it "raises an error if the address argument is not a string" do
61
- lambda { @phl_opa.search_by_block(123456780) }.should raise_error
62
- lambda { @phl_opa.search_by_block(['1234 Market St']) }.should raise_error
43
+ lambda { PHLopa.search_by_block(123456780) }.should raise_error
44
+ lambda { PHLopa.search_by_block(['1234 Market St']) }.should raise_error
63
45
  end
64
46
  end
65
47
 
66
48
  describe "#search_by_intersection" do
67
- before :each do
68
- @phl_opa = PHLopa::API.new
69
- end
70
-
71
49
  it "returns the property details for all the properties near the provided intersection" do
72
- @phl_opa.search_by_intersection('12th', 'Market')['total'] = 5
50
+ PHLopa.search_by_intersection('12th', 'Market')['total'] = 5
73
51
  end
74
52
 
75
53
  it "raises an error if the address argument is not a string" do
76
- lambda { @phl_opa.search_by_intersection(12, 'Market') }.should raise_error
77
- lambda { @phl_opa.search_by_intersection('Market', 12) }.should raise_error
54
+ lambda { PHLopa.search_by_intersection(12, 'Market') }.should raise_error
55
+ lambda { PHLopa.search_by_intersection('Market', 12) }.should raise_error
78
56
  end
79
57
 
80
58
  it "raises an error if either of the street arguments are nil" do
81
- lambda { @phl_opa.search_by_intersection('Market') }.should raise_error
82
- lambda { @phl_opa.search_by_intersection(nil, 'Market') }.should raise_error
59
+ lambda { PHLopa.search_by_intersection('Market') }.should raise_error
60
+ lambda { PHLopa.search_by_intersection(nil, 'Market') }.should raise_error
83
61
  end
84
62
  end
85
63
 
86
64
  describe "#search_nearby" do
87
- before :each do
88
- @phl_opa = PHLopa::API.new
89
- end
90
-
91
65
  it "returns the property details for all the properties near the provided point and within the provided radius" do
92
- @phl_opa.search_nearby(39.95166, -75.16097, 400)['total'] = 25
66
+ PHLopa.search_nearby(39.95166, -75.16097, 400)['total'] = 25
93
67
  end
94
68
 
95
69
  it "does not require that the user sets the radius argument" do
96
- @phl_opa.search_nearby(39.95166, -75.16097)['total'] = 4
70
+ PHLopa.search_nearby(39.95166, -75.16097)['total'] = 4
97
71
  end
98
72
 
99
73
  it "raises an error if the radius argument is not a positive number" do
100
- lambda { @phl_opa.search_nearby(39.95166, -75.16097, -100) }.should raise_error
101
- lambda { @phl_opa.search_nearby(39.95166, -75.16097, '1000') }.should raise_error
74
+ lambda { PHLopa.search_nearby(39.95166, -75.16097, -100) }.should raise_error
75
+ lambda { PHLopa.search_nearby(39.95166, -75.16097, '1000') }.should raise_error
102
76
  end
103
77
 
104
78
  it "raises an error if either the latitude or longitude arguments are nil" do
105
- lambda { @phl_opa.search_nearby(nil, -75.16097, 100) }.should raise_error
106
- lambda { @phl_opa.search_nearby(39.95166, nil, 100) }.should raise_error
107
- lambda { @phl_opa.search_nearby(nil, nil, 100) }.should raise_error
79
+ lambda { PHLopa.search_nearby(nil, -75.16097, 100) }.should raise_error
80
+ lambda { PHLopa.search_nearby(39.95166, nil, 100) }.should raise_error
81
+ lambda { PHLopa.search_nearby(nil, nil, 100) }.should raise_error
108
82
  end
109
83
 
110
84
  it "raises an error if either the latitude or longitude arguments are not numbers" do
111
- lambda { @phl_opa.search_nearby(39.95166, '-75.16097', 100) }.should raise_error
112
- lambda { @phl_opa.search_nearby('39.95166', -75.16097, 100) }.should raise_error
85
+ lambda { PHLopa.search_nearby(39.95166, '-75.16097', 100) }.should raise_error
86
+ lambda { PHLopa.search_nearby('39.95166', -75.16097, 100) }.should raise_error
113
87
  end
114
88
  end
115
89
 
metadata CHANGED
@@ -1,48 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phl-opa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Casey Thomas
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '10.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '10.3'
46
41
  description: A thin wrapper for the Philadelphia Office of Property Assessment API
47
42
  email:
48
43
  - cpthomas@gmail.com
@@ -50,8 +45,8 @@ executables: []
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - .gitignore
54
- - .travis.yml
48
+ - ".gitignore"
49
+ - ".travis.yml"
55
50
  - Gemfile
56
51
  - LICENSE.txt
57
52
  - README.md
@@ -65,27 +60,26 @@ files:
65
60
  homepage: https://www.github.com/caseypt/phl-opa
66
61
  licenses:
67
62
  - MIT
63
+ metadata: {}
68
64
  post_install_message:
69
65
  rdoc_options: []
70
66
  require_paths:
71
67
  - lib
72
68
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
69
  requirements:
75
- - - ! '>='
70
+ - - ">="
76
71
  - !ruby/object:Gem::Version
77
72
  version: '0'
78
73
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
74
  requirements:
81
- - - ! '>='
75
+ - - ">="
82
76
  - !ruby/object:Gem::Version
83
77
  version: '0'
84
78
  requirements: []
85
79
  rubyforge_project:
86
- rubygems_version: 1.8.23
80
+ rubygems_version: 2.2.0
87
81
  signing_key:
88
- specification_version: 3
82
+ specification_version: 4
89
83
  summary: Get information about properties in Philadelphia
90
84
  test_files:
91
85
  - spec/lib/phl_opa_spec.rb