StreetAddress 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3843c6d5bd24be978fa2cca64f03817180094ed4
4
+ data.tar.gz: 5bd92f6df1dd737c2ba33bd39e46c3fddb7bc92b
5
+ SHA512:
6
+ metadata.gz: 1aa3a268b475a9f5a124b32ba3d5620329db5e20d7ad2c25acdceca63af2a0458dc0bbb30645b689b09692ab695c9bcd1599c6bdb8c9988d75302261f8d80b8e
7
+ data.tar.gz: f525201005dd169ebfffe3d036e00ec693f4837c894eb3e3a3c7d063f210c05728a25ff9cbfe7ae419617cd8d564f1a71baa01067c3cbea9292581aeee0d1bfc
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ .swp
3
+ *.log
4
+ .ruby-version
5
+ .bundle
6
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ end
@@ -0,0 +1,58 @@
1
+ #DESCRIPTION
2
+
3
+ Parses one line street addresses and returns a normalized address object.
4
+
5
+ This is a near direct port of the of the perl module
6
+ Geo::StreetAddress::US originally written by Schuyler D. Erle.
7
+ For more information see
8
+ http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/
9
+
10
+ Since the original port in 2007 the two code bases have drifted somewhat. Any help porting updates would be greatly appreciated.
11
+
12
+ ## Installation
13
+
14
+ gem install StreetAddress
15
+
16
+ then in your code
17
+
18
+ require 'street_address'
19
+
20
+ or from Gemfile
21
+
22
+ gem 'StreetAddress', :require => "street_address"
23
+
24
+ ## Basic Usage
25
+
26
+ require 'street_address'
27
+ address = StreetAddress::US.parse("1600 Pennsylvania Ave, Washington, DC, 20500")
28
+ address.street # Pennsylvania
29
+ address.number # 1600
30
+ address.postal_code # 20500
31
+ address.city # Washington
32
+ address.state # DC
33
+ address.state_name # District of columbia
34
+ address.street_type # Ave
35
+ address.intersection? # false
36
+ address.to_s # "1600 Pennsylvania Ave, Washington, DC 20500"
37
+ address.to_s(:line1) # 1600 Pennsylvania Ave
38
+ StreetAddress::US.parse("1600 Pennsylvania Ave") # nil not a full address
39
+
40
+ ## Informal/Loose Parsing
41
+
42
+ address = StreetAddress::US.parse("1600 Pennsylvania Avenue", :informal => true)
43
+ address.number # 1600
44
+ address.street # Pennsylvania
45
+ address.street_type # Ave
46
+ address.to_s # 1600 Pennsylvania Ave
47
+
48
+ ## Zip+4
49
+
50
+ address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 22303-1864")
51
+ address.postal_code_ext # 1846
52
+ address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 223031864")
53
+ address.postal_code_ext # 1846
54
+
55
+ ## License
56
+ The [MIT Licencse](http://opensource.org/licenses/MIT)
57
+
58
+ Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2014,2016 Derrek Long
@@ -22,7 +22,7 @@
22
22
  Hollywood & Vine, Los Angeles, CA, 90028
23
23
  Hollywood Blvd and Vine St, Los Angeles, CA, 90028
24
24
  Mission Street at Valencia Street, San Francisco, CA, 90028
25
-
25
+
26
26
  ==== License
27
27
 
28
28
  Copyright (c) 2007 Riderway (Derrek Long, Nicholas Schlueter)
@@ -47,24 +47,24 @@
47
47
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48
48
 
49
49
  ==== Notes
50
- If parts of the address are omitted from the original string
50
+ If parts of the address are omitted from the original string
51
51
  the accessor will be nil in StreetAddress::US::Address.
52
-
52
+
53
53
  Example:
54
54
  address = StreetAddress::US.parse("1600 Pennsylvania Ave, washington, dc")
55
55
  assert address.postal_code.nil?
56
-
56
+
57
57
  ==== Acknowledgements
58
-
58
+
59
59
  This gem is a near direct port of the perl module Geo::StreetAddress::US
60
60
  originally written by Schuyler D. Erle. For more information see
61
61
  http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/
62
-
62
+
63
63
  =end
64
64
 
65
65
  module StreetAddress
66
66
  class US
67
- VERSION = '1.0.5'
67
+ VERSION = '1.0.6'
68
68
  DIRECTIONAL = {
69
69
  "north" => "N",
70
70
  "northeast" => "NE",
@@ -165,6 +165,7 @@ module StreetAddress
165
165
  "crssng" => "xing",
166
166
  "crt" => "ct",
167
167
  "curve" => "curv",
168
+ "cur" => "curv",
168
169
  "dale" => "dl",
169
170
  "dam" => "dm",
170
171
  "div" => "dv",
@@ -441,9 +442,9 @@ module StreetAddress
441
442
  "wells" => "wls",
442
443
  "wy" => "way"
443
444
  }
444
-
445
+
445
446
  STREET_TYPES_LIST = {}
446
- STREET_TYPES.to_a.each do |item|
447
+ STREET_TYPES.to_a.each do |item|
447
448
  STREET_TYPES_LIST[item[0]] = true
448
449
  STREET_TYPES_LIST[item[1]] = true
449
450
  end
@@ -511,7 +512,7 @@ module StreetAddress
511
512
  }
512
513
 
513
514
  STATE_NAMES = STATE_CODES.invert
514
-
515
+
515
516
  STATE_FIPS = {
516
517
  "01" => "AL",
517
518
  "02" => "AK",
@@ -569,7 +570,7 @@ module StreetAddress
569
570
  }
570
571
 
571
572
  FIPS_STATES = STATE_FIPS.invert
572
-
573
+
573
574
  class << self
574
575
  attr_accessor(
575
576
  :street_type_regexp,
@@ -587,7 +588,7 @@ module StreetAddress
587
588
  :informal_address_regexp
588
589
  )
589
590
  end
590
-
591
+
591
592
  self.street_type_regexp = STREET_TYPES_LIST.keys.join("|")
592
593
  self.number_regexp = '\d+-?\d*'
593
594
  self.fraction_regexp = '\d+\/\d+'
@@ -597,19 +598,19 @@ module StreetAddress
597
598
  ([^\d,]+?)\W+
598
599
  (' + state_regexp + ')
599
600
  )'
600
-
601
- self.direct_regexp = DIRECTIONAL.keys.join("|") +
602
- "|" +
603
- DIRECTIONAL.values.sort{ |a,b|
604
- b.length <=> a.length
605
- }.map{ |x|
601
+
602
+ self.direct_regexp = DIRECTIONAL.keys.join("|") +
603
+ "|" +
604
+ DIRECTIONAL.values.sort{ |a,b|
605
+ b.length <=> a.length
606
+ }.map{ |x|
606
607
  f = x.gsub(/(\w)/, '\1.')
607
- [Regexp::quote(f), Regexp::quote(x)]
608
+ [Regexp::quote(f), Regexp::quote(x)]
608
609
  }.join("|")
609
610
  self.zip_regexp = '(\d{5})(?:-?(\d{4})?)'
610
611
  self.corner_regexp = '(?:\band\b|\bat\b|&|\@)'
611
- self.unit_regexp = '(?:(su?i?te|p\W*[om]\W*b(?:ox)?|dept|apt|apartment|ro*m|fl|unit|box)\W+|\#\W*)([\w-]+)'
612
- self.street_regexp =
612
+ self.unit_regexp = '(?:(su?i?te|p\W*[om]\W*b(?:ox)?|dept|apt|apartment|ro*m|fl|unit|box)\W+|(\#)\W*)([\w-]+)'
613
+ self.street_regexp =
613
614
  '(?:
614
615
  (?:(' + direct_regexp + ')\W+
615
616
  (' + street_type_regexp + ')\b)
@@ -628,24 +629,25 @@ module StreetAddress
628
629
  (?:[^\w,]+(' + direct_regexp + ')\b)?
629
630
  )
630
631
  )'
631
- self.place_regexp =
632
+ self.place_regexp =
632
633
  '(?:' + city_and_state_regexp + '\W*)?
633
634
  (?:' + zip_regexp + ')?'
634
-
635
+
635
636
  self.address_regexp =
636
- '\A\W*
637
+ '\A[^\w\#]*
637
638
  (' + number_regexp + ')\W*
638
639
  (?:' + fraction_regexp + '\W*)?' +
639
640
  street_regexp + '\W+
640
641
  (?:' + unit_regexp + '\W+)?' +
641
642
  place_regexp +
642
643
  '\W*\Z'
643
-
644
+
644
645
  self.informal_address_regexp =
645
646
  '\A\s*
647
+ (?:' + unit_regexp + '(?:\W+|\Z))?
646
648
  (' + number_regexp + ')\W*
647
649
  (?:' + fraction_regexp + '\W*)?' +
648
- street_regexp + '(?:\W+|\Z)
650
+ street_regexp + '(?:[^\#\w]+|\Z)
649
651
  (?:' + unit_regexp + '(?:\W+|\Z))?' +
650
652
  '(?:' + place_regexp + ')?'
651
653
 
@@ -655,14 +657,14 @@ module StreetAddress
655
657
  StreetAddress::US::Address or nil if the location cannot be parsed
656
658
 
657
659
  pass the arguement, :informal => true, to make parsing more lenient
658
-
660
+
659
661
  ====example
660
662
  StreetAddress::US.parse('1600 Pennsylvania Ave Washington, DC 20006')
661
663
  or:
662
664
  StreetAddress::US.parse('Hollywood & Vine, Los Angeles, CA')
663
665
  or
664
666
  StreetAddress::US.parse("1600 Pennsylvania Ave", :informal => true)
665
-
667
+
666
668
  =end
667
669
  class << self
668
670
  def parse(location, args = {})
@@ -670,19 +672,19 @@ module StreetAddress
670
672
  parse_intersection(location)
671
673
  elsif args[:informal]
672
674
  parse_address(location) || parse_informal_address(location)
673
- else
675
+ else
674
676
  parse_address(location);
675
677
  end
676
678
  end
677
679
  =begin rdoc
678
-
679
- parses only an intersection and returnsan instance of
680
+
681
+ parses only an intersection and returns an instance of
680
682
  StreetAddress::US::Address or nil if the intersection cannot be parsed
681
-
683
+
682
684
  ====example
683
685
  address = StreetAddress::US.parse('Hollywood & Vine, Los Angeles, CA')
684
686
  assert address.intersection?
685
-
687
+
686
688
  =end
687
689
  def parse_intersection(inter)
688
690
  regex = Regexp.new(
@@ -691,9 +693,9 @@ module StreetAddress
691
693
  street_regexp + '\W+' +
692
694
  place_regexp + '\W*\Z', Regexp::IGNORECASE + Regexp::EXTENDED
693
695
  )
694
-
696
+
695
697
  return unless match = regex.match(inter)
696
-
698
+
697
699
  normalize_address(
698
700
  StreetAddress::US::Address.new(
699
701
  :street => match[4] || match[9],
@@ -710,10 +712,10 @@ module StreetAddress
710
712
  )
711
713
  )
712
714
  end
713
-
715
+
714
716
  =begin rdoc
715
717
 
716
- parses only an address and returnsan instance of
718
+ parses only an address and returns an instance of
717
719
  StreetAddress::US::Address or nil if the address cannot be parsed
718
720
 
719
721
  ====example
@@ -731,14 +733,14 @@ module StreetAddress
731
733
  :number => match[1],
732
734
  :street => match[5] || match[10] || match[2],
733
735
  :street_type => match[6] || match[3],
734
- :unit => match[14],
735
- :unit_prefix => match[13],
736
+ :unit => match[15],
737
+ :unit_prefix => match[13] || match[14],
736
738
  :suffix => match[7] || match[12],
737
739
  :prefix => match[4],
738
- :city => match[15],
739
- :state => match[16],
740
- :postal_code => match[17],
741
- :postal_code_ext => match[18]
740
+ :city => match[16],
741
+ :state => match[17],
742
+ :postal_code => match[18],
743
+ :postal_code_ext => match[19]
742
744
  )
743
745
  )
744
746
  end
@@ -750,21 +752,21 @@ module StreetAddress
750
752
 
751
753
  normalize_address(
752
754
  StreetAddress::US::Address.new(
753
- :number => match[1],
754
- :street => match[5] || match[10] || match[2],
755
- :street_type => match[6] || match[3],
756
- :unit => match[14],
757
- :unit_prefix => match[13],
758
- :suffix => match[7] || match[12],
759
- :prefix => match[4],
760
- :city => match[15],
761
- :state => match[16],
762
- :postal_code => match[17],
763
- :postal_code_ext => match[18]
755
+ :number => match[4],
756
+ :street => match[8] || match[13] || match[5],
757
+ :street_type => match[9] || match[6],
758
+ :unit => match[18] || match[3],
759
+ :unit_prefix => match[16] || match[17] || match[1] || match[2],
760
+ :suffix => match[10] || match[15],
761
+ :prefix => match[7],
762
+ :city => match[19],
763
+ :state => match[20],
764
+ :postal_code => match[21],
765
+ :postal_code_ext => match[22]
764
766
  )
765
767
  )
766
768
  end
767
-
769
+
768
770
  private
769
771
  def normalize_address(addr)
770
772
  addr.state = normalize_state(addr.state) unless addr.state.nil?
@@ -780,7 +782,7 @@ module StreetAddress
780
782
  addr.unit_prefix.capitalize! unless addr.unit_prefix.nil?
781
783
  return addr
782
784
  end
783
-
785
+
784
786
  def normalize_state(state)
785
787
  if state.length < 3
786
788
  state.upcase
@@ -788,13 +790,13 @@ module StreetAddress
788
790
  STATE_CODES[state.downcase]
789
791
  end
790
792
  end
791
-
793
+
792
794
  def normalize_street_type(s_type)
793
795
  s_type.downcase!
794
796
  s_type = STREET_TYPES[s_type] || s_type if STREET_TYPES_LIST[s_type]
795
797
  s_type.capitalize
796
798
  end
797
-
799
+
798
800
  def normalize_directional(dir)
799
801
  if dir.length < 3
800
802
  dir.upcase
@@ -805,34 +807,34 @@ module StreetAddress
805
807
  end
806
808
 
807
809
  =begin rdoc
808
-
809
- This is class returned by StreetAddress::US::parse, StreetAddress::US::parse_address
810
+
811
+ This is class returned by StreetAddress::US::parse, StreetAddress::US::parse_address
810
812
  and StreetAddress::US::parse_intersection. If an instance represents an intersection
811
813
  the attribute street2 will be populated.
812
-
814
+
813
815
  =end
814
816
  class Address
815
817
  attr_accessor(
816
- :number,
817
- :street,
818
- :street_type,
819
- :unit,
820
- :unit_prefix,
821
- :suffix,
822
- :prefix,
823
- :city,
824
- :state,
825
- :postal_code,
826
- :postal_code_ext,
827
- :street2,
828
- :street_type2,
829
- :suffix2,
818
+ :number,
819
+ :street,
820
+ :street_type,
821
+ :unit,
822
+ :unit_prefix,
823
+ :suffix,
824
+ :prefix,
825
+ :city,
826
+ :state,
827
+ :postal_code,
828
+ :postal_code_ext,
829
+ :street2,
830
+ :street_type2,
831
+ :suffix2,
830
832
  :prefix2
831
833
  )
832
834
 
833
835
  def initialize(args)
834
- args.keys.each do |attrib|
835
- self.send("#{attrib}=", args[attrib])
836
+ args.keys.each do |attrib|
837
+ self.send("#{attrib}=", args[attrib])
836
838
  end
837
839
  return
838
840
  end
@@ -850,19 +852,31 @@ module StreetAddress
850
852
  end
851
853
 
852
854
  def line1(s = "")
853
- return if intersection?
854
- s += number
855
- s += " " + prefix unless prefix.nil?
856
- s += " " + street unless street.nil?
857
- s += " " + street_type unless street_type.nil?
858
- if( !unit_prefix.nil? && !unit.nil? )
859
- s += " " + unit_prefix
860
- s += " " + unit
861
- elsif( unit_prefix.nil? && !unit.nil? )
862
- s += " #" + unit
855
+ if intersection?
856
+ s += prefix + " " unless prefix.nil?
857
+ s += street
858
+ s += " " + street_type unless street_type.nil?
859
+ s += " " + suffix unless suffix.nil?
860
+ s += " and"
861
+ s += " " + prefix2 unless prefix2.nil?
862
+ s += " " + street2
863
+ s += " " + street_type2 unless street_type2.nil?
864
+ s += " " + suffix2 unless suffix2.nil?
865
+ else
866
+ return if intersection?
867
+ s += number
868
+ s += " " + prefix unless prefix.nil?
869
+ s += " " + street unless street.nil?
870
+ s += " " + street_type unless street_type.nil?
871
+ if( !unit_prefix.nil? && !unit.nil? )
872
+ s += " " + unit_prefix
873
+ s += " " + unit
874
+ elsif( unit_prefix.nil? && !unit.nil? )
875
+ s += " #" + unit
876
+ end
877
+
878
+ return s
863
879
  end
864
- s += " " + suffix unless suffix.nil?
865
- return s
866
880
  end
867
881
 
868
882
  def to_s(format = :default)
@@ -873,7 +887,7 @@ module StreetAddress
873
887
  else
874
888
  if intersection?
875
889
  s += prefix + " " unless prefix.nil?
876
- s += street
890
+ s += street
877
891
  s += " " + street_type unless street_type.nil?
878
892
  s += " " + suffix unless suffix.nil?
879
893
  s += " and"
@@ -893,7 +907,7 @@ module StreetAddress
893
907
  end
894
908
  end
895
909
  return s
896
- end
910
+ end
897
911
  end
898
912
  end
899
913
  end
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift 'lib'
2
+
3
+ require 'street_address'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "StreetAddress"
7
+ s.version = StreetAddress::US::VERSION
8
+ s.date = Time.now.strftime('%Y-%m-%d')
9
+ s.summary = "Parse Addresses into substituent parts. This gem includes US only."
10
+ s.authors = ["Derrek Long"]
11
+ s.require_paths = ["lib"]
12
+ s.email = "derreklong@gmail.com"
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
15
+ s.homepage = "https://github.com/derrek/street-address"
16
+ s.description = <<desc
17
+ StreetAddress::US allows you to send any string to parse and if the string is a US address returns an object of the address broken into it's substituent parts.
18
+
19
+ A port of Geo::StreetAddress::US by Schuyler D. Erle and Tim Bunce.
20
+ desc
21
+ end
@@ -10,11 +10,13 @@ class StreetAddressUsTest < Test::Unit::TestCase
10
10
  @addr4 = "1005 Gravenstein Hwy N, Sebastopol CA 95472"
11
11
  @addr5 = "PO BOX 450, Chicago IL 60657"
12
12
  @addr6 = "2730 S Veitch St #207, Arlington, VA 22206"
13
+ @addr7 = "#42 233 S Wacker Dr 60606"
14
+ @addr8 = "Apt. 42, 233 S Wacker Dr 60606"
15
+ @addr9 = "2730 S Veitch St #207"
13
16
 
14
17
  @int1 = "Hollywood & Vine, Los Angeles, CA"
15
18
  @int2 = "Hollywood Blvd and Vine St, Los Angeles, CA"
16
19
  @int3 = "Mission Street at Valencia Street, San Francisco, CA"
17
-
18
20
  end
19
21
 
20
22
  def test_zip_plus_4_with_dash
@@ -96,8 +98,6 @@ class StreetAddressUsTest < Test::Unit::TestCase
96
98
  assert_equal addr.city, "Washington"
97
99
  assert_equal addr.street2, nil
98
100
 
99
-
100
-
101
101
  addr = StreetAddress::US.parse(@addr4)
102
102
  assert_equal addr.number, "1005"
103
103
  assert_equal addr.postal_code, "95472"
@@ -111,14 +111,41 @@ class StreetAddressUsTest < Test::Unit::TestCase
111
111
  assert_equal addr.street2, nil
112
112
  assert_equal addr.suffix, "N"
113
113
 
114
-
115
114
  addr = StreetAddress::US.parse(@addr5)
116
115
  assert_equal addr, nil
117
-
118
-
116
+
119
117
  addr = StreetAddress::US.parse(@addr6)
120
118
  assert_equal("207", addr.unit)
121
119
 
120
+ addr = StreetAddress::US.parse(@addr7, :informal => true)
121
+ assert_equal addr.number, "233"
122
+ assert_equal addr.postal_code, "60606"
123
+ assert_equal addr.prefix, "S"
124
+ assert_equal addr.state, nil
125
+ assert_equal addr.street, "Wacker"
126
+ assert_equal addr.street_type, "Dr"
127
+ assert_equal addr.unit, "42"
128
+ assert_equal addr.unit_prefix, "#"
129
+ assert_equal addr.city, nil
130
+ assert_equal addr.street2, nil
131
+ assert_equal addr.suffix, nil
132
+
133
+ addr = StreetAddress::US.parse(@addr8, :informal => true)
134
+ assert_equal addr.number, "233"
135
+ assert_equal addr.postal_code, "60606"
136
+ assert_equal addr.prefix, "S"
137
+ assert_equal addr.state, nil
138
+ assert_equal addr.street, "Wacker"
139
+ assert_equal addr.street_type, "Dr"
140
+ assert_equal addr.unit, "42"
141
+ assert_equal addr.unit_prefix, "Apt"
142
+ assert_equal addr.city, nil
143
+ assert_equal addr.street2, nil
144
+ assert_equal addr.suffix, nil
145
+
146
+ addr = StreetAddress::US.parse(@addr9, :informal => true)
147
+ assert_equal("207", addr.unit)
148
+
122
149
  addr = StreetAddress::US.parse(@int1)
123
150
  assert_equal addr.city, "Los Angeles"
124
151
  assert_equal addr.state, "CA"
@@ -138,7 +165,6 @@ class StreetAddressUsTest < Test::Unit::TestCase
138
165
  assert_equal addr.intersection?, true
139
166
  assert_equal addr.street_type, "Blvd"
140
167
  assert_equal addr.street_type2, "St"
141
- assert_equal addr.line1, nil
142
168
 
143
169
  addr = StreetAddress::US.parse(@int3)
144
170
  assert_equal addr.city, "San Francisco"
@@ -150,24 +176,26 @@ class StreetAddressUsTest < Test::Unit::TestCase
150
176
  assert_equal addr.intersection?, true
151
177
  assert_equal addr.street_type, "St"
152
178
  assert_equal addr.street_type2, "St"
153
-
154
- parseable = ["1600 Pennsylvania Ave Washington DC 20006",
155
- "1600 Pennsylvania Ave #400, Washington, DC, 20006",
156
- "1600 Pennsylvania Ave Washington, DC",
157
- "1600 Pennsylvania Ave #400 Washington DC",
158
- "1600 Pennsylvania Ave, 20006",
159
- "1600 Pennsylvania Ave #400, 20006",
160
- "1600 Pennsylvania Ave 20006",
161
- "1600 Pennsylvania Ave #400 20006",
162
- "Hollywood & Vine, Los Angeles, CA",
163
- "Hollywood Blvd and Vine St, Los Angeles, CA",
164
- "Mission Street at Valencia Street, San Francisco, CA",
165
- "Hollywood & Vine, Los Angeles, CA, 90028",
166
- "Hollywood Blvd and Vine St, Los Angeles, CA, 90028",
167
- "Mission Street at Valencia Street, San Francisco, CA, 90028"]
168
-
179
+
180
+ parseable = [
181
+ "1600 Pennsylvania Ave Washington DC 20006",
182
+ "1600 Pennsylvania Ave #400, Washington, DC, 20006",
183
+ "1600 Pennsylvania Ave Washington, DC",
184
+ "1600 Pennsylvania Ave #400 Washington DC",
185
+ "1600 Pennsylvania Ave, 20006",
186
+ "1600 Pennsylvania Ave #400, 20006",
187
+ "1600 Pennsylvania Ave 20006",
188
+ "1600 Pennsylvania Ave #400 20006",
189
+ "Hollywood & Vine, Los Angeles, CA",
190
+ "Hollywood Blvd and Vine St, Los Angeles, CA",
191
+ "Mission Street at Valencia Street, San Francisco, CA",
192
+ "Hollywood & Vine, Los Angeles, CA, 90028",
193
+ "Hollywood Blvd and Vine St, Los Angeles, CA, 90028",
194
+ "Mission Street at Valencia Street, San Francisco, CA, 90028"
195
+ ]
196
+
169
197
  parseable.each do |location|
170
- assert_not_nil(StreetAddress::US.parse(location), location + " was not parse able")
198
+ assert_not_nil(StreetAddress::US.parse(location), location + " was not parseable")
171
199
  end
172
200
 
173
201
  end
metadata CHANGED
@@ -1,70 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: StreetAddress
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 5
9
- version: 1.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.6
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Derrek Long
13
- - Nicholas Schleuter
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-06-16 00:00:00 -07:00
19
- default_executable:
11
+ date: 2014-12-21 00:00:00.000000000 Z
20
12
  dependencies: []
21
-
22
13
  description: |
23
14
  StreetAddress::US allows you to send any string to parse and if the string is a US address returns an object of the address broken into it's substituent parts.
24
-
25
- A port of Geo::StreetAddress::US by Schuyler D. Erle and Tim Bunce.
26
15
 
16
+ A port of Geo::StreetAddress::US by Schuyler D. Erle and Tim Bunce.
27
17
  email: derreklong@gmail.com
28
18
  executables: []
29
-
30
19
  extensions: []
31
-
32
20
  extra_rdoc_files: []
33
-
34
- files:
35
- - README.rdoc
21
+ files:
22
+ - ".gitignore"
23
+ - Gemfile
24
+ - README.md
36
25
  - Rakefile
37
- - LICENSE
38
26
  - lib/street_address.rb
39
- has_rdoc: true
27
+ - street_address.gemspec
28
+ - test/test_street_address.rb
40
29
  homepage: https://github.com/derrek/street-address
41
30
  licenses: []
42
-
31
+ metadata: {}
43
32
  post_install_message:
44
33
  rdoc_options: []
45
-
46
- require_paths:
34
+ require_paths:
47
35
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
49
- requirements:
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
50
38
  - - ">="
51
- - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
56
- requirements:
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
57
43
  - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
- version: "0"
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
62
46
  requirements: []
63
-
64
47
  rubyforge_project:
65
- rubygems_version: 1.3.6
48
+ rubygems_version: 2.2.2
66
49
  signing_key:
67
- specification_version: 3
50
+ specification_version: 4
68
51
  summary: Parse Addresses into substituent parts. This gem includes US only.
69
- test_files:
70
- - test/test_street_address.rb
52
+ test_files: []
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2011 Derrek Long
2
-
3
- The MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,45 +0,0 @@
1
- == DESCRIPTION:
2
-
3
- Parses one line street addresses and returns a normalized address object.
4
-
5
- This is a near direct port of the of the perl module
6
- Geo::StreetAddress::US originally written by Schuyler D. Erle.
7
- For more information see
8
- http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/
9
-
10
- == SYNOPSIS:
11
-
12
- Parse United States addresses.
13
-
14
- === Basic Usage:
15
- require 'street_address'
16
- address = StreetAddress::US.parse("1600 Pennsylvania Ave, Washington, DC, 20500")
17
- address.street # Pennsylvania
18
- address.number # 1600
19
- address.postal_code # 20500
20
- address.city # Washington
21
- address.state # DC
22
- address.state_name # District of columbia
23
- address.street_type # Ave
24
- address.intersection? # false
25
- address.to_s # "1600 Pennsylvania Ave, Washington, DC 20500"
26
- address.to_s(:line1) # 1600 Pennsylvania Ave
27
- StreetAddress::US.parse("1600 Pennsylvania Ave") # nil not a full address
28
-
29
- === Informal/Loose Parsing
30
- address = StreetAddress::US.parse("1600 Pennsylvania Avenue", :informal => true)
31
- address.number # 1600
32
- address.street # Pennsylvania
33
- address.street_type # Ave
34
- address.to_s # 1600 Pennsylvania Ave
35
-
36
- === Zip+4
37
- address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 22303-1864")
38
- address.postal_code_ext # 1846
39
-
40
- address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 223031864")
41
- address.postal_code_ext # 1846
42
-
43
- === Gemfile:
44
- To use from your Gemfile:
45
- gem 'StreetAddress', '1.0.3', :require => "street_address"