active_utils 3.1.0 → 3.2.0

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: d2cda56fd2a5bf93e2c5de4589e2ea474d4978fd
4
- data.tar.gz: 51036f2d8b672f7606d31edd54e406fe67f95273
3
+ metadata.gz: e8d8234345a5251007b9c809bbcc5e50b32ebebb
4
+ data.tar.gz: adcbab00d7199a94080f05752263ea58f20287c6
5
5
  SHA512:
6
- metadata.gz: d4af9fe1b18ce5a940e697c028732cec45c9101ada39a292166b1a758464cdd63e0cb8fe813f4b12c2f648845a618cef58cf87bae543693767d65abea31e805b
7
- data.tar.gz: d37119bee2e0fe398c9198f8843449387a2e381d84b7868a91ba812d5acfa9d997cc3d49cbaebbf05f1f1dded5cd01c17cea4b2afd3405b6ffc68316aa2e423b
6
+ metadata.gz: 04d5a842367ece5521c59fd297282c210c7badcf47b5f555e0ed16f941389455beca70049d8351771780cdd42b7ba944b0e39e2fc9713d6163b53942d51327e5
7
+ data.tar.gz: a79a175dd538dd1618759154c397ff5d29a979bad770ef60a56a80ced02276c3e03e03590dfb43bca93526ec67142ffbe70dbaa3c8d23a4771c76adba2c51f86
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ActiveUtils changelog
2
2
 
3
+ ### Version 3.2.0 (Oct. 13, 2015)
4
+ - Add #uses_postal_codes? to `ActiveUtils::Country`
5
+
3
6
  ### Version 3.1.0 (Sept. 30, 2015)
4
7
  - Use ActiveUtils::HTTPRequestError as base exception class
5
8
  - Add proxy address and port configuration
@@ -313,6 +313,16 @@ module ActiveUtils #:nodoc:
313
313
  { :alpha2 => 'AX', :name => 'Åland Islands', :alpha3 => 'ALA', :numeric => '248' }
314
314
  ]
315
315
 
316
+ COUNTRIES_THAT_DO_NOT_USE_POSTALCODES = %w(
317
+ QA BZ BS BF BJ AG AE AI AO AW HK
318
+ FJ ML JM ZW YE UG TV TT TG TD PA
319
+ CW
320
+ )
321
+
322
+ def uses_postal_codes?
323
+ !COUNTRIES_THAT_DO_NOT_USE_POSTALCODES.include?(code(:alpha2).value)
324
+ end
325
+
316
326
  def self.find(name)
317
327
  raise InvalidCountryCodeError, "Cannot lookup country for an empty name" if name.blank?
318
328
 
@@ -1,3 +1,3 @@
1
1
  module ActiveUtils
2
- VERSION = "3.1.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -65,4 +65,13 @@ class CountryTest < Minitest::Test
65
65
  assert_equal(country_names.sort, country_names)
66
66
  end
67
67
 
68
+ def test_canada_uses_postal_codes
69
+ canada = Country.find('Canada')
70
+ assert canada.uses_postal_codes?
71
+ end
72
+
73
+ def test_qatar_does_not_use_postal_codes
74
+ qatar = Country.find('Qatar')
75
+ refute qatar.uses_postal_codes?
76
+ end
68
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport