address-matcher 0.1.1 → 0.2.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/Gemfile.lock +20 -20
- data/VERSION +1 -1
- data/address_matcher.gemspec +3 -3
- data/lib/address_matcher/address_library.rb +8 -2
- data/spec/address_library_spec.rb +34 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f302ec9ed3f0501f73acc45e7f2940ca2c34f3
|
4
|
+
data.tar.gz: 0a6e261082cb6c0c6dfb5fbc6e2ce3bafcbfa62f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2661a44e8296c9dc2d985e4572594c224359b996ce52848388f7a8ddc5ffac6b5770bc9228b2e1940c839c064cd574a12e49174453caea1e1c26efe63f0065d
|
7
|
+
data.tar.gz: 2cce9e34c11d73fdfbd04ab8ed32ab79155d60b60e069babb38a822fca9a75c45780945d8f48c16d0901b4a1d02c04c32605eff37f2f08325ebad05a81fa0cf7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
address-matcher (0.
|
4
|
+
address-matcher (0.1.1)
|
5
5
|
geocoder (~> 1.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,32 +10,32 @@ GEM
|
|
10
10
|
coderay (1.1.0)
|
11
11
|
diff-lcs (1.2.5)
|
12
12
|
docile (1.1.5)
|
13
|
-
geocoder (1.2.
|
13
|
+
geocoder (1.2.9)
|
14
|
+
json (1.8.3)
|
14
15
|
method_source (0.8.2)
|
15
|
-
multi_json (1.11.0)
|
16
16
|
pry (0.10.1)
|
17
17
|
coderay (~> 1.1.0)
|
18
18
|
method_source (~> 0.8.1)
|
19
19
|
slop (~> 3.4)
|
20
20
|
rake (10.4.2)
|
21
|
-
rspec (3.
|
22
|
-
rspec-core (~> 3.
|
23
|
-
rspec-expectations (~> 3.
|
24
|
-
rspec-mocks (~> 3.
|
25
|
-
rspec-core (3.
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-expectations (3.
|
21
|
+
rspec (3.3.0)
|
22
|
+
rspec-core (~> 3.3.0)
|
23
|
+
rspec-expectations (~> 3.3.0)
|
24
|
+
rspec-mocks (~> 3.3.0)
|
25
|
+
rspec-core (3.3.1)
|
26
|
+
rspec-support (~> 3.3.0)
|
27
|
+
rspec-expectations (3.3.0)
|
28
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-mocks (3.
|
29
|
+
rspec-support (~> 3.3.0)
|
30
|
+
rspec-mocks (3.3.1)
|
31
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-support (3.
|
34
|
-
simplecov (0.
|
32
|
+
rspec-support (~> 3.3.0)
|
33
|
+
rspec-support (3.3.0)
|
34
|
+
simplecov (0.10.0)
|
35
35
|
docile (~> 1.1.0)
|
36
|
-
|
37
|
-
simplecov-html (~> 0.
|
38
|
-
simplecov-html (0.
|
36
|
+
json (~> 1.8)
|
37
|
+
simplecov-html (~> 0.10.0)
|
38
|
+
simplecov-html (0.10.0)
|
39
39
|
slop (3.6.0)
|
40
40
|
|
41
41
|
PLATFORMS
|
@@ -45,5 +45,5 @@ DEPENDENCIES
|
|
45
45
|
address-matcher!
|
46
46
|
pry (~> 0.10)
|
47
47
|
rake (~> 10.4)
|
48
|
-
rspec (~> 3.
|
49
|
-
simplecov (~> 0.
|
48
|
+
rspec (~> 3.3)
|
49
|
+
simplecov (~> 0.10)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/address_matcher.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'address-matcher'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.2.0'
|
4
4
|
s.date = '2015-04-07'
|
5
5
|
s.summary = "Matches addresses by geocoding"
|
6
6
|
s.description = "Uses geocoding to perform fuzzy match on address strings"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency('geocoder', '~> 1.2')
|
19
19
|
|
20
20
|
s.add_development_dependency('rake', '~> 10.4')
|
21
|
-
s.add_development_dependency('rspec', '~> 3.
|
22
|
-
s.add_development_dependency('simplecov', '~> 0.
|
21
|
+
s.add_development_dependency('rspec', '~> 3.3')
|
22
|
+
s.add_development_dependency('simplecov', '~> 0.10')
|
23
23
|
s.add_development_dependency('pry', '~> 0.10')
|
24
24
|
end
|
@@ -28,8 +28,14 @@ class AddressLibrary
|
|
28
28
|
def match(address_string)
|
29
29
|
coords = geocode(address_string)
|
30
30
|
if coords
|
31
|
-
|
32
|
-
|
31
|
+
address_for_coords(coords)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def address_for_coords(lat_long)
|
36
|
+
unless lat_long.to_a.empty?
|
37
|
+
group = store[latitude_index(lat_long)][longitude_index(lat_long)]
|
38
|
+
group.match(lat_long)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -142,5 +142,39 @@ describe AddressLibrary do
|
|
142
142
|
|
143
143
|
expect(match).to be_nil
|
144
144
|
end
|
145
|
+
|
146
|
+
describe '#address_for_coords' do
|
147
|
+
it 'returns the address that is nearest the given coordinates' do
|
148
|
+
lib = AddressLibrary.new.add_address(met_opera_short.address)
|
149
|
+
|
150
|
+
address = lib.address_for_coords(met_opera_long.coords)
|
151
|
+
|
152
|
+
expect(address).to eq met_opera_short.address
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'returns nil if there are no addresses near enough to match' do
|
156
|
+
lib = AddressLibrary.new.add_address(met_opera_short.address)
|
157
|
+
|
158
|
+
address = lib.address_for_coords(boco.coords)
|
159
|
+
|
160
|
+
expect(address).to be_nil
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'returns nil if the coords are nil' do
|
164
|
+
lib = AddressLibrary.new.add_address(met_opera_short.address)
|
165
|
+
|
166
|
+
address = lib.address_for_coords(nil)
|
167
|
+
|
168
|
+
expect(address).to be_nil
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'returns nil if the coords are empty' do
|
172
|
+
lib = AddressLibrary.new.add_address(met_opera_short.address)
|
173
|
+
|
174
|
+
address = lib.address_for_coords([])
|
175
|
+
|
176
|
+
expect(address).to be_nil
|
177
|
+
end
|
178
|
+
end
|
145
179
|
end
|
146
180
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: address-matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Terrett
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.3'
|
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: '3.
|
54
|
+
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.10'
|
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.
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|