postal_address 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 422cdf82f6d4e54433fab6605774d91be87b3b4c
4
- data.tar.gz: c42be9ee3b3922263c53a1d8a15fed692578bd74
3
+ metadata.gz: dd9ebb5dbcc6d69377b28f76b56b98d746ecf9a3
4
+ data.tar.gz: c698853f917f3755ed5afbf6b5fbee155f5b7b09
5
5
  SHA512:
6
- metadata.gz: 29a813c8fd37b87a96782874d2a199e6ba75f6166d2d6a33bda8c5835f9d48d3d061bc1606bb94c98f8b51ebd2bca728c4d0f2c6ee0d2d9b74e03f8beee979e3
7
- data.tar.gz: cda37c73bf10d4813414e12bc180ab8926c39eb916ad8eaf01f9ba6955f32679fe1007725ed57fec99bbd619f7dfea6180418f63f0ad4a45f5ce27e929a3f1b4
6
+ metadata.gz: f466cda1ce5cd6ddb84c58497a308988e8b81e903d419c97992b541891172266ea086f5fc398bf6459f0c1ac96d7e781b3fcfdd2fc4a5516663e4232f2e7447d
7
+ data.tar.gz: 595ee7159deff55287172552e8eedf055f14e2a17ec0c6ef694f8e553f45624026d6f4ba682fe112c39e7c6c1d46b97ac468630a86db3f6419aef6fb58656b91
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # PostalAddress
1
+ # International Postal Address Formatting
2
2
 
3
- International postal address formatting
3
+ International postal address formatting with HTML Microformats.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/max-power/postal_address.png)](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
@@ -1,3 +1,3 @@
1
1
  module Postal
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -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
- # 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
- # address.must_respond_to :"#{alias_name}="
88
- # #address.send(alias_name).must_equal address.state
89
- # end
90
- # 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
91
95
 
92
- # it "should respond to city aliases" do
93
- # [:locality].each do |alias_name|
94
- # #address.must_respond_to alias_name
95
- # address.must_respond_to :"#{alias_name}="
96
- # #address.send(alias_name).must_equal address.city
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>"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postal_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Melchert