countries 6.0.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/countries/cache/countries.json +1 -1
- data/lib/countries/configuration.rb +6 -2
- data/lib/countries/country/class_methods.rb +1 -1
- data/lib/countries/country/country_subdivision_methods.rb +2 -14
- data/lib/countries/country/finder_methods.rb +2 -3
- data/lib/countries/country.rb +2 -2
- data/lib/countries/data/countries/AM.yaml +0 -1
- data/lib/countries/data/countries/AR.yaml +1 -0
- data/lib/countries/data/countries/CD.yaml +1 -0
- data/lib/countries/data/countries/CG.yaml +1 -0
- data/lib/countries/data/countries/CH.yaml +5 -3
- data/lib/countries/data/countries/ER.yaml +1 -1
- data/lib/countries/data/countries/ES.yaml +8 -0
- data/lib/countries/data/countries/FI.yaml +1 -1
- data/lib/countries/data/countries/FJ.yaml +0 -1
- data/lib/countries/data/countries/GB.yaml +1 -0
- data/lib/countries/data/countries/MM.yaml +1 -0
- data/lib/countries/data/countries/PY.yaml +1 -1
- data/lib/countries/data/countries/UZ.yaml +0 -1
- data/lib/countries/data/subdivisions/GB.yaml +1 -1
- data/lib/countries/data.rb +2 -2
- data/lib/countries/sources/cldr/subdivision_updater.rb +1 -1
- data/lib/countries/sources.rb +5 -5
- data/lib/countries/translations.rb +1 -1
- data/lib/countries/version.rb +1 -1
- metadata +4 -4
@@ -19,13 +19,17 @@ module ISO3166
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class Configuration
|
22
|
-
attr_accessor :
|
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 =
|
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
|
-
|
15
|
-
|
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
|
-
|
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
|
data/lib/countries/country.rb
CHANGED
@@ -9,13 +9,13 @@ module ISO3166
|
|
9
9
|
include CountrySubdivisionMethods
|
10
10
|
attr_reader :data
|
11
11
|
|
12
|
-
ISO3166::DEFAULT_COUNTRY_HASH.
|
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'].
|
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
|
@@ -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:
|
66
|
+
standard: 8.1
|
65
67
|
reduced:
|
66
|
-
- 2.
|
67
|
-
- 3.
|
68
|
+
- 2.6
|
69
|
+
- 3.8
|
68
70
|
super_reduced:
|
69
71
|
parking:
|
70
72
|
world_region: EMEA
|
data/lib/countries/data.rb
CHANGED
@@ -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
|
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)
|
data/lib/countries/sources.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
3
|
+
require_relative 'sources/local/cached_loader'
|
4
|
+
require_relative 'sources/local/subdivision'
|
5
5
|
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
8
|
-
require_relative '
|
6
|
+
require_relative 'sources/cldr/downloader'
|
7
|
+
require_relative 'sources/cldr/subdivision'
|
8
|
+
require_relative 'sources/cldr/subdivision_updater'
|
data/lib/countries/version.rb
CHANGED
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:
|
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-
|
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.
|
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.
|
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.
|