addressable_record 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/addressable_record.gemspec +2 -2
- data/lib/addressable_record/address.rb +5 -1
- data/lib/addressable_record.rb +1 -1
- data/spec/addressable_record/address_spec.rb +4 -0
- data/spec/addressable_record_spec.rb +40 -1
- metadata +2 -2
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/addressable_record.gemspec
CHANGED
@@ -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.
|
8
|
+
s.version = "1.0.2"
|
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-
|
12
|
+
s.date = %q{2010-03-21}
|
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 = [
|
@@ -52,7 +52,7 @@ module AddressableRecord
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.parse( address )
|
55
|
-
raise "Cannot convert #{address.class.to_s.downcase} to an AddressableRecord::Address" unless [Array].include?( address.class )
|
55
|
+
raise "Cannot convert #{address.class.to_s.downcase} to an AddressableRecord::Address" unless [Array, Hash].include?( address.class )
|
56
56
|
self.send( :"parse_#{address.class.to_s.downcase}", address )
|
57
57
|
end
|
58
58
|
|
@@ -130,6 +130,10 @@ module AddressableRecord
|
|
130
130
|
street = streets.join( @@street_delimiter )
|
131
131
|
return AddressableRecord::Address.new( :raw_street => street, :city => city, :state_or_province => state, :raw_zip_code => zip_code, :country => country )
|
132
132
|
end
|
133
|
+
|
134
|
+
def parse_hash( address )
|
135
|
+
return AddressableRecord::Address.new( address )
|
136
|
+
end
|
133
137
|
|
134
138
|
def find_state_position( address_elements )
|
135
139
|
# Look for state abbreviation
|
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.2'
|
8
8
|
end
|
9
9
|
|
10
10
|
ActiveRecord::Base.send( :include, AddressableRecord::ActiveRecordExtensions ) if defined?( ActiveRecord::Base )
|
@@ -64,6 +64,10 @@ describe "AddressableRecord::Address" do
|
|
64
64
|
@klass.send( :find_state_position, ['123 Jones St.', 'Atlanta', '33333' ] ).should be_nil
|
65
65
|
end
|
66
66
|
|
67
|
+
describe "when parsing an hash of address elements" do
|
68
|
+
|
69
|
+
end
|
70
|
+
|
67
71
|
describe "when parsing an array of address elements" do
|
68
72
|
before :each do
|
69
73
|
@address_elements_without_country = ['123 Jones Street', 'Suite 540', 'Atlanta', 'GA', '33333-1111']
|
@@ -18,7 +18,7 @@ describe "AddressableRecord" do
|
|
18
18
|
@user.save!
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should respond to
|
21
|
+
it "should respond to address" do
|
22
22
|
@user.respond_to?( :address ).should be_true
|
23
23
|
end
|
24
24
|
|
@@ -49,6 +49,45 @@ describe "AddressableRecord" do
|
|
49
49
|
it "should agree that the country is United States" do
|
50
50
|
@user.address.country.should eql( 'United States' )
|
51
51
|
end
|
52
|
+
|
53
|
+
describe "when creating with a Hash of address elements" do
|
54
|
+
before :each do
|
55
|
+
@user = User.new( :name => 'John Smith', :address => @address_attributes )
|
56
|
+
@user.save!
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should respond to address" do
|
60
|
+
@user.respond_to?( :address ).should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be an AddressableRecord::Address" do
|
64
|
+
@user.address.is_a?( AddressableRecord::Address ).should be_true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should agree that the size of streets is 2" do
|
68
|
+
@user.address.streets.size.should eql( 2 )
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should agree that the street address is 123 Jones Street, Suite 540" do
|
72
|
+
@user.address.street.should eql( '123 Jones Street, Suite 540' )
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should agree that the city is Atlanta" do
|
76
|
+
@user.address.city.should eql( 'Atlanta' )
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should agree that the state is GA" do
|
80
|
+
@user.address.state.should eql( 'GA' )
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should agree that the zip_code is 31234-7890" do
|
84
|
+
@user.address.zip_code.should eql( '31234-7890' )
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should agree that the country is United States" do
|
88
|
+
@user.address.country.should eql( 'United States' )
|
89
|
+
end
|
90
|
+
end
|
52
91
|
end
|
53
92
|
|
54
93
|
describe "when used through an association" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addressable_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Jason Harrelson (midas)
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|