Indirizzo 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{Indirizzo}
3
- s.version = "0.1.5"
3
+ s.version = "0.1.7"
4
4
 
5
5
  s.authors = [%q{Dave Worth}]
6
- s.date = %q{2012-01-11}
6
+ s.date = %q{2012-01-29}
7
7
  s.description = %q{Indirizzo is simply an extraction of the US Street Address parsing code from Geocoder::US}
8
8
  s.email = %q{dave@highgroove.com}
9
9
 
@@ -1,5 +1,4 @@
1
1
  require 'indirizzo/constants'
2
- require 'awesome_print'
3
2
 
4
3
  module Indirizzo
5
4
  # Defines the matching of parsed address tokens.
@@ -88,10 +87,10 @@ module Indirizzo
88
87
  # full_state = @state.strip # special case: New York
89
88
  @state = State[@state]
90
89
  end
91
- elsif !text[:country].nil?
92
- @state = text[:country]
93
90
  elsif !text[:state].nil?
94
91
  @state = text[:state]
92
+ elsif !text[:country].nil?
93
+ @state = text[:country]
95
94
  end
96
95
 
97
96
  @zip = text[:postal_code]
@@ -263,17 +262,15 @@ module Indirizzo
263
262
 
264
263
  def city_parts
265
264
  strings = []
266
- @city.map {|string|
265
+ @city.map do |string|
267
266
  tokens = string.split(" ")
268
267
  strings |= (0...tokens.length).to_a.reverse.map {|i|
269
268
  (i...tokens.length).map {|j| tokens[i..j].join(" ")}}.flatten
270
- }
269
+ end
271
270
  # Don't return strings that consist solely of abbreviations.
272
271
  # NOTE: Is this a micro-optimization that has edge cases that will break?
273
272
  # Answer: Yes, it breaks on "Prairie"
274
- good_strings = strings.reject {|s| Std_Abbr.key? s}
275
- strings = good_strings if !good_strings.empty?
276
- strings.uniq
273
+ strings.reject { |s| Std_Abbr.key?(s) }.uniq
277
274
  end
278
275
 
279
276
  def city= (strings)
@@ -42,17 +42,24 @@ class TestAddress < Test::Unit::TestCase
42
42
  assert addr_po.po_box?
43
43
  end
44
44
 
45
+ def test_intersection
46
+ addr_intersection = Address.new "Means St. at Optimism Way"
47
+ assert addr_intersection.intersection?
48
+ end
49
+
45
50
  def test_skip_parse
46
51
  addresses = [
47
52
  {:street => "1233 Main St", :city => "Springfield", :region => "VA", :postal_code => "12345", :final_number => "1233", :parsed_street => "main st"},
48
53
  {:street => "somewhere Ln", :city => "Somewhere", :region => "WI", :postal_code => "22222", :number => "402", :parsed_street => "somewhere ln", :final_number => "402"},
54
+ {:street => "somewhere Ln", :city => "Somewhere", :state => "WI", :postal_code => "22222", :number => "402", :parsed_street => "somewhere ln", :final_number => "402"},
49
55
  ]
50
56
  for preparsed_address in addresses
51
57
  address_for_geocode = Address.new preparsed_address
52
58
  assert_equal preparsed_address[:parsed_street],address_for_geocode.street[0]
53
59
  assert_equal preparsed_address[:final_number],address_for_geocode.number
54
60
  assert_equal preparsed_address[:city],address_for_geocode.city[0]
55
- assert_equal preparsed_address[:region],address_for_geocode.state
61
+ assert_equal preparsed_address[:region],address_for_geocode.state if preparsed_address[:region]
62
+ assert_equal preparsed_address[:state],address_for_geocode.state if preparsed_address[:state]
56
63
  assert_equal preparsed_address[:postal_code],address_for_geocode.zip
57
64
  end
58
65
  end
@@ -128,7 +135,8 @@ class TestAddress < Test::Unit::TestCase
128
135
  [ "19131", "", "", "19131" ],
129
136
  [ "19131-9999", "", "", "19131" ],
130
137
  ].each do |fixture|
131
- define_method "test_city_parse_#{fixture[0].gsub(/(?:\s+|[,])/,'_')}" do
138
+ fixture_name = fixture[0].gsub(/(?:\s+|[,])/,'_')
139
+ define_method "test_city_parse_#{fixture_name}" do
132
140
  check_city(fixture)
133
141
  end
134
142
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Indirizzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-11 00:00:00.000000000Z
12
+ date: 2012-01-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70348554395680 !ruby/object:Gem::Requirement
16
+ requirement: &70262923397040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70348554395680
24
+ version_requirements: *70262923397040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cover_me
27
- requirement: &70348554395240 !ruby/object:Gem::Requirement
27
+ requirement: &70262923396600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70348554395240
35
+ version_requirements: *70262923396600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: awesome_print
38
- requirement: &70348554394820 !ruby/object:Gem::Requirement
38
+ requirement: &70262923396180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70348554394820
46
+ version_requirements: *70262923396180
47
47
  description: Indirizzo is simply an extraction of the US Street Address parsing code
48
48
  from Geocoder::US
49
49
  email: dave@highgroove.com