addressable_record 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.1.0 2010-07-01
2
+
3
+ * Tweak address formatting to use standard abbreviations and comma placement
4
+
5
+
1
6
  == 1.0.4 2010-03-29
2
7
 
3
8
  Removed some puts statements that should not have been left in the code.
data/README.rdoc CHANGED
@@ -34,7 +34,7 @@ Encapsulates the composed of pattern for addresses into any easy to use library.
34
34
 
35
35
  Add to environment file:
36
36
 
37
- config.gem "addressable_record", :version => '1.0.0', :source => 'http://gemcutter.org'
37
+ config.gem "addressable_record", :version => '~>1.0.0', :source => 'http://gemcutter.org'
38
38
 
39
39
  Run:
40
40
 
@@ -77,7 +77,7 @@ Call the macro in an ActiveRecord descendant:
77
77
  Set the field equal to something:
78
78
 
79
79
  @user.home_address = AddressableRecord::Address.new( :raw_street => '123 Jones Street###Suite 540', :city => 'Atlanta',
80
- :state_or_province => 'GA', :raw_zip_code => '333331111', :country => 'United States' )
80
+ :state_or_province => 'GA', :raw_zip_code => '333331111', :country => 'U.S.A.' )
81
81
 
82
82
  or (with identical results):
83
83
 
@@ -89,7 +89,7 @@ Reference the raw database fields:
89
89
  @user.home_address_city # => Atlanta
90
90
  @user.home_address_state_or_province # => GA
91
91
  @user.home_address_raw_zip_code # => 333331111
92
- @user.home_address_country # => United States
92
+ @user.home_address_country # => U.S.A.
93
93
 
94
94
  Reference the sub parts of the field:
95
95
 
@@ -102,7 +102,7 @@ Reference the sub parts of the field:
102
102
  @user.home_address.state # => GA
103
103
  @user.home_address.province # => GA
104
104
  @user.home_address.zip_code # => 33333-1111
105
- @user.home_address.country # => United States
105
+ @user.home_address.country # => U.S.A.
106
106
 
107
107
  Use formats to control the output:
108
108
 
@@ -110,13 +110,13 @@ Use formats to control the output:
110
110
  @user.home_address.to_s( '%c' ) # => Atlanta
111
111
  @user.home_address.to_s( '%S' ) # => GA
112
112
  @user.home_address.to_s( '%z' ) # => 33333-1111
113
- @user.home_address.to_s( '%C' ) # => United States
113
+ @user.home_address.to_s( '%C' ) # => U.S.A.
114
114
  @user.home_address.to_s( '%c %S' ) # => Atlanta GA
115
115
 
116
116
  Use pre-defined named formats to control the output:
117
117
 
118
- @user.home_address.to_s( :us_long ) # => 123 Jones Street, Suite 540, Atlanta GA, 33333-1111, United States
119
- @user.home_address.to_s( :us ) # => 123 Jones Street, Suite 540, Atlanta GA, 33333-1111
118
+ @user.home_address.to_s( :us_long ) # => 123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A.
119
+ @user.home_address.to_s( :us ) # => 123 Jones Street, Suite 540, Atlanta, GA 33333-1111
120
120
 
121
121
 
122
122
  == Note on Patches/Pull Requests
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{addressable_record}
8
- s.version = "1.0.4"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2010-03-29}
12
+ s.date = %q{2010-07-01}
13
13
  s.description = %q{Encapsulates the composed of pattern for addresses into any easy to use library. Provides convenience methods for formatting, parsing, etc.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.homepage = %q{http://github.com/midas/addressable_record}
45
45
  s.rdoc_options = ["--charset=UTF-8"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.5}
47
+ s.rubygems_version = %q{1.3.6}
48
48
  s.summary = %q{Encapsulates the composed of pattern for addresses into any easy to use library.}
49
49
  s.test_files = [
50
50
  "spec/addressable_record/address_parsing_shared_spec.rb",
@@ -7,8 +7,8 @@ module AddressableRecord
7
7
  @@street_delimiter ||= '###'
8
8
  @@zip_code_delimiter ||= '-'
9
9
  @@patterns ||= {
10
- :us_long => "%s, %c %S, %z, %C",
11
- :us => "%s, %c %S, %z"
10
+ :us_long => "%s, %c, %S %z %C",
11
+ :us => "%s, %c, %S %z"
12
12
  }
13
13
 
14
14
  def initialize( attrs )
@@ -123,7 +123,7 @@ module AddressableRecord
123
123
  raise 'Cannot parse address array. No zip code found.' unless address_elements.size >= (state_pos + 1)
124
124
  state = States.by_abbreviation.has_key?( address_elements[state_pos] ) ? address_elements[state_pos] : States.by_name[address_elements[state_pos]]
125
125
  zip_code = address_elements[state_pos+1].gsub( /#{@@zip_code_delimiter}/, '' )
126
- country = address_elements.size >= (state_pos + 3) ? address_elements[state_pos+2] : 'United States'
126
+ country = address_elements.size >= (state_pos + 3) ? address_elements[state_pos+2] : 'U.S.A.'
127
127
  city = address_elements[state_pos-1]
128
128
  streets = []
129
129
  (0..state_pos-2).each { |i| streets << address_elements[i] }
@@ -40,4 +40,4 @@ class ContactAddress < ActiveRecord::Base
40
40
  end
41
41
 
42
42
  ADDRESS_ATTRIBUTES = {:raw_street => '123 Jones Street###Suite 540', :city => 'Atlanta', :state_or_province => 'GA',
43
- :raw_zip_code => '312347890', :country => 'United States' }
43
+ :raw_zip_code => '312347890', :country => 'U.S.A.' }
@@ -1,6 +1,6 @@
1
1
  require File.expand_path( File.dirname(__FILE__) + '/../spec_helper' )
2
2
 
3
- shared_examples_for "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333-1111, United States" do
3
+ shared_examples_for "The address 123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A." do
4
4
  it "should be an AddressableRecord::Address" do
5
5
  @address.is_a?( AddressableRecord::Address ).should be_true
6
6
  end
@@ -25,8 +25,8 @@ shared_examples_for "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333
25
25
  @address.zip_code.should eql( '33333-1111' )
26
26
  end
27
27
 
28
- it "should agree that the country is United States" do
29
- @address.country.should eql( 'United States' )
28
+ it "should agree that the country is U.S.A." do
29
+ @address.country.should eql( 'U.S.A.' )
30
30
  end
31
31
 
32
32
  it "should join the address correctly given a string delimiter argument" do
@@ -42,10 +42,10 @@ shared_examples_for "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333
42
42
  end
43
43
 
44
44
  it "should join the address correctly given a delimiter and country option" do
45
- @address.join( :delimiter => '<br/>', :country => true ).should eql( '123 Jones Street<br/>Suite 540<br/>Atlanta, GA 33333-1111<br/>United States' )
45
+ @address.join( :delimiter => '<br/>', :country => true ).should eql( '123 Jones Street<br/>Suite 540<br/>Atlanta, GA 33333-1111<br/>U.S.A.' )
46
46
  end
47
47
 
48
48
  it "should join the address correctly given a delimiter and street_delimiter option" do
49
- @address.join( :delimiter => '<br/>', :street_delimiter => '###', :country => true ).should eql( '123 Jones Street###Suite 540<br/>Atlanta, GA 33333-1111<br/>United States' )
49
+ @address.join( :delimiter => '<br/>', :street_delimiter => '###', :country => true ).should eql( '123 Jones Street###Suite 540<br/>Atlanta, GA 33333-1111<br/>U.S.A.' )
50
50
  end
51
51
  end
@@ -75,10 +75,10 @@ describe "AddressableRecord::Address" do
75
75
 
76
76
  describe "with a country" do
77
77
  before :each do
78
- @address = @klass.parse( @address_elements_without_country + ['United States'] )
78
+ @address = @klass.parse( @address_elements_without_country + ['U.S.A.'] )
79
79
  end
80
80
 
81
- it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333-1111, United States"
81
+ it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A."
82
82
  end
83
83
 
84
84
  describe "without a country" do
@@ -86,7 +86,7 @@ describe "AddressableRecord::Address" do
86
86
  @address = @klass.parse( @address_elements_without_country )
87
87
  end
88
88
 
89
- it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333-1111, United States"
89
+ it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A."
90
90
  end
91
91
 
92
92
  describe "with a spelled out state name" do
@@ -95,7 +95,7 @@ describe "AddressableRecord::Address" do
95
95
  @address = @klass.parse( @address_elements_without_country )
96
96
  end
97
97
 
98
- it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333-1111, United States"
98
+ it_should_behave_like "The address 123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A."
99
99
  end
100
100
 
101
101
  describe "when printing out a formatted string" do
@@ -104,11 +104,11 @@ describe "AddressableRecord::Address" do
104
104
  end
105
105
 
106
106
  it "should obey the :us format correctly" do
107
- @address.to_s( :us ).should eql( '123 Jones Street, Suite 540, Atlanta GA, 33333-1111' )
107
+ @address.to_s( :us ).should eql( '123 Jones Street, Suite 540, Atlanta, GA 33333-1111' )
108
108
  end
109
109
 
110
110
  it "should obey the :us_long format correctly" do
111
- @address.to_s( :us_long ).should eql( '123 Jones Street, Suite 540, Atlanta GA, 33333-1111, United States' )
111
+ @address.to_s( :us_long ).should eql( '123 Jones Street, Suite 540, Atlanta, GA 33333-1111 U.S.A.' )
112
112
  end
113
113
 
114
114
  it "should obey the %s format correctly" do
@@ -148,7 +148,7 @@ describe "AddressableRecord::Address" do
148
148
  end
149
149
 
150
150
  it "should obey the %C format correctly" do
151
- @address.to_s( '%C' ).should eql( 'United States' )
151
+ @address.to_s( '%C' ).should eql( 'U.S.A.' )
152
152
  end
153
153
  end
154
154
  end
@@ -46,8 +46,8 @@ describe "AddressableRecord" do
46
46
  @user.address.zip_code.should eql( '31234-7890' )
47
47
  end
48
48
 
49
- it "should agree that the country is United States" do
50
- @user.address.country.should eql( 'United States' )
49
+ it "should agree that the country is U.S.A." do
50
+ @user.address.country.should eql( 'U.S.A.' )
51
51
  end
52
52
 
53
53
  describe "when creating with a Hash of address elements" do
@@ -84,8 +84,8 @@ describe "AddressableRecord" do
84
84
  @user.address.zip_code.should eql( '31234-7890' )
85
85
  end
86
86
 
87
- it "should agree that the country is United States" do
88
- @user.address.country.should eql( 'United States' )
87
+ it "should agree that the country is U.S.A." do
88
+ @user.address.country.should eql( 'U.S.A.' )
89
89
  end
90
90
 
91
91
  it "should handle a 5 digit zip code" do
@@ -142,12 +142,12 @@ describe "AddressableRecord" do
142
142
  @person.contact_addresses.first.address.zip_code.should eql( '31234-7890' )
143
143
  end
144
144
 
145
- it "should agree that the address country is United States" do
146
- @address.country.should eql( 'United States' )
145
+ it "should agree that the address country is U.S.A." do
146
+ @address.country.should eql( 'U.S.A.' )
147
147
  end
148
148
 
149
- it "should agree that the associated country is United States" do
150
- @person.contact_addresses.first.address.country.should eql( 'United States' )
149
+ it "should agree that the associated country is U.S.A." do
150
+ @person.contact_addresses.first.address.country.should eql( 'U.S.A.' )
151
151
  end
152
152
  end
153
153
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 0
9
+ version: 1.1.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - C. Jason Harrelson (midas)
@@ -9,39 +14,50 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-29 00:00:00 -05:00
17
+ date: 2010-07-01 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: geographer
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 1
30
+ - 1
23
31
  version: 1.1.1
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: activerecord
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
33
44
  version: "2.3"
34
- version:
45
+ type: :runtime
46
+ version_requirements: *id002
35
47
  - !ruby/object:Gem::Dependency
36
48
  name: rspec
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
40
51
  requirements:
41
52
  - - ">="
42
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 2
57
+ - 9
43
58
  version: 1.2.9
44
- version:
59
+ type: :development
60
+ version_requirements: *id003
45
61
  description: Encapsulates the composed of pattern for addresses into any easy to use library. Provides convenience methods for formatting, parsing, etc.
46
62
  email: jason@lookforwardenterprises.com
47
63
  executables: []
@@ -88,18 +104,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
104
  requirements:
89
105
  - - ">="
90
106
  - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
91
109
  version: "0"
92
- version:
93
110
  required_rubygems_version: !ruby/object:Gem::Requirement
94
111
  requirements:
95
112
  - - ">="
96
113
  - !ruby/object:Gem::Version
114
+ segments:
115
+ - 0
97
116
  version: "0"
98
- version:
99
117
  requirements: []
100
118
 
101
119
  rubyforge_project:
102
- rubygems_version: 1.3.5
120
+ rubygems_version: 1.3.6
103
121
  signing_key:
104
122
  specification_version: 3
105
123
  summary: Encapsulates the composed of pattern for addresses into any easy to use library.