Skip to content

Commit

Permalink
Fix the punctuation stripping.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwern committed May 7, 2015
1 parent 3208f27 commit 2c7a451
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,7 @@
.bundle
Gemfile.lock
.gem
*.bak
*~
*.old
*.tar.gz
5 changes: 3 additions & 2 deletions lib/street_address.rb
Expand Up @@ -877,9 +877,10 @@ def parse_intersection(intersection, args)
end

private def to_address(input, args)
# strip off some punctuation
# strip off some punctuation and whitespace
input.values.each { |string|
string.gsub!(/^\s+|\s+$|[^\w\s\-\#\&]/)
string.strip!
string.gsub!(/[^\w\s\-\#\&]/, '')
}

if( input['street'] && !input['street_type'] )
Expand Down
16 changes: 8 additions & 8 deletions test/test_street_address.rb
Expand Up @@ -198,14 +198,14 @@ class StreetAddressUsTest < MiniTest::Test
:city => 'Philadelphia',
:street_type => 'St',
},
# "100 S.E. Washington Ave, Minneapolis, MN" => {
# :number => '100',
# :street => 'Washington',
# :state => 'MN',
# :city => 'Minneapolis',
# :street_type => 'Ave',
# :prefix => 'SE'
# },
"100 S.E. Washington Ave, Minneapolis, MN" => {
:number => '100',
:street => 'Washington',
:state => 'MN',
:city => 'Minneapolis',
:street_type => 'Ave',
:prefix => 'SE'
},
"3813 1/2 Some Road, Los Angeles, CA" => {
:number => '3813',
:street => 'Some',
Expand Down

0 comments on commit 2c7a451

Please sign in to comment.