addressable_record 1.0.2 → 1.0.3
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.
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/addressable_record.gemspec +1 -1
- data/lib/addressable_record.rb +1 -1
- data/lib/addressable_record/address.rb +4 -1
- data/spec/addressable_record_spec.rb +6 -0
- metadata +1 -1
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/addressable_record.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{addressable_record}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
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)"]
|
data/lib/addressable_record.rb
CHANGED
@@ -4,7 +4,7 @@ require 'addressable_record/address'
|
|
4
4
|
require 'addressable_record/active_record_extesions'
|
5
5
|
|
6
6
|
module AddressableRecord
|
7
|
-
VERSION = '1.0.
|
7
|
+
VERSION = '1.0.3'
|
8
8
|
end
|
9
9
|
|
10
10
|
ActiveRecord::Base.send( :include, AddressableRecord::ActiveRecordExtensions ) if defined?( ActiveRecord::Base )
|
@@ -17,7 +17,10 @@ module AddressableRecord
|
|
17
17
|
|
18
18
|
@streets = AddressableRecord::Address.parse_street( attrs[:raw_street] || '' )
|
19
19
|
raw_zip = (attrs[:raw_zip_code] || '')
|
20
|
-
|
20
|
+
puts raw_zip
|
21
|
+
puts raw_zip.size
|
22
|
+
@zip_code = raw_zip.size == 5 ? raw_zip : raw_zip.gsub( /(\d{5})(\d{4})/, "\\1#{@@zip_code_delimiter}\\2" )
|
23
|
+
puts @zip_code
|
21
24
|
|
22
25
|
@pattern_map = {
|
23
26
|
'%s' => @streets.join( ', ' ) || "",
|
@@ -87,6 +87,12 @@ describe "AddressableRecord" do
|
|
87
87
|
it "should agree that the country is United States" do
|
88
88
|
@user.address.country.should eql( 'United States' )
|
89
89
|
end
|
90
|
+
|
91
|
+
it "should handle a 5 digit zip code" do
|
92
|
+
@user = User.new( :name => 'John Smith', :address => @address_attributes.merge( :raw_zip_code => '31234' ) )
|
93
|
+
@user.save!
|
94
|
+
@user.address.zip_code.should eql( '31234' )
|
95
|
+
end
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|