postal_address 0.0.4 → 0.0.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: ee5850c58fca03056e84cb446f8b9a30bb8f1a41
4
- data.tar.gz: fae24abff445bb0366ed0db87e39ba2684192e52
3
+ metadata.gz: 2499c8eb67851e9f520f4617be1237950cd8d1f1
4
+ data.tar.gz: 9ad9cb07b425aa9bb65953658811e292b8283ec9
5
5
  SHA512:
6
- metadata.gz: ffc4b57e2ebbc450bfb3f2fc5f57bdc8985c5e48359998f14e793219fc74338710644a0c0bd94bb256cb79a9556fc43b7825dc07320eff5c9f81e04b0b49d9d3
7
- data.tar.gz: 97bb83b15043f907e685f870114c647c4aa8af31d9bbf93ad8349181b02eeaf5d3f041bf32e08370a72efc9197e8f5eb40e831ed845f40bfc5104919223ee200
6
+ metadata.gz: 1cc7ca58f44d13de08c8965b43b276a5c01ed95ab1b9e5838132b359bff4eb432128fa06a08e43863e78b0a2963276f6f133a0f477a68f4a517f898ddcb8a173
7
+ data.tar.gz: fccf1064bc4ad2348a1ae747d56d22c1872fe4e06201343055b02f856d4d8d2da976d4d1c6c955f1a6a797099364efeaf75d89fba1734217f8588a154dc29f93
@@ -9,11 +9,11 @@ class PostalAddress
9
9
  end
10
10
 
11
11
  def formats
12
- @formats ||= YAML.load_file("data/address_formats.yml")
12
+ @formats ||= load_yaml('address_formats')
13
13
  end
14
14
 
15
15
  def country_names
16
- @country_names ||= YAML.load_file("data/country_names.yml")
16
+ @country_names ||= load_yaml('country_names')
17
17
  end
18
18
 
19
19
  def attributes
@@ -32,5 +32,9 @@ class PostalAddress
32
32
  def alias_attribute_writer(original, aliases)
33
33
  aliases.each { |name| alias_method :"#{name}=", :"#{original}=" }
34
34
  end
35
+
36
+ def load_yaml(filename)
37
+ YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "data", "#{filename}.yml"))
38
+ end
35
39
  end
36
40
  end
@@ -26,6 +26,10 @@ class PostalAddress
26
26
  def country
27
27
  @country = self.class.country_names[country_code] unless in_home_country?
28
28
  end
29
+
30
+ def in_home_country?
31
+ self.class.home_country == country_code
32
+ end
29
33
 
30
34
  private
31
35
 
@@ -37,10 +41,6 @@ class PostalAddress
37
41
  self.class.formats[country_code] || self.class.formats[state ? 'us' : 'de']
38
42
  end
39
43
 
40
- def in_home_country?
41
- self.class.home_country == country_code
42
- end
43
-
44
44
  def attributes(html=false)
45
45
  self.class.attributes.inject({}) do |hash, (key, attribute)|
46
46
  value = public_send(key)
@@ -1,3 +1,3 @@
1
1
  class PostalAddress
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Melchert
@@ -117,3 +117,4 @@ test_files:
117
117
  - spec/postal_address_spec.rb
118
118
  - spec/spec_helper.rb
119
119
  - spec/virtus_integration_spec.rb
120
+ has_rdoc: