postal_address 0.1.2 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/postal_address/address.rb +10 -1
- data/lib/postal_address/version.rb +1 -1
- data/spec/postal_address_spec.rb +16 -22
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd9ebb5dbcc6d69377b28f76b56b98d746ecf9a3
|
|
4
|
+
data.tar.gz: c698853f917f3755ed5afbf6b5fbee155f5b7b09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f466cda1ce5cd6ddb84c58497a308988e8b81e903d419c97992b541891172266ea086f5fc398bf6459f0c1ac96d7e781b3fcfdd2fc4a5516663e4232f2e7447d
|
|
7
|
+
data.tar.gz: 595ee7159deff55287172552e8eedf055f14e2a17ec0c6ef694f8e553f45624026d6f4ba682fe112c39e7c6c1d46b97ac468630a86db3f6419aef6fb58656b91
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# International Postal Address Formatting
|
|
2
2
|
|
|
3
|
-
International postal address formatting
|
|
3
|
+
International postal address formatting with HTML Microformats.
|
|
4
4
|
|
|
5
5
|
[](https://travis-ci.org/max-power/postal_address)
|
|
6
6
|
|
|
@@ -3,6 +3,15 @@ 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=
|
|
6
15
|
|
|
7
16
|
def initialize(attrs={})
|
|
8
17
|
attrs.each do |attr, value|
|
|
@@ -33,7 +42,7 @@ module Postal
|
|
|
33
42
|
private
|
|
34
43
|
|
|
35
44
|
def attributes
|
|
36
|
-
Fields.each_with_object({}) do |key, hash|
|
|
45
|
+
Fields.each_with_object({}) do |key, hash|
|
|
37
46
|
hash[key] = public_send(key)
|
|
38
47
|
end
|
|
39
48
|
end
|
data/spec/postal_address_spec.rb
CHANGED
|
@@ -81,29 +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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
|
91
95
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
# end
|
|
98
|
-
# end
|
|
99
|
-
#
|
|
100
|
-
# it "should respond to zip aliases" do
|
|
101
|
-
# [:zip_code, :postal_code, :postcode].each do |alias_name|
|
|
102
|
-
# #address.must_respond_to alias_name
|
|
103
|
-
# address.must_respond_to :"#{alias_name}="
|
|
104
|
-
# #address.send(alias_name).must_equal address.zip
|
|
105
|
-
# end
|
|
106
|
-
# end
|
|
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
|
|
107
101
|
|
|
108
102
|
it "should return html" do
|
|
109
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>"
|