postal_address 0.1.1 → 0.1.2

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: d917f51e33a1a55dcb4b1223df2626b3df0b5ec5
4
- data.tar.gz: 19521b23dd055ac878ed78e1e719c3bc927ca911
3
+ metadata.gz: 422cdf82f6d4e54433fab6605774d91be87b3b4c
4
+ data.tar.gz: c42be9ee3b3922263c53a1d8a15fed692578bd74
5
5
  SHA512:
6
- metadata.gz: 7fb11ea6efacab7cd36459679d643a52ed350ff34f3d3da9dde0cd432cfee89278c9592eed0127aab2d23a2d6c0a3c257080929a60cb5f98ea92e6fdc1235bee
7
- data.tar.gz: 835d1c41d90324bd5b167f1bda981561b3f87048dc73aa6d8482251390c5c74a235a0f85a0bcac3b897d18a907c380fb8022bf599dd0a3eaf0a329ae2dd30baa
6
+ metadata.gz: 29a813c8fd37b87a96782874d2a199e6ba75f6166d2d6a33bda8c5835f9d48d3d061bc1606bb94c98f8b51ebd2bca728c4d0f2c6ee0d2d9b74e03f8beee979e3
7
+ data.tar.gz: cda37c73bf10d4813414e12bc180ab8926c39eb916ad8eaf01f9ba6955f32679fe1007725ed57fec99bbd619f7dfea6180418f63f0ad4a45f5ce27e929a3f1b4
@@ -1,69 +1,71 @@
1
1
  # http://www.addressdoctor.com/en/countries-data/address-formats.html
2
2
 
3
-
4
3
  ---
5
- ae: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
4
+ de: &default "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
5
+ us: &default_with_state "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
6
+
7
+ ae: *default
6
8
  ar: "%{recipient}\n%{street}\n%{zip} %{city}\n%{state}\n%{country}"
7
- at: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
8
- au: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
9
- ba: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
10
- be: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
11
- bg: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
12
- bh: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
9
+ at: *default
10
+ au: *default_with_state
11
+ ba: *default
12
+ be: *default
13
+ bg: *default
14
+ bh: *default
13
15
  br: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
14
- ca: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
15
- ch: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
16
+ ca: *default_with_state
17
+ ch: *default
16
18
  cn: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
17
- cz: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
18
- de: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
19
+ cz: *default
20
+ #de: *default
19
21
  dk: "%{recipient}\n%{street}\n%{zip} %{city}\n%{state}\n%{country}"
20
- eg: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
22
+ eg: *default
21
23
  es: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
22
- fi: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
23
- fr: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
24
+ fi: *default
25
+ fr: *default
24
26
  gb: "%{recipient}\n%{street}\n%{city}\n%{state}\n%{zip}\n%{country}"
25
- gl: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
26
- gr: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
27
+ gl: *default
28
+ gr: *default
27
29
  hk: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
28
- hr: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
30
+ hr: *default
29
31
  hu: "%{recipient}\n%{city}\n%{street}\n%{zip}\n%{country}"
30
32
  id: "%{recipient}\n%{street}\n%{city}\n%{state} %{zip}\n%{country}"
31
- ie: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
32
- il: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
33
+ ie: *default_with_state
34
+ il: *default
33
35
  in: "%{recipient}\n%{street}\n%{state}\n%{city} %{zip}\n%{country}"
34
- is: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
36
+ is: *default
35
37
  it: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
36
- jo: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
38
+ jo: *default
37
39
  jp: "〒%{zip}\n%{state}%{city}%{street}\n%{recipient}\n%{country}"
38
40
  kr: "%{recipient}\n%{street}\n%{city} %{state}\n%{zip}\n%{country}"
39
41
  kw: "%{recipient}\n%{street}\n%{zip} %{city}\n%{state}\n%{country}"
40
- lb: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
41
- li: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
42
- lu: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
42
+ lb: *default
43
+ li: *default
44
+ lu: *default
43
45
  mk: "%{recipient}\n%{street}\n%{city} %{zip}\n%{country}"
44
46
  mx: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
45
- nc: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
46
- nl: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
47
- "no": "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
47
+ nc: *default
48
+ nl: *default
49
+ "no": *default
48
50
  nz: "%{recipient}\n%{street}\n%{state}\n%{city} %{zip}\n%{country}"
49
51
  om: "%{recipient}\n%{street}\n%{zip} %{city}\n%{state}\n%{country}"
50
52
  ph: "%{recipient}\n%{street} %{state}\n%{zip} %{city}\n%{country}"
51
53
  pl: "%{recipient}\n%{street}\n%{zip} %{city}\n%{state}\n%{country}"
52
54
  pt: "%{recipient}\n%{street}\n%{zip} %{city} %{state}\n%{country}"
53
- qa: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
54
- ro: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
55
+ qa: *default
56
+ ro: *default
55
57
  ru: "%{recipient}\n%{zip} %{city}\n%{street}\n%{country}"
56
- sa: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
57
- se: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
58
+ sa: *default
59
+ se: *default
58
60
  sg: "%{recipient}\n%{street}\n%{city} %{zip}\n%{country}"
59
- si: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
60
- sk: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
61
- sy: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
62
- th: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
63
- tr: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
64
- tw: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
61
+ si: *default
62
+ sk: *default
63
+ sy: *default
64
+ th: *default_with_state
65
+ tr: *default
66
+ tw: *default_with_state
65
67
  ua: "%{recipient}\n%{street}\n%{city} %{state}\n%{zip}\n%{country}"
66
- us: "%{recipient}\n%{street}\n%{city} %{state} %{zip}\n%{country}"
67
- ye: "%{recipient}\n%{street}\n%{zip} %{city}\n%{country}"
68
+ #us: *default_with_state
69
+ ye: *default
68
70
  yu: "%{recipient}\n%{street}\n%{zip} %{city}\n\n%{state}\n%{country}"
69
71
  za: "%{recipient}\n%{street}\n%{city}\n%{state}\n%{zip}\n%{country}"
@@ -6,7 +6,7 @@ module Postal
6
6
 
7
7
  def initialize(attrs={})
8
8
  attrs.each do |attr, value|
9
- self.public_send("#{attr}=", value) if self.respond_to?("#{attr}=")
9
+ self.public_send(:"#{attr}=", value) if self.respond_to?(:"#{attr}=")
10
10
  end if attrs
11
11
  end
12
12
 
@@ -19,7 +19,7 @@ module Postal
19
19
 
20
20
  def address_data
21
21
  super.each_with_object({}) do |(key, value), hash|
22
- hash[key] = content_tag(:span, value, itemprop: ItemProp[key])
22
+ hash[key] = value && content_tag(:span, value, itemprop: ItemProp[key])
23
23
  end
24
24
  end
25
25
 
@@ -13,12 +13,16 @@ module Postal
13
13
  private
14
14
 
15
15
  def address_data
16
- @address[:country] = nil if Postal.home_country?(@address[:country_code])
16
+ @address[:country] = nil if Postal.home_country? @address[:country_code]
17
17
  @address
18
18
  end
19
19
 
20
20
  def address_format
21
- Postal.address_formats[@address[:country_code]] || Postal.address_formats[@address[:state] ? 'us' : 'de']
21
+ Postal.address_formats[@address[:country_code]] || default_address_format
22
+ end
23
+
24
+ def default_address_format
25
+ Postal.address_formats[@address[:state] ? 'us' : 'de']
22
26
  end
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
- class PostalAddress
2
- VERSION = "0.1.1"
1
+ module Postal
2
+ VERSION = "0.1.2"
3
3
  end
@@ -5,7 +5,7 @@ require 'postal_address/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "postal_address"
8
- spec.version = PostalAddress::VERSION
8
+ spec.version = Postal::VERSION
9
9
  spec.authors = ["Kevin Melchert"]
10
10
  spec.email = ["kevin.melchert@gmail.com"]
11
11
  spec.description = %q{International postal address formatting}
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe PostalAddress do
4
+ describe Postal do
5
5
  it "should load the formats" do
6
6
  Postal.address_formats.wont_be :empty?
7
7
  Postal.address_formats.must_be_kind_of Hash
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.1.1
4
+ version: 0.1.2
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-18 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler