StreetAddress 1.0.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -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
data/.gitignore ADDED
@@ -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
data/README.md ADDED
@@ -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.3'
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,39 +570,47 @@ 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,
576
577
  :number_regexp,
577
578
  :fraction_regexp,
578
579
  :state_regexp,
580
+ :city_and_state_regexp,
579
581
  :direct_regexp,
580
582
  :zip_regexp,
581
583
  :corner_regexp,
582
584
  :unit_regexp,
583
585
  :street_regexp,
584
586
  :place_regexp,
585
- :address_regexp
587
+ :address_regexp,
588
+ :informal_address_regexp
586
589
  )
587
590
  end
588
-
591
+
589
592
  self.street_type_regexp = STREET_TYPES_LIST.keys.join("|")
590
593
  self.number_regexp = '\d+-?\d*'
591
594
  self.fraction_regexp = '\d+\/\d+'
592
595
  self.state_regexp = STATE_CODES.to_a.join("|").gsub(/ /, "\\s")
593
- self.direct_regexp = DIRECTIONAL.keys.join("|") +
594
- "|" +
595
- DIRECTIONAL.values.sort{ |a,b|
596
- b.length <=> a.length
597
- }.map{ |x|
596
+ self.city_and_state_regexp = '
597
+ (?:
598
+ ([^\d,]+?)\W+
599
+ (' + state_regexp + ')
600
+ )'
601
+
602
+ self.direct_regexp = DIRECTIONAL.keys.join("|") +
603
+ "|" +
604
+ DIRECTIONAL.values.sort{ |a,b|
605
+ b.length <=> a.length
606
+ }.map{ |x|
598
607
  f = x.gsub(/(\w)/, '\1.')
599
- [Regexp::quote(f), Regexp::quote(x)]
608
+ [Regexp::quote(f), Regexp::quote(x)]
600
609
  }.join("|")
601
- self.zip_regexp = '(\d{5})(?:-(\d{4}))?'
610
+ self.zip_regexp = '(\d{5})(?:-?(\d{4})?)'
602
611
  self.corner_regexp = '(?:\band\b|\bat\b|&|\@)'
603
- self.unit_regexp = '(?:(su?i?te|p\W*[om]\W*b(?:ox)?|dept|apt|apartment|ro*m|fl|unit|box)\W+|\#\W*)([\w-]+)'
604
- 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 =
605
614
  '(?:
606
615
  (?:(' + direct_regexp + ')\W+
607
616
  (' + street_type_regexp + ')\b)
@@ -620,51 +629,62 @@ module StreetAddress
620
629
  (?:[^\w,]+(' + direct_regexp + ')\b)?
621
630
  )
622
631
  )'
623
- self.place_regexp =
624
- '(?:
625
- ([^\d,]+?)\W+
626
- ($' + state_regexp + ')\W*
627
- )?
632
+ self.place_regexp =
633
+ '(?:' + city_and_state_regexp + '\W*)?
628
634
  (?:' + zip_regexp + ')?'
629
-
635
+
630
636
  self.address_regexp =
631
- '\A\W*
637
+ '\A[^\w\#]*
632
638
  (' + number_regexp + ')\W*
633
639
  (?:' + fraction_regexp + '\W*)?' +
634
640
  street_regexp + '\W+
635
641
  (?:' + unit_regexp + '\W+)?' +
636
642
  place_regexp +
637
643
  '\W*\Z'
638
-
644
+
645
+ self.informal_address_regexp =
646
+ '\A\s*
647
+ (?:' + unit_regexp + '(?:\W+|\Z))?
648
+ (' + number_regexp + ')\W*
649
+ (?:' + fraction_regexp + '\W*)?' +
650
+ street_regexp + '(?:[^\#\w]+|\Z)
651
+ (?:' + unit_regexp + '(?:\W+|\Z))?' +
652
+ '(?:' + place_regexp + ')?'
653
+
639
654
  =begin rdoc
640
655
 
641
656
  parses either an address or intersection and returns an instance of
642
657
  StreetAddress::US::Address or nil if the location cannot be parsed
643
-
658
+
659
+ pass the arguement, :informal => true, to make parsing more lenient
660
+
644
661
  ====example
645
662
  StreetAddress::US.parse('1600 Pennsylvania Ave Washington, DC 20006')
646
663
  or:
647
664
  StreetAddress::US.parse('Hollywood & Vine, Los Angeles, CA')
648
-
665
+ or
666
+ StreetAddress::US.parse("1600 Pennsylvania Ave", :informal => true)
667
+
649
668
  =end
650
669
  class << self
651
- def parse(location)
670
+ def parse(location, args = {})
652
671
  if Regexp.new(corner_regexp, Regexp::IGNORECASE).match(location)
653
- parse_intersection(location);
654
- else
672
+ parse_intersection(location)
673
+ elsif args[:informal]
674
+ parse_address(location) || parse_informal_address(location)
675
+ else
655
676
  parse_address(location);
656
677
  end
657
678
  end
658
-
659
679
  =begin rdoc
660
-
661
- parses only an intersection and returnsan instance of
680
+
681
+ parses only an intersection and returns an instance of
662
682
  StreetAddress::US::Address or nil if the intersection cannot be parsed
663
-
683
+
664
684
  ====example
665
685
  address = StreetAddress::US.parse('Hollywood & Vine, Los Angeles, CA')
666
686
  assert address.intersection?
667
-
687
+
668
688
  =end
669
689
  def parse_intersection(inter)
670
690
  regex = Regexp.new(
@@ -673,9 +693,9 @@ module StreetAddress
673
693
  street_regexp + '\W+' +
674
694
  place_regexp + '\W*\Z', Regexp::IGNORECASE + Regexp::EXTENDED
675
695
  )
676
-
696
+
677
697
  return unless match = regex.match(inter)
678
-
698
+
679
699
  normalize_address(
680
700
  StreetAddress::US::Address.new(
681
701
  :street => match[4] || match[9],
@@ -692,10 +712,10 @@ module StreetAddress
692
712
  )
693
713
  )
694
714
  end
695
-
715
+
696
716
  =begin rdoc
697
717
 
698
- parses only an address and returnsan instance of
718
+ parses only an address and returns an instance of
699
719
  StreetAddress::US::Address or nil if the address cannot be parsed
700
720
 
701
721
  ====example
@@ -713,18 +733,40 @@ module StreetAddress
713
733
  :number => match[1],
714
734
  :street => match[5] || match[10] || match[2],
715
735
  :street_type => match[6] || match[3],
716
- :unit => match[14],
717
- :unit_prefix => match[13],
736
+ :unit => match[15],
737
+ :unit_prefix => match[13] || match[14],
718
738
  :suffix => match[7] || match[12],
719
739
  :prefix => match[4],
720
- :city => match[15],
721
- :state => match[16],
722
- :postal_code => match[17],
723
- :postal_code_ext => match[18]
740
+ :city => match[16],
741
+ :state => match[17],
742
+ :postal_code => match[18],
743
+ :postal_code_ext => match[19]
744
+ )
745
+ )
746
+ end
747
+
748
+ def parse_informal_address(addr)
749
+ regex = Regexp.new(informal_address_regexp, Regexp::IGNORECASE + Regexp::EXTENDED)
750
+
751
+ return unless match = regex.match(addr)
752
+
753
+ normalize_address(
754
+ StreetAddress::US::Address.new(
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]
724
766
  )
725
767
  )
726
768
  end
727
-
769
+
728
770
  private
729
771
  def normalize_address(addr)
730
772
  addr.state = normalize_state(addr.state) unless addr.state.nil?
@@ -740,7 +782,7 @@ module StreetAddress
740
782
  addr.unit_prefix.capitalize! unless addr.unit_prefix.nil?
741
783
  return addr
742
784
  end
743
-
785
+
744
786
  def normalize_state(state)
745
787
  if state.length < 3
746
788
  state.upcase
@@ -748,13 +790,13 @@ module StreetAddress
748
790
  STATE_CODES[state.downcase]
749
791
  end
750
792
  end
751
-
793
+
752
794
  def normalize_street_type(s_type)
753
795
  s_type.downcase!
754
796
  s_type = STREET_TYPES[s_type] || s_type if STREET_TYPES_LIST[s_type]
755
797
  s_type.capitalize
756
798
  end
757
-
799
+
758
800
  def normalize_directional(dir)
759
801
  if dir.length < 3
760
802
  dir.upcase
@@ -765,34 +807,34 @@ module StreetAddress
765
807
  end
766
808
 
767
809
  =begin rdoc
768
-
769
- 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
770
812
  and StreetAddress::US::parse_intersection. If an instance represents an intersection
771
813
  the attribute street2 will be populated.
772
-
814
+
773
815
  =end
774
816
  class Address
775
817
  attr_accessor(
776
- :number,
777
- :street,
778
- :street_type,
779
- :unit,
780
- :unit_prefix,
781
- :suffix,
782
- :prefix,
783
- :city,
784
- :state,
785
- :postal_code,
786
- :postal_code_ext,
787
- :street2,
788
- :street_type2,
789
- :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,
790
832
  :prefix2
791
833
  )
792
834
 
793
835
  def initialize(args)
794
- args.keys.each do |attrib|
795
- self.send("#{attrib}=", args[attrib])
836
+ args.keys.each do |attrib|
837
+ self.send("#{attrib}=", args[attrib])
796
838
  end
797
839
  return
798
840
  end
@@ -810,18 +852,31 @@ module StreetAddress
810
852
  end
811
853
 
812
854
  def line1(s = "")
813
- s += number
814
- s += " " + prefix unless prefix.nil?
815
- s += " " + street unless street.nil?
816
- s += " " + street_type unless street_type.nil?
817
- if( !unit_prefix.nil? && !unit.nil? )
818
- s += " " + unit_prefix
819
- s += " " + unit
820
- elsif( unit_prefix.nil? && !unit.nil? )
821
- 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
822
879
  end
823
- s += " " + suffix unless suffix.nil?
824
- return s
825
880
  end
826
881
 
827
882
  def to_s(format = :default)
@@ -832,7 +887,7 @@ module StreetAddress
832
887
  else
833
888
  if intersection?
834
889
  s += prefix + " " unless prefix.nil?
835
- s += street
890
+ s += street
836
891
  s += " " + street_type unless street_type.nil?
837
892
  s += " " + suffix unless suffix.nil?
838
893
  s += " and"
@@ -852,7 +907,7 @@ module StreetAddress
852
907
  end
853
908
  end
854
909
  return s
855
- end
910
+ end
856
911
  end
857
912
  end
858
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,51 @@ 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"
20
+ end
21
+
22
+ def test_zip_plus_4_with_dash
23
+ addr = StreetAddress::US.parse("2730 S Veitch St, Arlington, VA 22206-3333")
24
+ assert_equal "3333", addr.postal_code_ext
25
+ end
17
26
 
27
+ def test_zip_plus_4_without_dash
28
+ addr = StreetAddress::US.parse("2730 S Veitch St, Arlington, VA 222064444")
29
+ assert_equal "4444", addr.postal_code_ext
30
+ end
31
+
32
+ def test_informal_parse_normal_address
33
+ a = StreetAddress::US.parse("2730 S Veitch St, Arlington, VA 222064444", :informal => true)
34
+ assert_equal "2730", a.number
35
+ assert_equal "S", a.prefix
36
+ assert_equal "Veitch", a.street
37
+ assert_equal "St", a.street_type
38
+ assert_equal "Arlington", a.city
39
+ assert_equal "VA", a.state
40
+ assert_equal "22206", a.postal_code
41
+ assert_equal "4444", a.postal_code_ext
42
+ end
43
+
44
+ def test_informal_parse_informal_address
45
+ a = StreetAddress::US.parse("2730 S Veitch St", :informal => true)
46
+ assert_equal "2730", a.number
47
+ assert_equal "S", a.prefix
48
+ assert_equal "Veitch", a.street
49
+ assert_equal "St", a.street_type
50
+ end
51
+
52
+ def test_informal_parse_informal_address_trailing_words
53
+ a = StreetAddress::US.parse("2730 S Veitch St in the south of arlington", :informal => true)
54
+ assert_equal "2730", a.number
55
+ assert_equal "S", a.prefix
56
+ assert_equal "Veitch", a.street
57
+ assert_equal "St", a.street_type
18
58
  end
19
59
 
20
60
  def test_parse
@@ -58,8 +98,6 @@ class StreetAddressUsTest < Test::Unit::TestCase
58
98
  assert_equal addr.city, "Washington"
59
99
  assert_equal addr.street2, nil
60
100
 
61
-
62
-
63
101
  addr = StreetAddress::US.parse(@addr4)
64
102
  assert_equal addr.number, "1005"
65
103
  assert_equal addr.postal_code, "95472"
@@ -73,14 +111,41 @@ class StreetAddressUsTest < Test::Unit::TestCase
73
111
  assert_equal addr.street2, nil
74
112
  assert_equal addr.suffix, "N"
75
113
 
76
-
77
114
  addr = StreetAddress::US.parse(@addr5)
78
115
  assert_equal addr, nil
79
-
80
-
116
+
81
117
  addr = StreetAddress::US.parse(@addr6)
82
118
  assert_equal("207", addr.unit)
83
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
+
84
149
  addr = StreetAddress::US.parse(@int1)
85
150
  assert_equal addr.city, "Los Angeles"
86
151
  assert_equal addr.state, "CA"
@@ -111,24 +176,26 @@ class StreetAddressUsTest < Test::Unit::TestCase
111
176
  assert_equal addr.intersection?, true
112
177
  assert_equal addr.street_type, "St"
113
178
  assert_equal addr.street_type2, "St"
114
-
115
- parseable = ["1600 Pennsylvania Ave Washington DC 20006",
116
- "1600 Pennsylvania Ave #400, Washington, DC, 20006",
117
- "1600 Pennsylvania Ave Washington, DC",
118
- "1600 Pennsylvania Ave #400 Washington DC",
119
- "1600 Pennsylvania Ave, 20006",
120
- "1600 Pennsylvania Ave #400, 20006",
121
- "1600 Pennsylvania Ave 20006",
122
- "1600 Pennsylvania Ave #400 20006",
123
- "Hollywood & Vine, Los Angeles, CA",
124
- "Hollywood Blvd and Vine St, Los Angeles, CA",
125
- "Mission Street at Valencia Street, San Francisco, CA",
126
- "Hollywood & Vine, Los Angeles, CA, 90028",
127
- "Hollywood Blvd and Vine St, Los Angeles, CA, 90028",
128
- "Mission Street at Valencia Street, San Francisco, CA, 90028"]
129
-
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
+
130
197
  parseable.each do |location|
131
- assert_not_nil(StreetAddress::US.parse(location), location + " was not parse able")
198
+ assert_not_nil(StreetAddress::US.parse(location), location + " was not parseable")
132
199
  end
133
200
 
134
201
  end
metadata CHANGED
@@ -1,76 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: StreetAddress
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 3
10
- version: 1.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.6
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Derrek Long
14
- - Nicholas Schleuter
15
8
  autorequire:
16
9
  bindir: bin
17
10
  cert_chain: []
18
-
19
- date: 2011-09-21 00:00:00 -07:00
20
- default_executable:
11
+ date: 2014-12-21 00:00:00.000000000 Z
21
12
  dependencies: []
22
-
23
13
  description: |
24
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.
25
-
26
- A port of Geo::StreetAddress::US by Schuyler D. Erle and Tim Bunce.
27
15
 
16
+ A port of Geo::StreetAddress::US by Schuyler D. Erle and Tim Bunce.
28
17
  email: derreklong@gmail.com
29
18
  executables: []
30
-
31
19
  extensions: []
32
-
33
20
  extra_rdoc_files: []
34
-
35
- files:
36
- - README.rdoc
21
+ files:
22
+ - ".gitignore"
23
+ - Gemfile
24
+ - README.md
37
25
  - Rakefile
38
- - LICENSE
39
26
  - lib/street_address.rb
27
+ - street_address.gemspec
40
28
  - test/test_street_address.rb
41
- has_rdoc: true
42
29
  homepage: https://github.com/derrek/street-address
43
30
  licenses: []
44
-
31
+ metadata: {}
45
32
  post_install_message:
46
33
  rdoc_options: []
47
-
48
- require_paths:
34
+ require_paths:
49
35
  - lib
50
- required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
53
38
  - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
62
43
  - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
68
46
  requirements: []
69
-
70
47
  rubyforge_project:
71
- rubygems_version: 1.4.2
48
+ rubygems_version: 2.2.2
72
49
  signing_key:
73
- specification_version: 3
50
+ specification_version: 4
74
51
  summary: Parse Addresses into substituent parts. This gem includes US only.
75
- test_files:
76
- - 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.
data/README.rdoc DELETED
@@ -1,35 +0,0 @@
1
- StreetAddress
2
- by Derrek Long
3
- https://github.com/derrek/street-address
4
-
5
- == DESCRIPTION:
6
-
7
- Parses one line street addresses and returns a normalized address object.
8
-
9
- This is a near direct port of the of the perl module
10
- Geo::StreetAddress::US originally written by Schuyler D. Erle.
11
- For more information see
12
- http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/
13
-
14
- == SYNOPSIS:
15
-
16
- Parse United States addresses.
17
-
18
- === Basic Usage:
19
- require 'street_address'
20
- address = StreetAddress::US.parse("1600 Pennsylvania Ave, Washington, DC, 20500")
21
- address.street # Pennsylvania
22
- address.number # 1600
23
- address.postal_code # 20500
24
- address.city # Washington
25
- address.state # DC
26
- address.state_name # District of columbia
27
- address.street_type # Ave
28
- address.intersection? # false
29
- address.to_s # "1600 Pennsylvania Ave, Washington, DC 20500"
30
- address.to_s(:line1) # 1600 Pennsylvania Ave
31
- StreetAddress::US.parse("1600 Pennsylvania Ave") # nil not a full address
32
-
33
- === Gemfile:
34
- To use from your Gemfile:
35
- gem 'StreetAddress', '1.0.2', :require => "street_address"