postal_address 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postal_address.rb +5 -4
- data/lib/postal_address/address.rb +1 -12
- data/lib/postal_address/formatters/text.rb +1 -1
- data/lib/postal_address/version.rb +1 -1
- data/spec/postal_address_spec.rb +17 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709f977bc0f278516ed857f4180eea486b82f8a2
|
4
|
+
data.tar.gz: bd3e09740ea53e45cfebbecec53dddea5b08a306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9584eae3902a14d69ee379d21c32daeae08c31d552ee50f9910aa14b2561652b03504cbf6c9b816d7d0f1dbd406612fa9ac7300040db332bd2ec579e73adb04
|
7
|
+
data.tar.gz: ff909cfda68bf7bafa7486e3ce53b7bf74d8c0422073eaa39fe2da337d21c21f64d52a5d6b972674517cc0ed668855f82b66f49acac0efe97659d8aae5448bb5
|
data/lib/postal_address.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require "pathname"
|
2
3
|
require "postal_address/version"
|
3
4
|
require "postal_address/address"
|
4
5
|
require "postal_address/formatters/text"
|
@@ -17,17 +18,17 @@ module Postal
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def address_formats
|
20
|
-
@address_formats ||=
|
21
|
+
@address_formats ||= YAML.load_file(path_for(:address_formats))
|
21
22
|
end
|
22
23
|
|
23
24
|
def country_names
|
24
|
-
@country_names ||=
|
25
|
+
@country_names ||= YAML.load_file(path_for(:country_names))
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
29
|
|
29
|
-
def
|
30
|
-
|
30
|
+
def path_for(filename)
|
31
|
+
Pathname.new(__FILE__).dirname.parent + "data" + "#{filename}.yml"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -3,15 +3,6 @@ module Postal
|
|
3
3
|
Fields = [:recipient, :street, :zip, :state, :city, :country, :country_code]
|
4
4
|
|
5
5
|
attr_accessor *Fields
|
6
|
-
|
7
|
-
alias_method :locality=, :city=
|
8
|
-
alias_method :zip_code=, :zip=
|
9
|
-
alias_method :postal_code=, :zip=
|
10
|
-
alias_method :postcode=, :zip=
|
11
|
-
alias_method :region=, :state=
|
12
|
-
alias_method :province=, :state=
|
13
|
-
alias_method :territory=, :state=
|
14
|
-
alias_method :administrative_area_level_1=, :state=
|
15
6
|
|
16
7
|
def country_code=(code)
|
17
8
|
@country_code = Postal.sanitize(code)
|
@@ -22,9 +13,7 @@ module Postal
|
|
22
13
|
end
|
23
14
|
|
24
15
|
def initialize(attrs={})
|
25
|
-
attrs.each
|
26
|
-
self.public_send(:"#{field}=", value) if self.respond_to?(:"#{field}=")
|
27
|
-
end if attrs
|
16
|
+
attrs.each { |k,v| public_send(:"#{k}=", v) if respond_to?(:"#{k}=") } if attrs
|
28
17
|
end
|
29
18
|
|
30
19
|
def to_h
|
data/spec/postal_address_spec.rb
CHANGED
@@ -81,23 +81,23 @@ describe Postal do
|
|
81
81
|
address.to_s.must_equal "Tobias Füncke\n101 Broadway\n10002 New York City"
|
82
82
|
end
|
83
83
|
|
84
|
-
it "should respond to state aliases" do
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should respond to city aliases" do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should respond to zip aliases" do
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
84
|
+
# it "should respond to state aliases" do
|
85
|
+
# [:region, :province, :territory, :administrative_area_level_1].each do |alias_name|
|
86
|
+
# address.must_respond_to :"#{alias_name}="
|
87
|
+
# end
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# it "should respond to city aliases" do
|
91
|
+
# [:locality].each do |alias_name|
|
92
|
+
# address.must_respond_to :"#{alias_name}="
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# it "should respond to zip aliases" do
|
97
|
+
# [:zip_code, :postal_code, :postcode].each do |alias_name|
|
98
|
+
# address.must_respond_to :"#{alias_name}="
|
99
|
+
# end
|
100
|
+
# end
|
101
101
|
|
102
102
|
it "should return html" do
|
103
103
|
address.to_html.must_equal "<p itemscope itemtype=\"http://schema.org/PostalAddress\"><span itemprop=\"name\">Tobias Füncke</span><br><span itemprop=\"streetAddress\">101 Broadway</span><br><span itemprop=\"addressLocality\">New York City</span> <span itemprop=\"addressRegion\">NY</span> <span itemprop=\"postalCode\">10002</span><br><span itemprop=\"addressCountry\">United States of America</span></p>"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postal_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Melchert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|