us_street 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/lib/us_street.rb +9 -2
- data/lib/us_street/version.rb +1 -1
- data/spec/us_street_spec.rb +13 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: badae80566f49f683a9396d11b5a42cb4351e523
|
4
|
+
data.tar.gz: b546d4c1b389a63c98b4eab66cc6487ac3360028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45c67df7ff76402003ce3e50fc258b095c1c26f368e628ab506aa3605bc4d3dcd55d650abefb69382a837f6d6622b2d220e7236197fb37041351da62846ab248
|
7
|
+
data.tar.gz: 75e2d09083dc7304329314217b6276f81edb6f423a9340d7ac6c263ed0ae9b19e5c66e983d40687f15eb5161186c34d4bc5c064ae5f231fc325b8fa0f72653bb
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/lib/us_street.rb
CHANGED
@@ -36,7 +36,14 @@ class UsStreet
|
|
36
36
|
def self.components; COMPONENTS; end
|
37
37
|
|
38
38
|
def self.clean(str)
|
39
|
-
str.to_s
|
39
|
+
str.to_s
|
40
|
+
.strip # 'cuz real data sux
|
41
|
+
.gsub(/[\.,:;]/, '') # remove non-meaningful characters
|
42
|
+
.gsub(/[-]+$/, '') # remove non-meaningful characters on the end
|
43
|
+
.gsub(/\(.*?\)/, '') # remove anything in parentheses
|
44
|
+
.gsub(/.#[a-zA-Z0-9]+$/, '') # remove unit numbers on the end
|
45
|
+
.gsub(/\s+/, ' ') # collapse multiple spaces to one
|
46
|
+
.strip.downcase.presence
|
40
47
|
end
|
41
48
|
|
42
49
|
def self.clean_hash(hash)
|
@@ -95,7 +102,7 @@ class UsStreet
|
|
95
102
|
|
96
103
|
# strip suffixes starting at the end and working backwards
|
97
104
|
# Check for a postdirectional (directional suffix)
|
98
|
-
eidx -= 1 if eidx - sidx > 0 and dir_suffix
|
105
|
+
eidx -= 1 if eidx - sidx > 0 and dir_suffix = direction_mapping(parts[eidx])
|
99
106
|
|
100
107
|
# Check for a street suffix. If there's already a street suffix override,
|
101
108
|
# don't strip from string unless it's the same suffix.
|
data/lib/us_street/version.rb
CHANGED
data/spec/us_street_spec.rb
CHANGED
@@ -39,6 +39,11 @@ describe UsStreet do
|
|
39
39
|
expect(us_street.full_street).to eq("123 N Main Southy")
|
40
40
|
end
|
41
41
|
|
42
|
+
it "strips off unrequired characters from the end" do
|
43
|
+
us_street = UsStreet.from_attrs(4109, nil, "N BOULDER CANYON --", nil, nil)
|
44
|
+
expect(us_street.full_street).to eq("4109 N Boulder Cyn")
|
45
|
+
end
|
46
|
+
|
42
47
|
it "strips off spaces" do
|
43
48
|
us_street = UsStreet.from_attrs(" 123", nil, "N. main, -southy ", nil, nil)
|
44
49
|
expect(us_street.full_street).to eq("123 N Main Southy")
|
@@ -131,6 +136,14 @@ describe UsStreet do
|
|
131
136
|
expect(us_street.full_street).to eq("123 N Main Southy")
|
132
137
|
end
|
133
138
|
|
139
|
+
it "strips off unrequired characters from the end" do
|
140
|
+
us_street = UsStreet.parse("4109 N BOULDER CANYON --")
|
141
|
+
expect(us_street.full_street).to eq("4109 N Boulder Cyn")
|
142
|
+
|
143
|
+
us_street = UsStreet.parse("4109 N BOULDER CANYON -- ")
|
144
|
+
expect(us_street.full_street).to eq("4109 N Boulder Cyn")
|
145
|
+
end
|
146
|
+
|
134
147
|
it "doesn't strip directions in street name" do
|
135
148
|
us_street = UsStreet.parse("2644 E North Ln")
|
136
149
|
expect(us_street.full_street).to eq("2644 E North Ln")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: us_street
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.5.1
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Normalizes Us Streets
|