countries 4.2.3 → 5.0.0
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 +1 -5
- data/.rubocop.yml +40 -1
- data/.rubocop_todo.yml +8 -41
- data/CHANGELOG.md +7 -2
- data/Gemfile +5 -3
- data/README.markdown +22 -5
- data/Rakefile +13 -31
- data/bin/console +1 -0
- data/countries.gemspec +7 -5
- data/lib/countries/cache/countries.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.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 +14 -12
- data/lib/countries/setup.rb +0 -18
data/spec/subdivision_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -23,9 +23,11 @@ describe ISO3166::Subdivision do
|
|
23
23
|
describe 'state codes' do
|
24
24
|
it 'should all be strings' do
|
25
25
|
countries.each do |country|
|
26
|
-
expect(country.subdivisions.keys).to
|
27
|
-
|
28
|
-
"
|
26
|
+
expect(country.subdivisions.keys).to(
|
27
|
+
all(be_a(String)),
|
28
|
+
"Expected #{country.alpha2.inspect} to have string subdivision \
|
29
|
+
codes but had #{country.subdivisions.keys.inspect}"
|
30
|
+
)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/spec/thread_safety_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
describe 'Accessing ISO3166::Country instances data in multiple threads' do
|
2
4
|
before do
|
3
5
|
if Thread.respond_to?(:report_on_exception)
|
@@ -12,7 +14,7 @@ describe 'Accessing ISO3166::Country instances data in multiple threads' do
|
|
12
14
|
nthreads = 100
|
13
15
|
threads = []
|
14
16
|
|
15
|
-
alpha2_codes = [
|
17
|
+
alpha2_codes = %w[us es nl ca de fr mx ru ch jp]
|
16
18
|
|
17
19
|
nthreads.times do
|
18
20
|
threads << Thread.new do
|
@@ -31,7 +33,7 @@ describe 'Accessing ISO3166::Country instances data in multiple threads' do
|
|
31
33
|
expect { create_countries_threaded }.to_not raise_error
|
32
34
|
end
|
33
35
|
|
34
|
-
it
|
36
|
+
it 'raises NoMethodError when not using a mutex' do
|
35
37
|
allow(ISO3166::Data).to receive(:use_mutex?).and_return(false)
|
36
38
|
|
37
39
|
expect { create_countries_threaded }.to raise_error(NoMethodError)
|
@@ -43,4 +45,3 @@ describe 'Accessing ISO3166::Country instances data in multiple threads' do
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
|
data/spec/timezone_spec.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: 5.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: 2022-03
|
14
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n_data
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '1.1'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
|
-
name:
|
45
|
+
name: activesupport
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
@@ -56,33 +56,33 @@ dependencies:
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '3'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
59
|
+
name: nokogiri
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
64
|
+
version: '1.8'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
71
|
+
version: '1.8'
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
73
|
+
name: rspec
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
78
|
+
version: '3'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
85
|
+
version: '3'
|
86
86
|
description: All sorts of useful information about every country packaged as pretty
|
87
87
|
little country objects. It includes data from ISO 3166
|
88
88
|
email:
|
@@ -93,6 +93,7 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
+
- ".github/workflows/codeql-analysis.yml"
|
96
97
|
- ".github/workflows/tests.yml"
|
97
98
|
- ".gitignore"
|
98
99
|
- ".rspec"
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- lib/countries/country/class_methods.rb
|
245
246
|
- lib/countries/country/currency_methods.rb
|
246
247
|
- lib/countries/country/emoji.rb
|
248
|
+
- lib/countries/country/finder_methods.rb
|
247
249
|
- lib/countries/data.rb
|
248
250
|
- lib/countries/data/countries/AD.yaml
|
249
251
|
- lib/countries/data/countries/AE.yaml
|
@@ -705,7 +707,6 @@ files:
|
|
705
707
|
- lib/countries/iso3166.rb
|
706
708
|
- lib/countries/kwarg_struct.rb
|
707
709
|
- lib/countries/mongoid.rb
|
708
|
-
- lib/countries/setup.rb
|
709
710
|
- lib/countries/sources.rb
|
710
711
|
- lib/countries/sources/cldr/downloader.rb
|
711
712
|
- lib/countries/sources/cldr/subdivision.rb
|
@@ -737,6 +738,7 @@ metadata:
|
|
737
738
|
changelog_uri: https://github.com/countries/countries/blob/master/CHANGELOG.md
|
738
739
|
source_code_uri: https://github.com/countries/countries
|
739
740
|
wiki_uri: https://github.com/countries/countries/wiki
|
741
|
+
rubygems_mfa_required: 'true'
|
740
742
|
post_install_message:
|
741
743
|
rdoc_options: []
|
742
744
|
require_paths:
|
@@ -745,14 +747,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
745
747
|
requirements:
|
746
748
|
- - ">="
|
747
749
|
- !ruby/object:Gem::Version
|
748
|
-
version: '2.
|
750
|
+
version: '2.7'
|
749
751
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
750
752
|
requirements:
|
751
753
|
- - ">="
|
752
754
|
- !ruby/object:Gem::Version
|
753
755
|
version: '0'
|
754
756
|
requirements: []
|
755
|
-
rubygems_version: 3.3.
|
757
|
+
rubygems_version: 3.3.7
|
756
758
|
signing_key:
|
757
759
|
specification_version: 4
|
758
760
|
summary: Gives you a country object full of all sorts of useful information.
|
data/lib/countries/setup.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module ISO3166
|
2
|
-
##
|
3
|
-
# <b>DEPRECATED:</b> Please use <tt>Data</tt> instead.
|
4
|
-
# TODO: Remove at version 2.1
|
5
|
-
# Handles building the in memory store of countries data
|
6
|
-
class Setup
|
7
|
-
# <b>DEPRECATED:</b> Please use <tt>Data.codes</tt> instead.
|
8
|
-
def codes
|
9
|
-
warn '[DEPRECATION] `Setup.codes` is deprecated. Please use `Data.codes` instead.'
|
10
|
-
Data.codes
|
11
|
-
end
|
12
|
-
|
13
|
-
def data
|
14
|
-
warn "[DEPRECATION] `Setup.new.data` is deprecated without replacement
|
15
|
-
data is now loaded per locale Data.new(:en).call"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|