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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f83668dafff4ede2c9d49c1c711cb5867167bd44
4
- data.tar.gz: 535bb43703e2f420c0f5177973ae95845d0270dc
3
+ metadata.gz: 709f977bc0f278516ed857f4180eea486b82f8a2
4
+ data.tar.gz: bd3e09740ea53e45cfebbecec53dddea5b08a306
5
5
  SHA512:
6
- metadata.gz: dad66c7a372952a9ba32058e3a9bddbbe1f5c86704fd68d358ea304f3b6ce533025c5b06083f190ab523d6566f235a83f8ffacab5abea4421f2fd20f04ab0352
7
- data.tar.gz: dc0a4a98c5b98429e355bbc43c765544f62ddd304ff7d115d2e67fbba19365ae2bab261cc9e50b9227a9f7f4ac51bace01f1f61197d6f5003e12e37eab29d9c5
6
+ metadata.gz: a9584eae3902a14d69ee379d21c32daeae08c31d552ee50f9910aa14b2561652b03504cbf6c9b816d7d0f1dbd406612fa9ac7300040db332bd2ec579e73adb04
7
+ data.tar.gz: ff909cfda68bf7bafa7486e3ce53b7bf74d8c0422073eaa39fe2da337d21c21f64d52a5d6b972674517cc0ed668855f82b66f49acac0efe97659d8aae5448bb5
@@ -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 ||= load_yaml('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 ||= load_yaml('country_names')
25
+ @country_names ||= YAML.load_file(path_for(:country_names))
25
26
  end
26
27
 
27
28
  private
28
29
 
29
- def load_yaml(filename)
30
- YAML.load_file(File.expand_path("../data/#{filename}.yml", File.dirname(__FILE__)))
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 do |field, value|
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
@@ -1,7 +1,7 @@
1
1
  module Postal
2
2
  module AddressFormatter
3
3
  class Text
4
- # expects any hash with the fields names of address
4
+ # expects any hash with the 7 keys from Postal::Address::Fields
5
5
  def initialize(address)
6
6
  @address = address
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Postal
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -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
- [: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
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.2
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-19 00:00:00.000000000 Z
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler