countries 4.2.3 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/tests.yml +3 -7
- data/.rubocop.yml +40 -1
- data/.rubocop_todo.yml +8 -41
- data/CHANGELOG.md +21 -2
- data/Gemfile +5 -3
- data/README.markdown +48 -60
- data/Rakefile +13 -31
- data/UPGRADE.md +26 -0
- data/bin/console +1 -0
- data/countries.gemspec +7 -5
- data/lib/countries/cache/countries.json +1 -1
- data/lib/countries/cache/locales/en.json +1 -1
- data/lib/countries/configuration.rb +2 -0
- data/lib/countries/country/class_methods.rb +12 -97
- data/lib/countries/country/currency_methods.rb +2 -0
- data/lib/countries/country/emoji.rb +2 -3
- data/lib/countries/country/finder_methods.rb +81 -0
- data/lib/countries/country.rb +3 -40
- data/lib/countries/data/countries/KN.yaml +0 -1
- data/lib/countries/data/subdivisions/MX.yaml +3 -15
- data/lib/countries/data/subdivisions/PT.yaml +13 -13
- data/lib/countries/data/translation_corrections.yaml +2 -0
- data/lib/countries/data.rb +34 -37
- data/lib/countries/global.rb +2 -0
- data/lib/countries/iso3166.rb +3 -0
- data/lib/countries/kwarg_struct.rb +2 -0
- data/lib/countries/mongoid.rb +2 -0
- data/lib/countries/sources/cldr/downloader.rb +8 -8
- data/lib/countries/sources/cldr/subdivision.rb +3 -0
- data/lib/countries/sources/cldr/subdivision_updater.rb +23 -17
- data/lib/countries/sources/local/cached_loader.rb +3 -0
- data/lib/countries/sources/local/subdivision.rb +5 -2
- data/lib/countries/sources.rb +2 -0
- data/lib/countries/structure.rb +1 -1
- data/lib/countries/subdivision.rb +2 -0
- data/lib/countries/tasks/geocoding.rake +15 -6
- data/lib/countries/tasks/postal_codes.rake +5 -3
- data/lib/countries/timezones.rb +5 -2
- data/lib/countries/translations.rb +2 -0
- data/lib/countries/version.rb +3 -1
- data/lib/countries.rb +2 -0
- data/spec/00_global_spec.rb +2 -0
- data/spec/configuration_spec.rb +11 -5
- data/spec/country_spec.rb +71 -22
- data/spec/data_spec.rb +24 -18
- data/spec/mongoid_spec.rb +2 -2
- data/spec/perf_spec.rb +16 -16
- data/spec/spec_helper.rb +2 -0
- data/spec/subdivision_spec.rb +6 -4
- data/spec/thread_safety_spec.rb +4 -3
- data/spec/timezone_spec.rb +2 -0
- metadata +15 -12
- data/lib/countries/setup.rb +0 -18
@@ -1 +1 @@
|
|
1
|
-
{"AW":"Aruba","AF":"Afghanistan","AO":"Angola","AI":"Anguilla","AX":"Åland Islands","AL":"Albania","AD":"Andorra","AE":"United Arab Emirates","AR":"Argentina","AM":"Armenia","AS":"American Samoa","AQ":"Antarctica","TF":"French Southern Territories","AG":"Antigua and Barbuda","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BI":"Burundi","BE":"Belgium","BJ":"Benin","BQ":"Bonaire, Sint Eustatius and Saba","BF":"Burkina Faso","BD":"Bangladesh","BG":"Bulgaria","BH":"Bahrain","BS":"Bahamas","BA":"Bosnia and Herzegovina","BL":"Saint Barthélemy","BY":"Belarus","BZ":"Belize","BM":"Bermuda","BO":"Bolivia","BR":"Brazil","BB":"Barbados","BN":"Brunei Darussalam","BT":"Bhutan","BV":"Bouvet Island","BW":"Botswana","CF":"Central African Republic","CA":"Canada","CC":"Cocos (Keeling) Islands","CH":"Switzerland","CL":"Chile","CN":"China","CI":"Côte d'Ivoire","CM":"Cameroon","CD":"Congo, The Democratic Republic of the","CG":"Congo","CK":"Cook Islands","CO":"Colombia","KM":"Comoros","CV":"Cabo Verde","CR":"Costa Rica","CU":"Cuba","CW":"Curaçao","CX":"Christmas Island","KY":"Cayman Islands","CY":"Cyprus","CZ":"Czechia","DE":"Germany","DJ":"Djibouti","DM":"Dominica","DK":"Denmark","DO":"Dominican Republic","DZ":"Algeria","EC":"Ecuador","EG":"Egypt","ER":"Eritrea","EH":"Western Sahara","ES":"Spain","EE":"Estonia","ET":"Ethiopia","FI":"Finland","FJ":"Fiji","FK":"Falkland Islands (Malvinas)","FR":"France","FO":"Faroe Islands","FM":"Micronesia, Federated States of","GA":"Gabon","GB":"United Kingdom","GE":"Georgia","GG":"Guernsey","GH":"Ghana","GI":"Gibraltar","GN":"Guinea","GP":"Guadeloupe","GM":"Gambia","GW":"Guinea-Bissau","GQ":"Equatorial Guinea","GR":"Greece","GD":"Grenada","GL":"Greenland","GT":"Guatemala","GF":"French Guiana","GU":"Guam","GY":"Guyana","HK":"Hong Kong","HM":"Heard Island and McDonald Islands","HN":"Honduras","HR":"Croatia","HT":"Haiti","HU":"Hungary","ID":"Indonesia","IM":"Isle of Man","IN":"India","IO":"British Indian Ocean Territory","IE":"Ireland","IR":"Iran
|
1
|
+
{"AW":"Aruba","AF":"Afghanistan","AO":"Angola","AI":"Anguilla","AX":"Åland Islands","AL":"Albania","AD":"Andorra","AE":"United Arab Emirates","AR":"Argentina","AM":"Armenia","AS":"American Samoa","AQ":"Antarctica","TF":"French Southern Territories","AG":"Antigua and Barbuda","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BI":"Burundi","BE":"Belgium","BJ":"Benin","BQ":"Bonaire, Sint Eustatius and Saba","BF":"Burkina Faso","BD":"Bangladesh","BG":"Bulgaria","BH":"Bahrain","BS":"Bahamas","BA":"Bosnia and Herzegovina","BL":"Saint Barthélemy","BY":"Belarus","BZ":"Belize","BM":"Bermuda","BO":"Bolivia","BR":"Brazil","BB":"Barbados","BN":"Brunei Darussalam","BT":"Bhutan","BV":"Bouvet Island","BW":"Botswana","CF":"Central African Republic","CA":"Canada","CC":"Cocos (Keeling) Islands","CH":"Switzerland","CL":"Chile","CN":"China","CI":"Côte d'Ivoire","CM":"Cameroon","CD":"Congo, The Democratic Republic of the","CG":"Congo","CK":"Cook Islands","CO":"Colombia","KM":"Comoros","CV":"Cabo Verde","CR":"Costa Rica","CU":"Cuba","CW":"Curaçao","CX":"Christmas Island","KY":"Cayman Islands","CY":"Cyprus","CZ":"Czechia","DE":"Germany","DJ":"Djibouti","DM":"Dominica","DK":"Denmark","DO":"Dominican Republic","DZ":"Algeria","EC":"Ecuador","EG":"Egypt","ER":"Eritrea","EH":"Western Sahara","ES":"Spain","EE":"Estonia","ET":"Ethiopia","FI":"Finland","FJ":"Fiji","FK":"Falkland Islands (Malvinas)","FR":"France","FO":"Faroe Islands","FM":"Micronesia, Federated States of","GA":"Gabon","GB":"United Kingdom","GE":"Georgia","GG":"Guernsey","GH":"Ghana","GI":"Gibraltar","GN":"Guinea","GP":"Guadeloupe","GM":"Gambia","GW":"Guinea-Bissau","GQ":"Equatorial Guinea","GR":"Greece","GD":"Grenada","GL":"Greenland","GT":"Guatemala","GF":"French Guiana","GU":"Guam","GY":"Guyana","HK":"Hong Kong","HM":"Heard Island and McDonald Islands","HN":"Honduras","HR":"Croatia","HT":"Haiti","HU":"Hungary","ID":"Indonesia","IM":"Isle of Man","IN":"India","IO":"British Indian Ocean Territory","IE":"Ireland","IR":"Iran","IQ":"Iraq","IS":"Iceland","IL":"Israel","IT":"Italy","JM":"Jamaica","JE":"Jersey","JO":"Jordan","JP":"Japan","KZ":"Kazakhstan","KE":"Kenya","KG":"Kyrgyzstan","KH":"Cambodia","KI":"Kiribati","KN":"Saint Kitts and Nevis","KR":"South Korea","KW":"Kuwait","LA":"Lao People's Democratic Republic","LB":"Lebanon","LR":"Liberia","LY":"Libya","LC":"Saint Lucia","LI":"Liechtenstein","LK":"Sri Lanka","LS":"Lesotho","LT":"Lithuania","LU":"Luxembourg","LV":"Latvia","MO":"Macao","MF":"Saint Martin (French part)","MA":"Morocco","MC":"Monaco","MD":"Moldova","MG":"Madagascar","MV":"Maldives","MX":"Mexico","MH":"Marshall Islands","MK":"North Macedonia","ML":"Mali","MT":"Malta","MM":"Myanmar","ME":"Montenegro","MN":"Mongolia","MP":"Northern Mariana Islands","MZ":"Mozambique","MR":"Mauritania","MS":"Montserrat","MQ":"Martinique","MU":"Mauritius","MW":"Malawi","MY":"Malaysia","YT":"Mayotte","NA":"Namibia","NC":"New Caledonia","NE":"Niger","NF":"Norfolk Island","NG":"Nigeria","NI":"Nicaragua","NU":"Niue","NL":"Netherlands","NO":"Norway","NP":"Nepal","NR":"Nauru","NZ":"New Zealand","OM":"Oman","PK":"Pakistan","PA":"Panama","PN":"Pitcairn","PE":"Peru","PH":"Philippines","PW":"Palau","PG":"Papua New Guinea","PL":"Poland","PR":"Puerto Rico","KP":"North Korea","PT":"Portugal","PY":"Paraguay","PS":"Palestine, State of","PF":"French Polynesia","QA":"Qatar","RE":"Réunion","RO":"Romania","RU":"Russian Federation","RW":"Rwanda","SA":"Saudi Arabia","SD":"Sudan","SN":"Senegal","SG":"Singapore","GS":"South Georgia and the South Sandwich Islands","SH":"Saint Helena, Ascension and Tristan da Cunha","SJ":"Svalbard and Jan Mayen","SB":"Solomon Islands","SL":"Sierra Leone","SV":"El Salvador","SM":"San Marino","SO":"Somalia","PM":"Saint Pierre and Miquelon","RS":"Serbia","SS":"South Sudan","ST":"Sao Tome and Principe","SR":"Suriname","SK":"Slovakia","SI":"Slovenia","SE":"Sweden","SZ":"Eswatini","SX":"Sint Maarten (Dutch part)","SC":"Seychelles","SY":"Syrian Arab Republic","TC":"Turks and Caicos Islands","TD":"Chad","TG":"Togo","TH":"Thailand","TJ":"Tajikistan","TK":"Tokelau","TM":"Turkmenistan","TL":"Timor-Leste","TO":"Tonga","TT":"Trinidad and Tobago","TN":"Tunisia","TR":"Turkey","TV":"Tuvalu","TW":"Taiwan","TZ":"Tanzania","UG":"Uganda","UA":"Ukraine","UM":"United States Minor Outlying Islands","UY":"Uruguay","US":"United States","UZ":"Uzbekistan","VA":"Holy See (Vatican City State)","VC":"Saint Vincent and the Grenadines","VE":"Venezuela","VG":"Virgin Islands, British","VI":"Virgin Islands, U.S.","VN":"Vietnam","VU":"Vanuatu","WF":"Wallis and Futuna","WS":"Samoa","YE":"Yemen","ZA":"South Africa","ZM":"Zambia","ZW":"Zimbabwe"}
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sixarm_ruby_unaccent'
|
2
4
|
|
3
5
|
module ISO3166
|
4
6
|
UNSEARCHABLE_METHODS = [:translations].freeze
|
5
7
|
|
6
|
-
def self
|
8
|
+
def self.Country(country_data_or_country)
|
7
9
|
case country_data_or_country
|
8
10
|
when ISO3166::Country
|
9
11
|
country_data_or_country
|
@@ -15,9 +17,6 @@ module ISO3166
|
|
15
17
|
end
|
16
18
|
|
17
19
|
module CountryClassMethods
|
18
|
-
FIND_BY_REGEX = /^find_(all_)?(country_|countries_)?by_(.+)/
|
19
|
-
SEARCH_TERM_FILTER_REGEX = /\(|\)|\[\]|,/
|
20
|
-
|
21
20
|
def new(country_data)
|
22
21
|
super if country_data.is_a?(Hash) || codes.include?(country_data.to_s.upcase)
|
23
22
|
end
|
@@ -33,10 +32,6 @@ module ISO3166
|
|
33
32
|
|
34
33
|
alias countries all
|
35
34
|
|
36
|
-
def all_translated(locale = 'en')
|
37
|
-
translations(locale).values
|
38
|
-
end
|
39
|
-
|
40
35
|
def all_names_with_codes(locale = 'en')
|
41
36
|
Country.all.map do |c|
|
42
37
|
lc = (c.translation(locale) || c.iso_short_name)
|
@@ -50,6 +45,10 @@ module ISO3166
|
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
48
|
+
def all_translated(locale = 'en')
|
49
|
+
translations(locale).values
|
50
|
+
end
|
51
|
+
|
53
52
|
def translations(locale = 'en')
|
54
53
|
i18n_data_countries = I18nData.countries(locale.upcase)
|
55
54
|
|
@@ -62,54 +61,6 @@ module ISO3166
|
|
62
61
|
i18n_data_countries.merge(custom_countries)
|
63
62
|
end
|
64
63
|
|
65
|
-
def search(query)
|
66
|
-
country = new(query.to_s.upcase)
|
67
|
-
country && country.valid? ? country : nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def [](query)
|
71
|
-
search(query)
|
72
|
-
end
|
73
|
-
|
74
|
-
def method_missing(method_name, *arguments)
|
75
|
-
matches = method_name.to_s.match(FIND_BY_REGEX)
|
76
|
-
return_all = matches[1]
|
77
|
-
super unless matches
|
78
|
-
|
79
|
-
if matches[3] == 'names'
|
80
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
81
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
82
|
-
else
|
83
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
countries = find_by(matches[3], arguments[0], matches[2])
|
88
|
-
return_all ? countries : countries.last
|
89
|
-
end
|
90
|
-
|
91
|
-
def respond_to_missing?(method_name, include_private = false)
|
92
|
-
matches = method_name.to_s.match(FIND_BY_REGEX)
|
93
|
-
if matches && matches[3]
|
94
|
-
instance_methods.include?(matches[3].to_sym)
|
95
|
-
else
|
96
|
-
super
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def find_all_by(attribute, val)
|
101
|
-
attributes, lookup_value = parse_attributes(attribute, val)
|
102
|
-
|
103
|
-
ISO3166::Data.cache.select do |_, v|
|
104
|
-
country = Country.new(v)
|
105
|
-
attributes.any? do |attr|
|
106
|
-
Array(country.send(attr)).any? do |n|
|
107
|
-
lookup_value === cached(n) { parse_value(n) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
64
|
def subdivisions(alpha2)
|
114
65
|
@subdivisions ||= {}
|
115
66
|
@subdivisions[alpha2] ||= create_subdivisions(subdivision_data(alpha2))
|
@@ -124,51 +75,14 @@ module ISO3166
|
|
124
75
|
|
125
76
|
protected
|
126
77
|
|
127
|
-
def strip_accents(
|
128
|
-
if
|
129
|
-
Regexp.new(
|
78
|
+
def strip_accents(string)
|
79
|
+
if string.is_a?(Regexp)
|
80
|
+
Regexp.new(string.source.unaccent, 'i')
|
130
81
|
else
|
131
|
-
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def parse_attributes(attribute, val)
|
136
|
-
raise "Invalid attribute name '#{attribute}'" unless searchable_attribute?(attribute.to_sym)
|
137
|
-
|
138
|
-
attributes = Array(attribute.to_s)
|
139
|
-
if attribute.to_s == 'name'
|
140
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
141
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
142
|
-
else
|
143
|
-
warn "DEPRECATION WARNING: 'find_by_name' and 'find_*_by_name' methods are deprecated, please refer to the README file for more information on this change.", uplevel: 1
|
144
|
-
end
|
145
|
-
# 'find_by_name' and 'find_*_by_name' will be changed for 5.0
|
146
|
-
# The addition of 'iso_short_name' here ensures the behaviour of 4.1 is kept for 4.2
|
147
|
-
attributes = %w[iso_short_name unofficial_names translated_names]
|
148
|
-
end
|
149
|
-
|
150
|
-
[attributes, parse_value(val)]
|
151
|
-
end
|
152
|
-
|
153
|
-
def searchable_attribute?(attribute)
|
154
|
-
searchable_attributes.include?(attribute.to_sym)
|
155
|
-
end
|
156
|
-
|
157
|
-
def searchable_attributes
|
158
|
-
instance_methods - UNSEARCHABLE_METHODS
|
159
|
-
end
|
160
|
-
|
161
|
-
def find_by(attribute, value, obj = nil)
|
162
|
-
find_all_by(attribute.downcase, value).map do |country|
|
163
|
-
obj.nil? ? country : new(country.last)
|
82
|
+
string.to_s.unaccent.downcase
|
164
83
|
end
|
165
84
|
end
|
166
85
|
|
167
|
-
def parse_value(value)
|
168
|
-
value = value.gsub(SEARCH_TERM_FILTER_REGEX, '') if value.respond_to?(:gsub)
|
169
|
-
strip_accents(value)
|
170
|
-
end
|
171
|
-
|
172
86
|
def subdivision_data(alpha2)
|
173
87
|
file = subdivision_file_path(alpha2)
|
174
88
|
File.exist?(file) ? YAML.load_file(file) : {}
|
@@ -190,6 +104,7 @@ module ISO3166
|
|
190
104
|
def cached(value)
|
191
105
|
@_parsed_values_cache ||= {}
|
192
106
|
return @_parsed_values_cache[value] if @_parsed_values_cache[value]
|
107
|
+
|
193
108
|
@_parsed_values_cache[value] = yield
|
194
109
|
end
|
195
110
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# encoding: utf-8
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module ISO3166
|
5
4
|
module Emoji
|
@@ -36,7 +35,7 @@ module ISO3166
|
|
36
35
|
#
|
37
36
|
# The emoji flag for this country, using Unicode Regional Indicator characters. e.g: "U+1F1FA U+1F1F8" for 🇺🇸
|
38
37
|
def emoji_flag
|
39
|
-
alpha2.downcase.chars.map { |c| CODE_POINTS[c] }.join
|
38
|
+
alpha2.downcase.chars.map { |c| CODE_POINTS[c] }.join
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ISO3166
|
4
|
+
module CountryFinderMethods
|
5
|
+
FIND_BY_REGEX = /^find_(all_)?(country_|countries_)?by_(.+)/.freeze
|
6
|
+
SEARCH_TERM_FILTER_REGEX = /\(|\)|\[\]|,/.freeze
|
7
|
+
|
8
|
+
def search(query)
|
9
|
+
country = new(query.to_s.upcase)
|
10
|
+
country&.valid? ? country : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](query)
|
14
|
+
search(query)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_all_by(attribute, val)
|
18
|
+
attributes, lookup_value = parse_attributes(attribute, val)
|
19
|
+
|
20
|
+
ISO3166::Data.cache.select do |_, v|
|
21
|
+
country = Country.new(v)
|
22
|
+
attributes.any? do |attr|
|
23
|
+
Array(country.send(attr)).any? do |n|
|
24
|
+
lookup_value === cached(n) { parse_value(n) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(method_name, *arguments)
|
31
|
+
matches = method_name.to_s.match(FIND_BY_REGEX)
|
32
|
+
return_all = matches[1]
|
33
|
+
super unless matches
|
34
|
+
|
35
|
+
countries = find_by(matches[3], arguments[0], matches[2])
|
36
|
+
return_all ? countries : countries.last
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond_to_missing?(method_name, include_private = false)
|
40
|
+
matches = method_name.to_s.match(FIND_BY_REGEX)
|
41
|
+
if matches && matches[3]
|
42
|
+
instance_methods.include?(matches[3].to_sym)
|
43
|
+
else
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def find_by(attribute, value, obj = nil)
|
51
|
+
find_all_by(attribute.downcase, value).map do |country|
|
52
|
+
obj.nil? ? country : new(country.last)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_attributes(attribute, val)
|
57
|
+
raise "Invalid attribute name '#{attribute}'" unless searchable_attribute?(attribute.to_sym)
|
58
|
+
|
59
|
+
attributes = Array(attribute.to_s)
|
60
|
+
if attribute.to_s == 'any_name'
|
61
|
+
attributes = %w[iso_long_name iso_short_name unofficial_names translated_names]
|
62
|
+
end
|
63
|
+
|
64
|
+
[attributes, parse_value(val)]
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse_value(value)
|
68
|
+
value = value.gsub(SEARCH_TERM_FILTER_REGEX, '') if value.respond_to?(:gsub)
|
69
|
+
strip_accents(value)
|
70
|
+
end
|
71
|
+
|
72
|
+
def searchable_attribute?(attribute)
|
73
|
+
searchable_attributes.include?(attribute.to_sym)
|
74
|
+
end
|
75
|
+
|
76
|
+
def searchable_attributes
|
77
|
+
# Add name and names until we complete the deprecation of the finders
|
78
|
+
instance_methods - UNSEARCHABLE_METHODS + [:name, :names, :any_name]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/countries/country.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ISO3166
|
2
4
|
class Country
|
3
5
|
extend CountryClassMethods
|
6
|
+
extend CountryFinderMethods
|
4
7
|
include Emoji
|
5
8
|
attr_reader :data
|
6
9
|
|
@@ -31,24 +34,6 @@ module ISO3166
|
|
31
34
|
alias zip_format postal_code_format
|
32
35
|
alias languages languages_official
|
33
36
|
|
34
|
-
def latitude_dec
|
35
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
36
|
-
warn "DEPRECATION WARNING: The Country#latitude_dec method has been deprecated and will be removed in 5.0. Please use Country#latitude instead.", uplevel: 1, category: :deprecated
|
37
|
-
else
|
38
|
-
warn "DEPRECATION WARNING: The Country#latitude_dec method has been deprecated and will be removed in 5.0. Please use Country#latitude instead.", uplevel: 1
|
39
|
-
end
|
40
|
-
latitude
|
41
|
-
end
|
42
|
-
|
43
|
-
def longitude_dec
|
44
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
45
|
-
warn "DEPRECATION WARNING: The Country#longitude_dec method has been deprecated and will be removed in 5.0. Please use Country#longitude instead.", uplevel: 1, category: :deprecated
|
46
|
-
else
|
47
|
-
warn "DEPRECATION WARNING: The Country#longitude_dec method has been deprecated and will be removed in 5.0. Please use Country#longitude instead.", uplevel: 1
|
48
|
-
end
|
49
|
-
longitude
|
50
|
-
end
|
51
|
-
|
52
37
|
def ==(other)
|
53
38
|
other.respond_to?(:alpha2) && other.alpha2 == alpha2
|
54
39
|
end
|
@@ -136,28 +121,6 @@ module ISO3166
|
|
136
121
|
@local_name ||= local_names.first
|
137
122
|
end
|
138
123
|
|
139
|
-
# @return [String] This Country's ISO Short Name
|
140
|
-
# @deprecated Use {#iso_short_name} instead.
|
141
|
-
def name
|
142
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
143
|
-
warn "DEPRECATION WARNING: The Country#name method has been deprecated. Please use Country#iso_short_name instead or refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
144
|
-
else
|
145
|
-
warn "DEPRECATION WARNING: The Country#name method has been deprecated. Please use Country#iso_short_name instead or refer to the README file for more information on this change.", uplevel: 1
|
146
|
-
end
|
147
|
-
iso_short_name
|
148
|
-
end
|
149
|
-
|
150
|
-
# @return [Array<String>] Array of unofficial, slang names or aliases for this Country
|
151
|
-
# @deprecated Use {#unofficial_names} instead.
|
152
|
-
def names
|
153
|
-
if RUBY_VERSION =~ /^3\.\d\.\d/
|
154
|
-
warn "DEPRECATION WARNING: The Country#names method has been deprecated. Please use Country#unofficial_names instead or refer to the README file for more information on this change.", uplevel: 1, category: :deprecated
|
155
|
-
else
|
156
|
-
warn "DEPRECATION WARNING: The Country#names method has been deprecated. Please use Country#unofficial_names instead or refer to the README file for more information on this change.", uplevel: 1
|
157
|
-
end
|
158
|
-
unofficial_names
|
159
|
-
end
|
160
|
-
|
161
124
|
# @!attribute alpha2
|
162
125
|
# @return [String] the ISO3166 alpha-2 code for this Country
|
163
126
|
#
|
@@ -565,7 +565,7 @@ CMX:
|
|
565
565
|
COA:
|
566
566
|
name: Coahuila
|
567
567
|
code:
|
568
|
-
unofficial_names: Coahuila
|
568
|
+
unofficial_names: Coahuila de Zaragoza
|
569
569
|
geo:
|
570
570
|
latitude: 27.058676
|
571
571
|
longitude: -101.7068294
|
@@ -1170,7 +1170,7 @@ MEX:
|
|
1170
1170
|
MIC:
|
1171
1171
|
name: Michoacán
|
1172
1172
|
code:
|
1173
|
-
unofficial_names: Michoacán
|
1173
|
+
unofficial_names: Michoacán de Ocampo
|
1174
1174
|
geo:
|
1175
1175
|
latitude: 19.5665192
|
1176
1176
|
longitude: -101.7068294
|
@@ -2234,7 +2234,7 @@ TLA:
|
|
2234
2234
|
VER:
|
2235
2235
|
name: Veracruz
|
2236
2236
|
code:
|
2237
|
-
unofficial_names: Veracruz
|
2237
|
+
unofficial_names: Veracruz de Ignacio de la Llave
|
2238
2238
|
geo:
|
2239
2239
|
latitude: 19.173773
|
2240
2240
|
longitude: -96.1342241
|
@@ -2463,15 +2463,3 @@ ZAC:
|
|
2463
2463
|
mk: Закатекас
|
2464
2464
|
'no': Zacatecas
|
2465
2465
|
comments:
|
2466
|
-
DIF:
|
2467
|
-
name: Mexico City
|
2468
|
-
code:
|
2469
|
-
unofficial_names:
|
2470
|
-
geo:
|
2471
|
-
latitude: 19.3663162
|
2472
|
-
longitude: -99.1593231
|
2473
|
-
translations:
|
2474
|
-
en: Mexico City
|
2475
|
-
ccp: "\U0001111F\U0001112C\U00011107\U00011134\U00011125\U00011128\U00011107\U0001112E
|
2476
|
-
\U00011125\U00011128\U00011111\U00011128"
|
2477
|
-
comments:
|
@@ -86,7 +86,7 @@
|
|
86
86
|
nb: Beja
|
87
87
|
nl: Beja
|
88
88
|
pl: Dystrykt Beja
|
89
|
-
pt:
|
89
|
+
pt: Beja
|
90
90
|
ro: Districtul Beja
|
91
91
|
ru: Бежа
|
92
92
|
si: බෙජා දිස්ත්රික්කය
|
@@ -147,7 +147,7 @@
|
|
147
147
|
nb: Braga
|
148
148
|
nl: Braga
|
149
149
|
pl: Dystrykt Braga
|
150
|
-
pt:
|
150
|
+
pt: Braga
|
151
151
|
ro: Districtul Braga
|
152
152
|
ru: Брага
|
153
153
|
si: බ්රගා දිස්ත්රික්කය
|
@@ -252,7 +252,7 @@
|
|
252
252
|
nb: Castelo Branco
|
253
253
|
nl: Castelo Branco
|
254
254
|
pl: Dystrykt Castelo Branco
|
255
|
-
pt:
|
255
|
+
pt: Castelo Branco
|
256
256
|
ro: Districtul Castelo Branco
|
257
257
|
ru: Каштелу-Бранку
|
258
258
|
si: කැස්ටෙලෝ බ්රන්කෝ දිස්ත්රික්කය
|
@@ -313,7 +313,7 @@
|
|
313
313
|
nb: Coimbra
|
314
314
|
nl: Coimbra
|
315
315
|
pl: Dystrykt Coimbra
|
316
|
-
pt:
|
316
|
+
pt: Coimbra
|
317
317
|
ro: Districtul Coimbra
|
318
318
|
ru: Коимбра
|
319
319
|
si: කොයිම්බ්රා දිස්ත්රික්කය
|
@@ -372,7 +372,7 @@
|
|
372
372
|
nb: Évora
|
373
373
|
nl: Évora
|
374
374
|
pl: Dystrykt Évora
|
375
|
-
pt:
|
375
|
+
pt: Évora
|
376
376
|
ro: Districtul Évora
|
377
377
|
ru: Эвора
|
378
378
|
si: එවොරා දිස්ත්රික්කය
|
@@ -432,7 +432,7 @@
|
|
432
432
|
nb: Faro
|
433
433
|
nl: Faro
|
434
434
|
pl: Dystrykt Faro
|
435
|
-
pt:
|
435
|
+
pt: Faro
|
436
436
|
ro: Districtul Faro
|
437
437
|
ru: Фару
|
438
438
|
si: ෆාරො දිස්ත්රික්කය
|
@@ -486,7 +486,7 @@
|
|
486
486
|
nb: Guarda
|
487
487
|
nl: Guarda
|
488
488
|
pl: Dystrykt Guarda
|
489
|
-
pt:
|
489
|
+
pt: Guarda
|
490
490
|
ro: Districtul Guarda
|
491
491
|
ru: Гуарда
|
492
492
|
sr: Гварда
|
@@ -539,7 +539,7 @@
|
|
539
539
|
nb: Leiria
|
540
540
|
nl: Leiria
|
541
541
|
pl: Dystrykt Leiria
|
542
|
-
pt:
|
542
|
+
pt: Leiria
|
543
543
|
ro: Districtul Leiria
|
544
544
|
ru: Лейрия
|
545
545
|
si: ලේයිරියා දිස්ත්රික්කය
|
@@ -597,7 +597,7 @@
|
|
597
597
|
nb: Lisboa
|
598
598
|
nl: Lissabon
|
599
599
|
pl: Dystrykt Lizbona
|
600
|
-
pt:
|
600
|
+
pt: Lisboa
|
601
601
|
ro: Districtul Lisabona
|
602
602
|
ru: Лиссабон
|
603
603
|
sr: Лисабон
|
@@ -642,7 +642,7 @@
|
|
642
642
|
nb: Portalegre
|
643
643
|
nl: Portalegre
|
644
644
|
pl: Dystrykt Portalegre
|
645
|
-
pt:
|
645
|
+
pt: Portalegre
|
646
646
|
ro: Districtul Portalegre
|
647
647
|
ru: Порталегри
|
648
648
|
sr: Порталегре
|
@@ -741,7 +741,7 @@
|
|
741
741
|
nb: Santarém
|
742
742
|
nl: Santarém
|
743
743
|
pl: Dystrykt Santarém
|
744
|
-
pt:
|
744
|
+
pt: Santarém
|
745
745
|
ro: Districtul Santarém
|
746
746
|
ru: Сантарен
|
747
747
|
si: සැන්ටරේම් දිස්ත්රික්කය
|
@@ -802,7 +802,7 @@
|
|
802
802
|
nb: Setúbal
|
803
803
|
nl: Setúbal
|
804
804
|
pl: Dystrykt Setúbal
|
805
|
-
pt:
|
805
|
+
pt: Setúbal
|
806
806
|
ro: Districtul Setúbal
|
807
807
|
ru: Сетубал
|
808
808
|
si: සෙටුබල් දිස්ත්රික්කය
|
@@ -862,7 +862,7 @@
|
|
862
862
|
nb: Viana do Castelo
|
863
863
|
nl: Viana do Castelo
|
864
864
|
pl: Dystrykt Viana do Castelo
|
865
|
-
pt:
|
865
|
+
pt: Viana do Castelo
|
866
866
|
ro: Districtul Viana do Castelo
|
867
867
|
ru: Виана-ду-Каштелу
|
868
868
|
si: වියානා ඩො කැස්ටෙලෝ දිස්ත්රික්කය
|