dc_address_lookup 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dc_address_lookup.gemspec +0 -1
- data/lib/dc_address_lookup.rb +3 -2
- data/lib/dc_address_lookup/client.rb +2 -1
- data/lib/dc_address_lookup/location.rb +12 -7
- data/lib/dc_address_lookup/response.rb +3 -7
- data/lib/dc_address_lookup/version.rb +1 -1
- data/script/console +2 -3
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677528e5dacce954168dbedb9eefa326950ea723
|
4
|
+
data.tar.gz: 9a35c1825f44a12028922afcaa0ceee0ff913ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e611b0ac557929f2806d75323393294cd02b7576fb45b3b36745fb6e692939c00acbe37d09a1e736d41e86dfff04fcb5a2ffd9f65859b59cd11750fdb0ec5cf8
|
7
|
+
data.tar.gz: f33e20e9cc389b181c121075b0e13b9a4a56b0798d2323433bdb139d69088e89687f82dc6d99f29f3120e306d44ac35dc2130cb5a5f285f9767352daf2e987fe
|
data/dc_address_lookup.gemspec
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "rest-client", "~> 1.8"
|
22
22
|
spec.add_dependency "rest-client-components", "~> 1.4"
|
23
|
-
spec.add_dependency "nokogiri", "~> 1.6"
|
24
23
|
spec.add_dependency "rack-cache", "~> 1.5"
|
25
24
|
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.10"
|
data/lib/dc_address_lookup.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'nokogiri'
|
2
1
|
require 'rest-client'
|
3
2
|
require 'restclient/components'
|
4
3
|
require 'rack/cache'
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
require "dc_address_lookup/version"
|
7
7
|
require "dc_address_lookup/client"
|
@@ -9,7 +9,8 @@ require "dc_address_lookup/response"
|
|
9
9
|
require "dc_address_lookup/location"
|
10
10
|
|
11
11
|
module DcAddressLookup
|
12
|
-
|
12
|
+
DOMAIN = "http://citizenatlas.dc.gov"
|
13
|
+
ENDPOINT = "#{DOMAIN}/newwebservices/locationverifier.asmx/findLocation2"
|
13
14
|
|
14
15
|
def self.lookup(address)
|
15
16
|
Client.new.lookup(address)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module DcAddressLookup
|
2
2
|
class Client
|
3
3
|
def lookup(query)
|
4
|
-
|
4
|
+
params = { f: "json", str: query }
|
5
|
+
response = RestClient.get DcAddressLookup::ENDPOINT, { params: params }
|
5
6
|
location = Response.new(response).location
|
6
7
|
location if location.valid?
|
7
8
|
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
module DcAddressLookup
|
2
2
|
class Location
|
3
|
-
def self.from_table(
|
3
|
+
def self.from_table(table)
|
4
4
|
location = self.new
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
value
|
10
|
-
|
11
|
-
|
6
|
+
table.each do |key,value|
|
7
|
+
key = key.downcase
|
8
|
+
|
9
|
+
if value.class == String
|
10
|
+
value = value.gsub(/\A#{key.split("_").first}\b/i, "").squeeze("\s").strip
|
11
|
+
value = value.to_i if value =~ /\A[1-9][0-9]*\z/
|
12
|
+
value = value.to_f if value =~ /\A[0-9]+\.[0-9]+\z/
|
13
|
+
elsif value.class == Float
|
14
|
+
value = value.to_i if value.to_s =~ /\A[0-9]+\.0\z/
|
15
|
+
end
|
16
|
+
|
12
17
|
location.data[key] = value
|
13
18
|
end
|
14
19
|
|
@@ -13,16 +13,12 @@ module DcAddressLookup
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
doc = Nokogiri::XML(body) { |config| config.strict.nonet }
|
19
|
-
doc.remove_namespaces!
|
20
|
-
doc
|
21
|
-
end
|
16
|
+
def parsed
|
17
|
+
@parsed ||= JSON.parse(body)
|
22
18
|
end
|
23
19
|
|
24
20
|
def table
|
25
|
-
|
21
|
+
parsed["returnDataset"]["Table1"].first
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
data/script/console
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dc_address_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.4'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nokogiri
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.6'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.6'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rack-cache
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|