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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ef48a37d102c911b24152c2f77485b964c6e874
4
- data.tar.gz: 5cfa71014710d2f69cb9f39e737e45e88011bd18
3
+ metadata.gz: badae80566f49f683a9396d11b5a42cb4351e523
4
+ data.tar.gz: b546d4c1b389a63c98b4eab66cc6487ac3360028
5
5
  SHA512:
6
- metadata.gz: a6afeaec5a91f008c6789921b488f35204db9177dadeb8e42c6e3718ce14572f30c57303bdb3f76487e8f1a337372af58fe8ad0679e45937150eee1f2d991854
7
- data.tar.gz: 5b3d4e54f5c146fba3d7cbe99eb67c74fe2f0b72bc53f4f97635b1198276cdddd62db6410f3db14fca86ed13e56cd4058dc3827123e25e104d55a1c6a5d289a6
6
+ metadata.gz: 45c67df7ff76402003ce3e50fc258b095c1c26f368e628ab506aa3605bc4d3dcd55d650abefb69382a837f6d6622b2d220e7236197fb37041351da62846ab248
7
+ data.tar.gz: 75e2d09083dc7304329314217b6276f81edb6f423a9340d7ac6c263ed0ae9b19e5c66e983d40687f15eb5161186c34d4bc5c064ae5f231fc325b8fa0f72653bb
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /vendor/bundle/
10
11
  *.bundle
11
12
  *.so
12
13
  *.o
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -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.gsub(/([\.,:;]|\(.*?\))/, '').gsub(/.#[a-zA-Z0-9]+$/, '').gsub(/\s+/, ' ').strip.downcase.presence
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 = direction_mapping(parts[eidx])
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.
@@ -1,3 +1,3 @@
1
1
  class UsStreet
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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.3
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 00:00:00.000000000 Z
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.4.5.1
94
+ rubygems_version: 2.5.1
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: Normalizes Us Streets