people_places_things 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,159 @@
1
+ require 'spec/helper'
2
+
3
+ describe StreetAddress do
4
+ it "should parse number street" do
5
+ addr = StreetAddress.new "123 Main Street"
6
+ addr.number.should == '123'
7
+ addr.name.should == 'Main'
8
+ addr.suffix.should == :street
9
+ end
10
+
11
+ it "should parse number with letter" do
12
+ addr = StreetAddress.new "204-B Main Street"
13
+ addr.number.should == '204-B'
14
+ addr.name.should == 'Main'
15
+ addr.suffix.should == :street
16
+ end
17
+
18
+ it "should parse pre direction" do
19
+ addr = StreetAddress.new "123 E Main Street"
20
+ addr.number.should == '123'
21
+ addr.pre_direction.should == :east
22
+ addr.name.should == 'Main'
23
+ addr.suffix.should == :street
24
+ end
25
+
26
+ it "should parse post direction" do
27
+ addr = StreetAddress.new "123 Main Street NE"
28
+ addr.number.should == '123'
29
+ addr.name.should == 'Main'
30
+ addr.suffix.should == :street
31
+ addr.post_direction.should == :northeast
32
+ end
33
+
34
+ it "should parse pre and post direction" do
35
+ addr = StreetAddress.new "123 E Main Street North"
36
+ addr.number.should == '123'
37
+ addr.pre_direction.should == :east
38
+ addr.name.should == 'Main'
39
+ addr.suffix.should == :street
40
+ addr.post_direction.should == :north
41
+ end
42
+
43
+ it "should parse street names that look like directions" do
44
+ addr = StreetAddress.new "123 E E St"
45
+ addr.number.should == '123'
46
+ addr.pre_direction.should == :east
47
+ addr.name.should == 'E'
48
+ addr.suffix.should == :street
49
+ end
50
+
51
+ it "should parse street names that look like directions, with post directions" do
52
+ addr = StreetAddress.new "123 E E St NE"
53
+ addr.number.should == '123'
54
+ addr.pre_direction.should == :east
55
+ addr.name.should == 'E'
56
+ addr.suffix.should == :street
57
+ addr.post_direction.should == :northeast
58
+ end
59
+
60
+ it "should parse abbreviations" do
61
+ addr = StreetAddress.new "123 e. 1st ave"
62
+ addr.number.should == '123'
63
+ addr.pre_direction.should == :east
64
+ addr.name.should == '1st'
65
+ addr.suffix.should == :avenue
66
+ end
67
+
68
+ it "should parse suites" do
69
+ addr = StreetAddress.new "123 E E St NE Ste 23"
70
+ addr.number.should == '123'
71
+ addr.pre_direction.should == :east
72
+ addr.name.should == 'E'
73
+ addr.suffix.should == :street
74
+ addr.post_direction.should == :northeast
75
+ addr.unit_type.should == :suite
76
+ addr.unit.should == '23'
77
+ end
78
+
79
+ it "should parse apartments" do
80
+ addr = StreetAddress.new "123 E E St NE Apartment 4"
81
+ addr.number.should == '123'
82
+ addr.pre_direction.should == :east
83
+ addr.name.should == 'E'
84
+ addr.suffix.should == :street
85
+ addr.post_direction.should == :northeast
86
+ addr.unit_type.should == :apartment
87
+ addr.unit.should == '4'
88
+ end
89
+
90
+ it "should parse numbers" do
91
+ addr = StreetAddress.new '123 E E St NE # 5'
92
+ addr.number.should == '123'
93
+ addr.pre_direction.should == :east
94
+ addr.name.should == 'E'
95
+ addr.suffix.should == :street
96
+ addr.post_direction.should == :northeast
97
+ addr.unit_type.should == :number
98
+ addr.unit.should == '5'
99
+ end
100
+
101
+ it "should parse no number" do
102
+ addr = StreetAddress.new "Westside Highway"
103
+ addr.number.should == nil
104
+ addr.name.should == 'Westside'
105
+ addr.suffix.should == :highway
106
+ end
107
+
108
+ it "should parse directional street with suffix" do
109
+ addr = StreetAddress.new "12 north avenue"
110
+ addr.number.should == '12'
111
+ addr.name.should == 'north'
112
+ addr.suffix.should == :avenue
113
+ end
114
+
115
+ it "should parse directional street without suffix" do
116
+ addr = StreetAddress.new "12 north"
117
+ addr.number.should == '12'
118
+ addr.name.should == 'north'
119
+ end
120
+
121
+ it "should parse directional street with postdir" do
122
+ addr = StreetAddress.new "12 north w"
123
+ addr.number.should == '12'
124
+ addr.name.should == 'north'
125
+ addr.post_direction.should == :west
126
+ end
127
+
128
+ it "should parse directional street with postdir and unit" do
129
+ addr = StreetAddress.new "12 n sw apt. 2"
130
+ addr.number.should == '12'
131
+ addr.name.should == 'n'
132
+ addr.post_direction.should == :southwest
133
+ addr.unit_type.should == :apartment
134
+ addr.unit.should == '2'
135
+ end
136
+
137
+ it "should handle commas" do
138
+ addr = StreetAddress.new "123 E E St NE, suite 23"
139
+ addr.number.should == '123'
140
+ addr.pre_direction.should == :east
141
+ addr.name.should == 'E'
142
+ addr.suffix.should == :street
143
+ addr.post_direction.should == :northeast
144
+ addr.unit_type.should == :suite
145
+ addr.unit.should == '23'
146
+ end
147
+
148
+ it "should support long form" do
149
+ StreetAddress.string_for(:northwest, :long).should == 'northwest'
150
+ end
151
+
152
+ it "should support short form" do
153
+ StreetAddress.string_for(:road, :short).should == 'rd'
154
+ end
155
+
156
+ it "should support short form when none exists" do
157
+ StreetAddress.string_for(:oaks, :short).should == StreetAddress.string_for(:oaks, :long)
158
+ end
159
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec/helper'
2
+
3
+ describe ZipCode do
4
+ it "should parse base" do
5
+ zip = ZipCode.new '30306'
6
+ zip.base.should == '30306'
7
+ zip.plus_four.should == nil
8
+ end
9
+
10
+ it "should parse plus four" do
11
+ zip = ZipCode.new '30306-3522'
12
+ zip.base.should == '30306'
13
+ zip.plus_four.should == '3522'
14
+ end
15
+
16
+ it "should throw exception on unsupported parse format" do
17
+ lambda { ZipCode.new('303065344') }.should raise_error
18
+ end
19
+
20
+ it "should convert to string" do
21
+ ZipCode.new('30306-3522').to_s.should == '30306-3522'
22
+ end
23
+
24
+ it "should throw exception on unsupported to_s format" do
25
+ lambda { ZipCode.new('30306-3522').to_s(:bogus) }.should raise_error
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: people_places_things
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Danny Burkes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-01 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Parsers and formatters for person names, street addresses, city/state/zip, phone numbers, etc.
17
+ email: dburkes@netable.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.textile
24
+ files:
25
+ - .gitignore
26
+ - README.textile
27
+ - Rakefile
28
+ - VERSION
29
+ - lib/people_places_things.rb
30
+ - lib/people_places_things/VERSION
31
+ - lib/people_places_things/ansi_counties.rb
32
+ - lib/people_places_things/data/data.yml
33
+ - lib/people_places_things/data/process_data.rb
34
+ - lib/people_places_things/data/raw.txt
35
+ - lib/people_places_things/location.rb
36
+ - lib/people_places_things/person_name.rb
37
+ - lib/people_places_things/phone_number.rb
38
+ - lib/people_places_things/state.rb
39
+ - lib/people_places_things/street_address.rb
40
+ - lib/people_places_things/zip_code.rb
41
+ - people_places_things.gemspec
42
+ - spec/ansi_counties_spec.rb
43
+ - spec/helper.rb
44
+ - spec/location_spec.rb
45
+ - spec/person_name_spec.rb
46
+ - spec/phone_number_spec.rb
47
+ - spec/state_spec.rb
48
+ - spec/street_address_spec.rb
49
+ - spec/zip_code_spec.rb
50
+ has_rdoc: true
51
+ homepage: http://github.com/dburkes/people_places_things
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --charset=UTF-8
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.3.5
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: Parsers and formatters for person names, street addresses, city/state/zip, phone numbers, etc.
78
+ test_files:
79
+ - spec/ansi_counties_spec.rb
80
+ - spec/helper.rb
81
+ - spec/location_spec.rb
82
+ - spec/person_name_spec.rb
83
+ - spec/phone_number_spec.rb
84
+ - spec/state_spec.rb
85
+ - spec/street_address_spec.rb
86
+ - spec/zip_code_spec.rb