countries 6.0.1 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,13 +19,17 @@ module ISO3166
19
19
  end
20
20
 
21
21
  class Configuration
22
- attr_accessor :locales, :loaded_locales
22
+ attr_accessor :loaded_locales
23
+ attr_writer :locales
23
24
 
24
25
  def initialize
25
- @locales = default_locales
26
26
  @loaded_locales = []
27
27
  end
28
28
 
29
+ def locales
30
+ @locales ||= default_locales
31
+ end
32
+
29
33
  # Enables the integration with the {Money}[https://github.com/RubyMoney/money] gem
30
34
  #
31
35
  # Please note that it requires you to add "money" gem to your gemfile.
@@ -34,7 +34,7 @@ module ISO3166
34
34
 
35
35
  def all_names_with_codes(locale = 'en')
36
36
  Country.all.map do |c|
37
- lc = (c.translation(locale) || c.iso_short_name)
37
+ lc = c.translation(locale) || c.iso_short_name
38
38
  [lc.respond_to?('html_safe') ? lc.html_safe : lc, c.alpha2]
39
39
  end.sort
40
40
  end
@@ -11,8 +11,8 @@ module ISO3166
11
11
  end
12
12
 
13
13
  def subdivision_for_string?(subdivision_str)
14
- !subdivisions.transform_values(&:translations)
15
- .select { |k, v| subdivision_str == k || v.values.include?(subdivision_str) }.empty?
14
+ subdivisions.transform_values(&:translations)
15
+ .any? { |k, v| subdivision_str == k || v.values.include?(subdivision_str) }
16
16
  end
17
17
 
18
18
  # +true+ if this Country has any Subdivisions.
@@ -61,18 +61,6 @@ module ISO3166
61
61
  subdivisions.map { |_k, v| v.translations[locale] || v.name }
62
62
  end
63
63
 
64
- def states
65
- if RUBY_VERSION =~ /^3\.\d\.\d/
66
- warn 'DEPRECATION WARNING: The Country#states method has been deprecated and will be removed in 6.0. Please use Country#subdivisions instead.',
67
- uplevel: 1, category: :deprecated
68
- else
69
- warn 'DEPRECATION WARNING: The Country#states method has been deprecated and will be removed in 6.0. Please use Country#subdivisions instead.',
70
- uplevel: 1
71
- end
72
-
73
- subdivisions
74
- end
75
-
76
64
  private
77
65
 
78
66
  def humanize_string(str)
@@ -29,8 +29,8 @@ module ISO3166
29
29
 
30
30
  def method_missing(method_name, *arguments)
31
31
  matches = method_name.to_s.match(FIND_BY_REGEX)
32
- return_all = matches[1]
33
32
  super unless matches
33
+ return_all = matches[1]
34
34
 
35
35
  countries = find_by(matches[3], arguments[0], matches[2])
36
36
  return_all ? countries : countries.last
@@ -72,8 +72,7 @@ module ISO3166
72
72
  end
73
73
 
74
74
  def searchable_attributes
75
- # Add name and names until we complete the deprecation of the finders
76
- instance_methods - UNSEARCHABLE_METHODS + %i[name names any_name]
75
+ instance_methods - UNSEARCHABLE_METHODS + %i[any_name]
77
76
  end
78
77
  end
79
78
  end
@@ -9,13 +9,13 @@ module ISO3166
9
9
  include CountrySubdivisionMethods
10
10
  attr_reader :data
11
11
 
12
- ISO3166::DEFAULT_COUNTRY_HASH.each do |method_name, _type|
12
+ ISO3166::DEFAULT_COUNTRY_HASH.each_key do |method_name|
13
13
  define_method method_name do
14
14
  data[method_name.to_s]
15
15
  end
16
16
  end
17
17
 
18
- ISO3166::DEFAULT_COUNTRY_HASH['geo'].each do |method_name, _type|
18
+ ISO3166::DEFAULT_COUNTRY_HASH['geo'].each_key do |method_name|
19
19
  define_method method_name do
20
20
  data['geo'][method_name.to_s]
21
21
  end
@@ -27,7 +27,6 @@ AM:
27
27
  iso_short_name: Armenia
28
28
  languages_official:
29
29
  - hy
30
- - ru
31
30
  languages_spoken:
32
31
  - hy
33
32
  - ru
@@ -38,6 +38,7 @@ AR:
38
38
  languages_spoken:
39
39
  - es
40
40
  - gn
41
+ - qu
41
42
  national_destination_code_lengths:
42
43
  - 2
43
44
  national_number_lengths:
@@ -58,4 +58,5 @@ CD:
58
58
  - Congo (The Democratic Republic Of The)
59
59
  - Democratic Republic of the Congo
60
60
  - Congo, Democratic Republic of
61
+ - Congo (Kinshasa)
61
62
  world_region: EMEA
@@ -49,4 +49,5 @@ CG:
49
49
  - コンゴ共和国
50
50
  - Congo [Republiek]
51
51
  - Congo, Republic of
52
+ - Congo (Brazzaville)
52
53
  world_region: EMEA
@@ -35,10 +35,12 @@ CH:
35
35
  - de
36
36
  - fr
37
37
  - it
38
+ - rm
38
39
  languages_spoken:
39
40
  - de
40
41
  - fr
41
42
  - it
43
+ - rm
42
44
  national_destination_code_lengths:
43
45
  - 2
44
46
  national_number_lengths:
@@ -61,10 +63,10 @@ CH:
61
63
  - スイス
62
64
  - Zwitserland
63
65
  vat_rates:
64
- standard: 7.7
66
+ standard: 8.1
65
67
  reduced:
66
- - 2.5
67
- - 3.7
68
+ - 2.6
69
+ - 3.8
68
70
  super_reduced:
69
71
  parking:
70
72
  world_region: EMEA
@@ -4,7 +4,7 @@ ER:
4
4
  alpha3: ERI
5
5
  continent: Africa
6
6
  country_code: '291'
7
- currency_code: ETB
7
+ currency_code: ERN
8
8
  distance_unit: KM
9
9
  gec: ER
10
10
  geo:
@@ -37,6 +37,14 @@ ES:
37
37
  - es
38
38
  languages_spoken:
39
39
  - es
40
+ - ca
41
+ - gl
42
+ - eu
43
+ - an
44
+ - ast
45
+ - fax
46
+ - rif
47
+ - rmq
40
48
  national_destination_code_lengths:
41
49
  - 2
42
50
  national_number_lengths:
@@ -58,7 +58,7 @@ FI:
58
58
  - Finlandia
59
59
  - フィンランド
60
60
  vat_rates:
61
- standard: 24
61
+ standard: 25.5
62
62
  reduced:
63
63
  - 10
64
64
  - 14
@@ -29,7 +29,6 @@ FJ:
29
29
  - en
30
30
  - fj
31
31
  - hi
32
- - ur
33
32
  languages_spoken:
34
33
  - en
35
34
  - fj
@@ -71,6 +71,7 @@ GB:
71
71
  - Velká Británie
72
72
  - İngiltere
73
73
  - Великобританія
74
+ - Great Britain
74
75
  vat_rates:
75
76
  standard: 20
76
77
  reduced:
@@ -46,4 +46,5 @@ MM:
46
46
  unofficial_names:
47
47
  - Myanmar (Burma)
48
48
  - ミャンマー
49
+ - Burma
49
50
  world_region: APAC
@@ -39,7 +39,7 @@ PY:
39
39
  nationality: Paraguayan
40
40
  number: '600'
41
41
  postal_code: true
42
- postal_code_format: "\\d{4}"
42
+ postal_code_format: "\\d{6}"
43
43
  region: Americas
44
44
  start_of_week: monday
45
45
  subregion: South America
@@ -27,7 +27,6 @@ UZ:
27
27
  iso_short_name: Uzbekistan
28
28
  languages_official:
29
29
  - uz
30
- - ru
31
30
  languages_spoken:
32
31
  - uz
33
32
  - ru
@@ -9029,7 +9029,7 @@ PTE:
9029
9029
  max_latitude: 52.6637708
9030
9030
  max_longitude: -0.1032429
9031
9031
  translations:
9032
- en: Peter
9032
+ en: Peterborough
9033
9033
  af: Peterborough
9034
9034
  ar: بيتربرة
9035
9035
  bn: পিটারবার্গ
@@ -98,8 +98,8 @@ module ISO3166
98
98
  end
99
99
  end
100
100
 
101
- def synchronized(&block)
102
- @mutex.synchronize(&block)
101
+ def synchronized(&)
102
+ @mutex.synchronize(&)
103
103
  end
104
104
 
105
105
  def load_required?
@@ -24,7 +24,7 @@ module Sources
24
24
  last_country_code_seen = nil
25
25
 
26
26
  subdivisions.each_with_index do |subdivision, index|
27
- subdivision = Sources::CLDR::Subdivision.new(language_code: language_code, xml: subdivision)
27
+ subdivision = Sources::CLDR::Subdivision.new(language_code:, xml: subdivision)
28
28
  data = @loader.load(subdivision.country_code)
29
29
  data[subdivision.code] ||= {}
30
30
  data[subdivision.code] = data[subdivision.code].deep_merge(subdivision.to_h)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './sources/local/cached_loader'
4
- require_relative './sources/local/subdivision'
3
+ require_relative 'sources/local/cached_loader'
4
+ require_relative 'sources/local/subdivision'
5
5
 
6
- require_relative './sources/cldr/downloader'
7
- require_relative './sources/cldr/subdivision'
8
- require_relative './sources/cldr/subdivision_updater'
6
+ require_relative 'sources/cldr/downloader'
7
+ require_relative 'sources/cldr/subdivision'
8
+ require_relative 'sources/cldr/subdivision_updater'
@@ -7,7 +7,7 @@ module ISO3166
7
7
  # to +pt+ to prevent from showing nil values
8
8
  class Translations < Hash
9
9
  def [](locale)
10
- super(locale) || super(locale.to_s.sub(/-.*/, ''))
10
+ super || super(locale.to_s.sub(/-.*/, ''))
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Countries
4
- VERSION = '6.0.1'
4
+ VERSION = '7.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: countries
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Robinson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-05-18 00:00:00.000000000 Z
14
+ date: 2024-09-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: unaccent
@@ -849,14 +849,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
849
849
  requirements:
850
850
  - - ">="
851
851
  - !ruby/object:Gem::Version
852
- version: '3.0'
852
+ version: '3.1'
853
853
  required_rubygems_version: !ruby/object:Gem::Requirement
854
854
  requirements:
855
855
  - - ">="
856
856
  - !ruby/object:Gem::Version
857
857
  version: '0'
858
858
  requirements: []
859
- rubygems_version: 3.5.9
859
+ rubygems_version: 3.5.16
860
860
  signing_key:
861
861
  specification_version: 4
862
862
  summary: Gives you a country object full of all sorts of useful information.