country_select 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c90fbc7dfe822e709d24caaa9f6ea4aadbc565d056acd04a83881fd456d77d04
4
- data.tar.gz: b8b38e3f7c4b907df636ecb611db60c26aa95c7e355a102ce9b4b5b0395fc77a
3
+ metadata.gz: c2e998f6961d73f6b512f6f2a8346f5f1b971b2fd48795772b9f2553970c2a7d
4
+ data.tar.gz: 72ecc080ff6e7c161d7e09686b170363fc29be7090e2541c41be0c8ab10ffde9
5
5
  SHA512:
6
- metadata.gz: 6c467912e59762ce36aecdff5b9ff177b10745a5462437be8d4b3eb283d6e92d1629b3eaa08f1ac2581bb28b212e2b43114bfbcc88ee5118fd0290b596817dd8
7
- data.tar.gz: c29e2c423c6cbf990ff80de5b1415945e90f1425ca5bc82a8cb819edca7438c22d4bba374fc52a6d467c29bab8b823d53b50ad8e70fe5d28afa8a8069ffff083
6
+ metadata.gz: f69921ae492051bdad6a71fab965e03c71f6446e4fbeb6da5b583b5d70d2136302f7eb726aca6fb6e1a803491855fa94928b28face16161f44437dbe93c23e09
7
+ data.tar.gz: 87530ffdd430818801590107cdf6314cc32deb8f1ec42444ce4e0f8848c4a175934e7e4dac3c495d16b66633e7d819422297213d120014aabefb646b5b9639f0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 8.0.0 2022-06-30
2
+
3
+ * Update countries gem to 5.1.0 (@pmor)
4
+ * Add deprecation warning for old priority country syntax (@pmor)
5
+ * Allow option to preserve the sort order as inputted in the `only` array of countries (@pmor)
6
+ * Remove `sort_alphabetical` dependency (@pmor)
7
+
1
8
  ## 7.0.0 2022-04-03
2
9
 
3
10
  * #200 - Drop support for Ruby 2.5 and 2.6 (@pmor)
data/Gemfile.lock CHANGED
@@ -1,27 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- country_select (6.1.1)
4
+ country_select (7.0.0)
5
5
  countries (~> 5.0)
6
- sort_alphabetical (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actionpack (7.0.2.3)
12
- actionview (= 7.0.2.3)
13
- activesupport (= 7.0.2.3)
10
+ actionpack (7.0.3)
11
+ actionview (= 7.0.3)
12
+ activesupport (= 7.0.3)
14
13
  rack (~> 2.0, >= 2.2.0)
15
14
  rack-test (>= 0.6.3)
16
15
  rails-dom-testing (~> 2.0)
17
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (7.0.2.3)
19
- activesupport (= 7.0.2.3)
17
+ actionview (7.0.3)
18
+ activesupport (= 7.0.3)
20
19
  builder (~> 3.1)
21
20
  erubi (~> 1.4)
22
21
  rails-dom-testing (~> 2.0)
23
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (7.0.2.3)
23
+ activesupport (7.0.3)
25
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
25
  i18n (>= 1.6, < 2)
27
26
  minitest (>= 5.1)
@@ -29,34 +28,31 @@ GEM
29
28
  builder (3.2.4)
30
29
  coderay (1.1.3)
31
30
  concurrent-ruby (1.1.10)
32
- countries (5.0.0)
33
- i18n_data (~> 0.16.0)
31
+ countries (5.1.0)
34
32
  sixarm_ruby_unaccent (~> 1.1)
35
33
  crass (1.0.6)
36
34
  diff-lcs (1.5.0)
37
35
  erubi (1.10.0)
38
36
  i18n (1.10.0)
39
37
  concurrent-ruby (~> 1.0)
40
- i18n_data (0.16.0)
41
- simple_po_parser (~> 1.1)
42
- loofah (2.16.0)
38
+ loofah (2.18.0)
43
39
  crass (~> 1.0.2)
44
40
  nokogiri (>= 1.5.9)
45
41
  method_source (1.0.0)
46
- minitest (5.15.0)
47
- nokogiri (1.13.3-x86_64-darwin)
42
+ minitest (5.16.1)
43
+ nokogiri (1.13.6-x86_64-darwin)
48
44
  racc (~> 1.4)
49
45
  pry (0.14.1)
50
46
  coderay (~> 1.1)
51
47
  method_source (~> 1.0)
52
48
  racc (1.6.0)
53
- rack (2.2.3)
54
- rack-test (1.1.0)
55
- rack (>= 1.0, < 3)
49
+ rack (2.2.3.1)
50
+ rack-test (2.0.0)
51
+ rack (>= 1.3)
56
52
  rails-dom-testing (2.0.3)
57
53
  activesupport (>= 4.2.0)
58
54
  nokogiri (>= 1.6)
59
- rails-html-sanitizer (1.4.2)
55
+ rails-html-sanitizer (1.4.3)
60
56
  loofah (~> 2.3)
61
57
  rake (13.0.6)
62
58
  rspec (3.11.0)
@@ -72,13 +68,9 @@ GEM
72
68
  diff-lcs (>= 1.2.0, < 2.0)
73
69
  rspec-support (~> 3.11.0)
74
70
  rspec-support (3.11.0)
75
- simple_po_parser (1.1.6)
76
71
  sixarm_ruby_unaccent (1.2.0)
77
- sort_alphabetical (1.1.0)
78
- unicode_utils (>= 1.2.2)
79
72
  tzinfo (2.0.4)
80
73
  concurrent-ruby (~> 1.0)
81
- unicode_utils (1.4.0)
82
74
 
83
75
  PLATFORMS
84
76
  x86_64-darwin-21
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Rails – Country Select
2
- [![build](https://github.com/countries/country_select/actions/workflows/build.yml/badge.svg)](https://github.com/countries/country_select/actions/workflows/build.yml)
2
+ [![Gem Version](https://badge.fury.io/rb/country_select.svg)](https://badge.fury.io/rb/countries) [![build](https://github.com/countries/country_select/actions/workflows/build.yml/badge.svg)](https://github.com/countries/country_select/actions/workflows/build.yml)
3
3
  [![Code Climate](https://codeclimate.com/github/countries/country_select.svg)](https://codeclimate.com/github/countries/country_select)
4
4
  [![CodeQL](https://github.com/countries/country_select/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/countries/country_select/actions/workflows/codeql-analysis.yml)
5
5
 
@@ -57,13 +57,17 @@ country_select("user", "country")
57
57
  Supplying priority countries to be placed at the top of the list:
58
58
 
59
59
  ```ruby
60
- country_select("user", "country", priority_countries: ["GB", "FR", "DE"])
60
+ country_select("user", "country", priority_countries: ["GB", "FR", "DE"]) # Countries will be sorted by name according to the current locale
61
+ # or
62
+ country_select("user", "country", priority_countries: ["GB", "FR", "DE"], sort_provided: false) # Countries will be displayed is the provided order
61
63
  ```
62
64
 
63
65
  Supplying only certain countries:
64
66
 
65
67
  ```ruby
66
- country_select("user", "country", only: ["GB", "FR", "DE"])
68
+ country_select("user", "country", only: ["GB", "FR", "DE"]) # Countries will be sorted by name according to the current locale
69
+ # or
70
+ country_select("user", "country", only: ["GB", "FR", "DE"], sort_provided: false) # Countries will be displayed is the provided order
67
71
  ```
68
72
 
69
73
  Discarding certain countries:
data/Rakefile CHANGED
@@ -8,3 +8,29 @@ require 'rspec/core/rake_task'
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
10
  task default: 'spec'
11
+
12
+
13
+ task :update_gemfiles do
14
+ require 'pry'
15
+ Dir.glob('gemfiles/*.gemfile').each do |gemfile|
16
+ puts "Updating #{gemfile}...\n\n"
17
+ ENV['BUNDLE_GEMFILE']=gemfile
18
+ puts `bundle install --gemfile=#{gemfile} --no-cache`
19
+ puts `bundle update --gemfile=#{gemfile}`
20
+
21
+ lockfile = "#{gemfile}.lock"
22
+
23
+ if File.exists? lockfile
24
+ parsed_lockfile = Bundler::LockfileParser.new(Bundler.read_file(lockfile))
25
+ # Ensure lockfile has x86_64-linux
26
+ if parsed_lockfile.platforms.map(&:to_s).none? {|p| p == 'x86_64-linux' }
27
+ puts "Adding platform x86_64-linux to #{lockfile}\n\n"
28
+ puts `bundle lock --add-platform x86_64-linux --gemfile=#{gemfile}`
29
+ end
30
+
31
+ puts ""
32
+ else
33
+ raise StandardError.new("Expected #{lockfile} to exist.")
34
+ end
35
+ end
36
+ end
@@ -29,5 +29,4 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'rspec', '~> 3'
30
30
 
31
31
  s.add_dependency 'countries', '~> 5.0'
32
- s.add_dependency 'sort_alphabetical', '~> 1.1'
33
32
  end
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem "railties", "~> 5.2"
6
- gem "actionpack", "~> 5.2"
5
+ gem "railties", "~> 5.2.0"
6
+ gem "actionpack", "~> 5.2.0"
@@ -3,25 +3,24 @@ PATH
3
3
  specs:
4
4
  country_select (7.0.0)
5
5
  countries (~> 5.0)
6
- sort_alphabetical (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actionpack (5.2.7)
12
- actionview (= 5.2.7)
13
- activesupport (= 5.2.7)
10
+ actionpack (5.2.8)
11
+ actionview (= 5.2.8)
12
+ activesupport (= 5.2.8)
14
13
  rack (~> 2.0, >= 2.0.8)
15
14
  rack-test (>= 0.6.3)
16
15
  rails-dom-testing (~> 2.0)
17
16
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
- actionview (5.2.7)
19
- activesupport (= 5.2.7)
17
+ actionview (5.2.8)
18
+ activesupport (= 5.2.8)
20
19
  builder (~> 3.1)
21
20
  erubi (~> 1.4)
22
21
  rails-dom-testing (~> 2.0)
23
22
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
- activesupport (5.2.7)
23
+ activesupport (5.2.8)
25
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
25
  i18n (>= 0.7, < 2)
27
26
  minitest (~> 5.1)
@@ -29,40 +28,37 @@ GEM
29
28
  builder (3.2.4)
30
29
  coderay (1.1.3)
31
30
  concurrent-ruby (1.1.10)
32
- countries (5.0.0)
33
- i18n_data (~> 0.16.0)
31
+ countries (5.1.0)
34
32
  sixarm_ruby_unaccent (~> 1.1)
35
33
  crass (1.0.6)
36
34
  diff-lcs (1.5.0)
37
35
  erubi (1.10.0)
38
36
  i18n (1.10.0)
39
37
  concurrent-ruby (~> 1.0)
40
- i18n_data (0.16.0)
41
- simple_po_parser (~> 1.1)
42
- loofah (2.16.0)
38
+ loofah (2.18.0)
43
39
  crass (~> 1.0.2)
44
40
  nokogiri (>= 1.5.9)
45
41
  method_source (1.0.0)
46
- minitest (5.15.0)
47
- nokogiri (1.13.3-x86_64-darwin)
42
+ minitest (5.16.1)
43
+ nokogiri (1.13.6-x86_64-darwin)
48
44
  racc (~> 1.4)
49
- nokogiri (1.13.3-x86_64-linux)
45
+ nokogiri (1.13.6-x86_64-linux)
50
46
  racc (~> 1.4)
51
47
  pry (0.14.1)
52
48
  coderay (~> 1.1)
53
49
  method_source (~> 1.0)
54
50
  racc (1.6.0)
55
- rack (2.2.3)
56
- rack-test (1.1.0)
57
- rack (>= 1.0, < 3)
51
+ rack (2.2.3.1)
52
+ rack-test (2.0.2)
53
+ rack (>= 1.3)
58
54
  rails-dom-testing (2.0.3)
59
55
  activesupport (>= 4.2.0)
60
56
  nokogiri (>= 1.6)
61
- rails-html-sanitizer (1.4.2)
57
+ rails-html-sanitizer (1.4.3)
62
58
  loofah (~> 2.3)
63
- railties (5.2.7)
64
- actionpack (= 5.2.7)
65
- activesupport (= 5.2.7)
59
+ railties (5.2.8)
60
+ actionpack (= 5.2.8)
61
+ activesupport (= 5.2.8)
66
62
  method_source
67
63
  rake (>= 0.8.7)
68
64
  thor (>= 0.19.0, < 2.0)
@@ -80,25 +76,21 @@ GEM
80
76
  diff-lcs (>= 1.2.0, < 2.0)
81
77
  rspec-support (~> 3.11.0)
82
78
  rspec-support (3.11.0)
83
- simple_po_parser (1.1.6)
84
79
  sixarm_ruby_unaccent (1.2.0)
85
- sort_alphabetical (1.1.0)
86
- unicode_utils (>= 1.2.2)
87
80
  thor (1.2.1)
88
81
  thread_safe (0.3.6)
89
82
  tzinfo (1.2.9)
90
83
  thread_safe (~> 0.1)
91
- unicode_utils (1.4.0)
92
84
 
93
85
  PLATFORMS
94
86
  x86_64-darwin-21
95
87
  x86_64-linux
96
88
 
97
89
  DEPENDENCIES
98
- actionpack (~> 5.2)
90
+ actionpack (~> 5.2.0)
99
91
  country_select!
100
92
  pry (~> 0)
101
- railties (~> 5.2)
93
+ railties (~> 5.2.0)
102
94
  rake (~> 13)
103
95
  rspec (~> 3)
104
96
 
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem "railties", "~> 6.0"
6
- gem "actionpack", "~> 6.0"
5
+ gem "railties", "~> 6.0.0"
6
+ gem "actionpack", "~> 6.0.0"
@@ -3,70 +3,66 @@ PATH
3
3
  specs:
4
4
  country_select (7.0.0)
5
5
  countries (~> 5.0)
6
- sort_alphabetical (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actionpack (6.1.4.6)
12
- actionview (= 6.1.4.6)
13
- activesupport (= 6.1.4.6)
14
- rack (~> 2.0, >= 2.0.9)
10
+ actionpack (6.0.5)
11
+ actionview (= 6.0.5)
12
+ activesupport (= 6.0.5)
13
+ rack (~> 2.0, >= 2.0.8)
15
14
  rack-test (>= 0.6.3)
16
15
  rails-dom-testing (~> 2.0)
17
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.4.6)
19
- activesupport (= 6.1.4.6)
17
+ actionview (6.0.5)
18
+ activesupport (= 6.0.5)
20
19
  builder (~> 3.1)
21
20
  erubi (~> 1.4)
22
21
  rails-dom-testing (~> 2.0)
23
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (6.1.4.6)
23
+ activesupport (6.0.5)
25
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
- i18n (>= 1.6, < 2)
27
- minitest (>= 5.1)
28
- tzinfo (~> 2.0)
29
- zeitwerk (~> 2.3)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ zeitwerk (~> 2.2, >= 2.2.2)
30
29
  builder (3.2.4)
31
30
  coderay (1.1.3)
32
31
  concurrent-ruby (1.1.10)
33
- countries (5.0.0)
34
- i18n_data (~> 0.16.0)
32
+ countries (5.1.0)
35
33
  sixarm_ruby_unaccent (~> 1.1)
36
34
  crass (1.0.6)
37
35
  diff-lcs (1.5.0)
38
36
  erubi (1.10.0)
39
37
  i18n (1.10.0)
40
38
  concurrent-ruby (~> 1.0)
41
- i18n_data (0.16.0)
42
- simple_po_parser (~> 1.1)
43
- loofah (2.16.0)
39
+ loofah (2.18.0)
44
40
  crass (~> 1.0.2)
45
41
  nokogiri (>= 1.5.9)
46
42
  method_source (1.0.0)
47
- minitest (5.15.0)
48
- nokogiri (1.13.3-x86_64-darwin)
43
+ minitest (5.16.1)
44
+ nokogiri (1.13.6-x86_64-darwin)
49
45
  racc (~> 1.4)
50
- nokogiri (1.13.3-x86_64-linux)
46
+ nokogiri (1.13.6-x86_64-linux)
51
47
  racc (~> 1.4)
52
48
  pry (0.14.1)
53
49
  coderay (~> 1.1)
54
50
  method_source (~> 1.0)
55
51
  racc (1.6.0)
56
- rack (2.2.3)
57
- rack-test (1.1.0)
58
- rack (>= 1.0, < 3)
52
+ rack (2.2.3.1)
53
+ rack-test (2.0.2)
54
+ rack (>= 1.3)
59
55
  rails-dom-testing (2.0.3)
60
56
  activesupport (>= 4.2.0)
61
57
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.4.2)
58
+ rails-html-sanitizer (1.4.3)
63
59
  loofah (~> 2.3)
64
- railties (6.1.4.6)
65
- actionpack (= 6.1.4.6)
66
- activesupport (= 6.1.4.6)
60
+ railties (6.0.5)
61
+ actionpack (= 6.0.5)
62
+ activesupport (= 6.0.5)
67
63
  method_source
68
- rake (>= 0.13)
69
- thor (~> 1.0)
64
+ rake (>= 0.8.7)
65
+ thor (>= 0.20.3, < 2.0)
70
66
  rake (13.0.6)
71
67
  rspec (3.11.0)
72
68
  rspec-core (~> 3.11.0)
@@ -81,25 +77,22 @@ GEM
81
77
  diff-lcs (>= 1.2.0, < 2.0)
82
78
  rspec-support (~> 3.11.0)
83
79
  rspec-support (3.11.0)
84
- simple_po_parser (1.1.6)
85
80
  sixarm_ruby_unaccent (1.2.0)
86
- sort_alphabetical (1.1.0)
87
- unicode_utils (>= 1.2.2)
88
81
  thor (1.2.1)
89
- tzinfo (2.0.4)
90
- concurrent-ruby (~> 1.0)
91
- unicode_utils (1.4.0)
92
- zeitwerk (2.5.4)
82
+ thread_safe (0.3.6)
83
+ tzinfo (1.2.9)
84
+ thread_safe (~> 0.1)
85
+ zeitwerk (2.6.0)
93
86
 
94
87
  PLATFORMS
95
88
  x86_64-darwin-21
96
89
  x86_64-linux
97
90
 
98
91
  DEPENDENCIES
99
- actionpack (~> 6.0)
92
+ actionpack (~> 6.0.0)
100
93
  country_select!
101
94
  pry (~> 0)
102
- railties (~> 6.0)
95
+ railties (~> 6.0.0)
103
96
  rake (~> 13)
104
97
  rspec (~> 3)
105
98
 
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem "railties", "~> 6.1"
6
- gem "actionpack", "~> 6.1"
5
+ gem "railties", "~> 6.1.0"
6
+ gem "actionpack", "~> 6.1.0"
@@ -3,25 +3,24 @@ PATH
3
3
  specs:
4
4
  country_select (7.0.0)
5
5
  countries (~> 5.0)
6
- sort_alphabetical (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actionpack (6.1.4.6)
12
- actionview (= 6.1.4.6)
13
- activesupport (= 6.1.4.6)
10
+ actionpack (6.1.6)
11
+ actionview (= 6.1.6)
12
+ activesupport (= 6.1.6)
14
13
  rack (~> 2.0, >= 2.0.9)
15
14
  rack-test (>= 0.6.3)
16
15
  rails-dom-testing (~> 2.0)
17
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.4.6)
19
- activesupport (= 6.1.4.6)
17
+ actionview (6.1.6)
18
+ activesupport (= 6.1.6)
20
19
  builder (~> 3.1)
21
20
  erubi (~> 1.4)
22
21
  rails-dom-testing (~> 2.0)
23
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (6.1.4.6)
23
+ activesupport (6.1.6)
25
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
25
  i18n (>= 1.6, < 2)
27
26
  minitest (>= 5.1)
@@ -30,42 +29,39 @@ GEM
30
29
  builder (3.2.4)
31
30
  coderay (1.1.3)
32
31
  concurrent-ruby (1.1.10)
33
- countries (5.0.0)
34
- i18n_data (~> 0.16.0)
32
+ countries (5.1.0)
35
33
  sixarm_ruby_unaccent (~> 1.1)
36
34
  crass (1.0.6)
37
35
  diff-lcs (1.5.0)
38
36
  erubi (1.10.0)
39
37
  i18n (1.10.0)
40
38
  concurrent-ruby (~> 1.0)
41
- i18n_data (0.16.0)
42
- simple_po_parser (~> 1.1)
43
- loofah (2.16.0)
39
+ loofah (2.18.0)
44
40
  crass (~> 1.0.2)
45
41
  nokogiri (>= 1.5.9)
46
42
  method_source (1.0.0)
47
- minitest (5.15.0)
48
- nokogiri (1.13.3-x86_64-darwin)
43
+ minitest (5.16.1)
44
+ nokogiri (1.13.6-x86_64-darwin)
49
45
  racc (~> 1.4)
50
- nokogiri (1.13.3-x86_64-linux)
46
+ nokogiri (1.13.6-x86_64-linux)
51
47
  racc (~> 1.4)
52
48
  pry (0.14.1)
53
49
  coderay (~> 1.1)
54
50
  method_source (~> 1.0)
55
51
  racc (1.6.0)
56
- rack (2.2.3)
57
- rack-test (1.1.0)
58
- rack (>= 1.0, < 3)
52
+ rack (2.2.3.1)
53
+ rack-test (2.0.2)
54
+ rack (>= 1.3)
59
55
  rails-dom-testing (2.0.3)
60
56
  activesupport (>= 4.2.0)
61
57
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.4.2)
58
+ rails-html-sanitizer (1.4.3)
63
59
  loofah (~> 2.3)
64
- railties (6.1.4.6)
65
- actionpack (= 6.1.4.6)
66
- activesupport (= 6.1.4.6)
60
+ railties (6.1.6)
61
+ actionpack (= 6.1.6)
62
+ activesupport (= 6.1.6)
67
63
  method_source
68
- rake (>= 0.13)
64
+ rake (>= 12.2)
69
65
  thor (~> 1.0)
70
66
  rake (13.0.6)
71
67
  rspec (3.11.0)
@@ -81,25 +77,21 @@ GEM
81
77
  diff-lcs (>= 1.2.0, < 2.0)
82
78
  rspec-support (~> 3.11.0)
83
79
  rspec-support (3.11.0)
84
- simple_po_parser (1.1.6)
85
80
  sixarm_ruby_unaccent (1.2.0)
86
- sort_alphabetical (1.1.0)
87
- unicode_utils (>= 1.2.2)
88
81
  thor (1.2.1)
89
82
  tzinfo (2.0.4)
90
83
  concurrent-ruby (~> 1.0)
91
- unicode_utils (1.4.0)
92
- zeitwerk (2.5.4)
84
+ zeitwerk (2.6.0)
93
85
 
94
86
  PLATFORMS
95
87
  x86_64-darwin-21
96
88
  x86_64-linux
97
89
 
98
90
  DEPENDENCIES
99
- actionpack (~> 6.1)
91
+ actionpack (~> 6.1.0)
100
92
  country_select!
101
93
  pry (~> 0)
102
- railties (~> 6.1)
94
+ railties (~> 6.1.0)
103
95
  rake (~> 13)
104
96
  rspec (~> 3)
105
97
 
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec :path => "../"
4
4
 
5
- gem "railties", "~> 7.0"
6
- gem "actionpack", "~> 7.0"
5
+ gem "railties", "~> 7.0.0"
6
+ gem "actionpack", "~> 7.0.0"
@@ -3,25 +3,24 @@ PATH
3
3
  specs:
4
4
  country_select (7.0.0)
5
5
  countries (~> 5.0)
6
- sort_alphabetical (~> 1.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actionpack (7.0.2.3)
12
- actionview (= 7.0.2.3)
13
- activesupport (= 7.0.2.3)
10
+ actionpack (7.0.3)
11
+ actionview (= 7.0.3)
12
+ activesupport (= 7.0.3)
14
13
  rack (~> 2.0, >= 2.2.0)
15
14
  rack-test (>= 0.6.3)
16
15
  rails-dom-testing (~> 2.0)
17
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (7.0.2.3)
19
- activesupport (= 7.0.2.3)
17
+ actionview (7.0.3)
18
+ activesupport (= 7.0.3)
20
19
  builder (~> 3.1)
21
20
  erubi (~> 1.4)
22
21
  rails-dom-testing (~> 2.0)
23
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (7.0.2.3)
23
+ activesupport (7.0.3)
25
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
25
  i18n (>= 1.6, < 2)
27
26
  minitest (>= 5.1)
@@ -29,40 +28,37 @@ GEM
29
28
  builder (3.2.4)
30
29
  coderay (1.1.3)
31
30
  concurrent-ruby (1.1.10)
32
- countries (5.0.0)
33
- i18n_data (~> 0.16.0)
31
+ countries (5.1.0)
34
32
  sixarm_ruby_unaccent (~> 1.1)
35
33
  crass (1.0.6)
36
34
  diff-lcs (1.5.0)
37
35
  erubi (1.10.0)
38
36
  i18n (1.10.0)
39
37
  concurrent-ruby (~> 1.0)
40
- i18n_data (0.16.0)
41
- simple_po_parser (~> 1.1)
42
- loofah (2.16.0)
38
+ loofah (2.18.0)
43
39
  crass (~> 1.0.2)
44
40
  nokogiri (>= 1.5.9)
45
41
  method_source (1.0.0)
46
- minitest (5.15.0)
47
- nokogiri (1.13.3-x86_64-darwin)
42
+ minitest (5.16.1)
43
+ nokogiri (1.13.6-x86_64-darwin)
48
44
  racc (~> 1.4)
49
- nokogiri (1.13.3-x86_64-linux)
45
+ nokogiri (1.13.6-x86_64-linux)
50
46
  racc (~> 1.4)
51
47
  pry (0.14.1)
52
48
  coderay (~> 1.1)
53
49
  method_source (~> 1.0)
54
50
  racc (1.6.0)
55
- rack (2.2.3)
56
- rack-test (1.1.0)
57
- rack (>= 1.0, < 3)
51
+ rack (2.2.3.1)
52
+ rack-test (2.0.2)
53
+ rack (>= 1.3)
58
54
  rails-dom-testing (2.0.3)
59
55
  activesupport (>= 4.2.0)
60
56
  nokogiri (>= 1.6)
61
- rails-html-sanitizer (1.4.2)
57
+ rails-html-sanitizer (1.4.3)
62
58
  loofah (~> 2.3)
63
- railties (7.0.2.3)
64
- actionpack (= 7.0.2.3)
65
- activesupport (= 7.0.2.3)
59
+ railties (7.0.3)
60
+ actionpack (= 7.0.3)
61
+ activesupport (= 7.0.3)
66
62
  method_source
67
63
  rake (>= 12.2)
68
64
  thor (~> 1.0)
@@ -81,25 +77,21 @@ GEM
81
77
  diff-lcs (>= 1.2.0, < 2.0)
82
78
  rspec-support (~> 3.11.0)
83
79
  rspec-support (3.11.0)
84
- simple_po_parser (1.1.6)
85
80
  sixarm_ruby_unaccent (1.2.0)
86
- sort_alphabetical (1.1.0)
87
- unicode_utils (>= 1.2.2)
88
81
  thor (1.2.1)
89
82
  tzinfo (2.0.4)
90
83
  concurrent-ruby (~> 1.0)
91
- unicode_utils (1.4.0)
92
- zeitwerk (2.5.4)
84
+ zeitwerk (2.6.0)
93
85
 
94
86
  PLATFORMS
95
87
  x86_64-darwin-21
96
88
  x86_64-linux
97
89
 
98
90
  DEPENDENCIES
99
- actionpack (~> 7.0)
91
+ actionpack (~> 7.0.0)
100
92
  country_select!
101
93
  pry (~> 0)
102
- railties (~> 7.0)
94
+ railties (~> 7.0.0)
103
95
  rake (~> 13)
104
96
  rspec (~> 3)
105
97
 
@@ -6,6 +6,11 @@ module ActionView
6
6
  html_options = options
7
7
  options = priority_or_options
8
8
  else
9
+ if RUBY_VERSION =~ /^3\.\d\.\d/
10
+ warn "DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. Please use the `priority_countries:` option.", uplevel: 1, category: :deprecated
11
+ else
12
+ warn "DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. Please use the `priority_countries:` option.", uplevel: 1
13
+ end
9
14
  options[:priority_countries] = priority_or_options
10
15
  end
11
16
 
@@ -5,6 +5,7 @@ module CountrySelect
5
5
  locale: nil,
6
6
  only: nil,
7
7
  priority_countries: nil,
8
- priority_countries_divider: "-" * 15
8
+ priority_countries_divider: "-" * 15,
9
+ sort_provided: true
9
10
  }
10
11
  end
@@ -19,7 +19,7 @@ module CountrySelect
19
19
  }
20
20
 
21
21
  if priority_countries.present?
22
- priority_countries_options = country_options_for(priority_countries, false)
22
+ priority_countries_options = country_options_for(priority_countries, @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided]))
23
23
 
24
24
  option_tags = options_for_select(priority_countries_options, option_tags_options)
25
25
  option_tags += html_safe_newline + options_for_select([priority_countries_divider], disabled: priority_countries_divider)
@@ -59,14 +59,14 @@ module CountrySelect
59
59
  end
60
60
 
61
61
  def country_options
62
- country_options_for(all_country_codes, true)
62
+ country_options_for(all_country_codes, @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided]))
63
63
  end
64
64
 
65
65
  def all_country_codes
66
66
  codes = ISO3166::Country.codes
67
67
 
68
68
  if only_country_codes.present?
69
- codes & only_country_codes
69
+ only_country_codes & codes
70
70
  elsif except_country_codes.present?
71
71
  codes - except_country_codes
72
72
  else
@@ -99,11 +99,7 @@ module CountrySelect
99
99
  end
100
100
 
101
101
  if sorted
102
- if country_list.respond_to?(:sort_alphabetical)
103
- country_list.sort_alphabetical
104
- else
105
- country_list.sort
106
- end
102
+ country_list.sort_by { |name, code| [I18n.transliterate(name), name] }
107
103
  else
108
104
  country_list
109
105
  end
@@ -1,3 +1,3 @@
1
1
  module CountrySelect
2
- VERSION = '7.0.0'
2
+ VERSION = '8.0.0'
3
3
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'countries'
4
- require 'sort_alphabetical'
5
4
 
6
5
  require 'country_select/version'
7
6
  require 'country_select/defaults'
@@ -92,9 +92,26 @@ describe "CountrySelect" do
92
92
  it "accepts priority countries" do
93
93
  tag = options_for_select(
94
94
  [
95
+ ['Denmark', 'DK'],
95
96
  ['Latvia','LV'],
96
97
  ['United States','US'],
98
+ ['-'*15,'-'*15]
99
+ ],
100
+ selected: 'US',
101
+ disabled: '-'*15
102
+ )
103
+
104
+ walrus.country_code = 'US'
105
+ t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'])
106
+ expect(t).to include(tag)
107
+ end
108
+
109
+ it "priority countries are sorted by name by default" do
110
+ tag = options_for_select(
111
+ [
97
112
  ['Denmark', 'DK'],
113
+ ['Latvia','LV'],
114
+ ['United States','US'],
98
115
  ['-'*15,'-'*15]
99
116
  ],
100
117
  selected: 'US',
@@ -106,6 +123,23 @@ describe "CountrySelect" do
106
123
  expect(t).to include(tag)
107
124
  end
108
125
 
126
+ it "priority countries with `sort_provided: false` preserves the provided order" do
127
+ tag = options_for_select(
128
+ [
129
+ ['Latvia','LV'],
130
+ ['United States','US'],
131
+ ['Denmark', 'DK'],
132
+ ['-'*15,'-'*15]
133
+ ],
134
+ selected: 'US',
135
+ disabled: '-'*15
136
+ )
137
+
138
+ walrus.country_code = 'US'
139
+ t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'], sort_provided: false)
140
+ expect(t).to include(tag)
141
+ end
142
+
109
143
  describe "when selected options is not an array" do
110
144
  it "selects only the first matching option" do
111
145
  tag = options_for_select([["United States", "US"],["Uruguay", "UY"]], "US")
@@ -139,6 +173,18 @@ describe "CountrySelect" do
139
173
  expect(t).to_not include(tag)
140
174
  end
141
175
 
176
+ it "countries provided in `only` are sorted by name by default" do
177
+ t = builder.country_select(:country_code, only: ['PT','DE','AR'])
178
+ order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
179
+ expect(order).to eq(['AR', 'DE', 'PT'])
180
+ end
181
+
182
+ it "countries provided in `only` with `sort_provided` to false keeps the order of the provided countries" do
183
+ t = builder.country_select(:country_code, only: ['PT','DE','AR'], sort_provided: false)
184
+ order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
185
+ expect(order).to eq(['PT','DE','AR'])
186
+ end
187
+
142
188
  context "when there is a default 'except' configured" do
143
189
  around do |example|
144
190
  old_value = ::CountrySelect::DEFAULTS[:except]
@@ -160,9 +206,9 @@ describe "CountrySelect" do
160
206
  it "accepts priority countries" do
161
207
  tag = options_for_select(
162
208
  [
209
+ ['Denmark', 'DK'],
163
210
  ['Latvia','LV'],
164
211
  ['United States','US'],
165
- ['Denmark', 'DK'],
166
212
  ['-'*15,'-'*15]
167
213
  ],
168
214
  selected: 'US',
@@ -235,23 +281,6 @@ describe "CountrySelect" do
235
281
  expect(order).to eq(['AF', 'AX', 'AL', 'ZW'])
236
282
  end
237
283
 
238
- context "without sort_alphabetical" do
239
- before do
240
- Enumerable.send(:alias_method, :_sort_alphabetical, :sort_alphabetical)
241
- Enumerable.send(:remove_method, :sort_alphabetical)
242
- end
243
-
244
- after do
245
- Enumerable.send(:alias_method, :sort_alphabetical, :_sort_alphabetical)
246
- end
247
-
248
- it 'falls back to regular sort' do
249
- tag = builder.country_select(:country_code, only: ['AX', 'AL', 'AF', 'ZW'])
250
- order = tag.scan(/value="(\w{2})"/).map { |o| o[0] }
251
- expect(order).to eq(['AF', 'AL', 'ZW', 'AX'])
252
- end
253
- end
254
-
255
284
  describe "custom formats" do
256
285
  it "accepts a custom formatter" do
257
286
  ::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: country_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Penner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-03 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.0'
83
- - !ruby/object:Gem::Dependency
84
- name: sort_alphabetical
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.1'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.1'
97
83
  description: Provides a simple helper to get an HTML select list of countries. The
98
84
  list of countries comes from the ISO 3166 standard. While it is a relatively neutral
99
85
  source of country names, it will still offend some users.
@@ -123,15 +109,12 @@ files:
123
109
  - gemfiles/actionpack-6.1.gemfile.lock
124
110
  - gemfiles/actionpack-7.0.gemfile
125
111
  - gemfiles/actionpack-7.0.gemfile.lock
126
- - gemfiles/actionpack-head.gemfile
127
- - gemfiles/actionpack-head.gemfile.lock
128
112
  - lib/country_select.rb
129
113
  - lib/country_select/country_select_helper.rb
130
114
  - lib/country_select/defaults.rb
131
115
  - lib/country_select/formats.rb
132
116
  - lib/country_select/tag_helper.rb
133
117
  - lib/country_select/version.rb
134
- - lib/country_select_without_sort_alphabetical.rb
135
118
  - spec/country_select_spec.rb
136
119
  - spec/spec_helper.rb
137
120
  homepage: https://github.com/countries/country_select
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path => "../"
4
-
5
- git "https://github.com/rails/rails.git" do
6
- gem "actionpack"
7
- gem "actionview"
8
- gem "activesupport"
9
- end
@@ -1,104 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: bb4a8a91884f3eff2b22d4deb3727d3cc267ddc4
4
- specs:
5
- actionpack (7.1.0.alpha)
6
- actionview (= 7.1.0.alpha)
7
- activesupport (= 7.1.0.alpha)
8
- rack (~> 2.0, >= 2.2.0)
9
- rack-test (>= 0.6.3)
10
- rails-dom-testing (~> 2.0)
11
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
12
- actionview (7.1.0.alpha)
13
- activesupport (= 7.1.0.alpha)
14
- builder (~> 3.1)
15
- erubi (~> 1.4)
16
- rails-dom-testing (~> 2.0)
17
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
18
- activesupport (7.1.0.alpha)
19
- concurrent-ruby (~> 1.0, >= 1.0.2)
20
- i18n (>= 1.6, < 2)
21
- minitest (>= 5.1)
22
- tzinfo (~> 2.0)
23
-
24
- PATH
25
- remote: ..
26
- specs:
27
- country_select (7.0.0)
28
- countries (~> 5.0)
29
- sort_alphabetical (~> 1.1)
30
-
31
- GEM
32
- remote: https://rubygems.org/
33
- specs:
34
- builder (3.2.4)
35
- coderay (1.1.3)
36
- concurrent-ruby (1.1.10)
37
- countries (5.0.0)
38
- i18n_data (~> 0.16.0)
39
- sixarm_ruby_unaccent (~> 1.1)
40
- crass (1.0.6)
41
- diff-lcs (1.5.0)
42
- erubi (1.10.0)
43
- i18n (1.10.0)
44
- concurrent-ruby (~> 1.0)
45
- i18n_data (0.16.0)
46
- simple_po_parser (~> 1.1)
47
- loofah (2.16.0)
48
- crass (~> 1.0.2)
49
- nokogiri (>= 1.5.9)
50
- method_source (1.0.0)
51
- minitest (5.15.0)
52
- nokogiri (1.13.3-x86_64-darwin)
53
- racc (~> 1.4)
54
- nokogiri (1.13.3-x86_64-linux)
55
- racc (~> 1.4)
56
- pry (0.14.1)
57
- coderay (~> 1.1)
58
- method_source (~> 1.0)
59
- racc (1.6.0)
60
- rack (2.2.3)
61
- rack-test (1.1.0)
62
- rack (>= 1.0, < 3)
63
- rails-dom-testing (2.0.3)
64
- activesupport (>= 4.2.0)
65
- nokogiri (>= 1.6)
66
- rails-html-sanitizer (1.4.2)
67
- loofah (~> 2.3)
68
- rake (13.0.6)
69
- rspec (3.11.0)
70
- rspec-core (~> 3.11.0)
71
- rspec-expectations (~> 3.11.0)
72
- rspec-mocks (~> 3.11.0)
73
- rspec-core (3.11.0)
74
- rspec-support (~> 3.11.0)
75
- rspec-expectations (3.11.0)
76
- diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.11.0)
78
- rspec-mocks (3.11.1)
79
- diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.11.0)
81
- rspec-support (3.11.0)
82
- simple_po_parser (1.1.6)
83
- sixarm_ruby_unaccent (1.2.0)
84
- sort_alphabetical (1.1.0)
85
- unicode_utils (>= 1.2.2)
86
- tzinfo (2.0.4)
87
- concurrent-ruby (~> 1.0)
88
- unicode_utils (1.4.0)
89
-
90
- PLATFORMS
91
- x86_64-darwin-21
92
- x86_64-linux
93
-
94
- DEPENDENCIES
95
- actionpack!
96
- actionview!
97
- activesupport!
98
- country_select!
99
- pry (~> 0)
100
- rake (~> 13)
101
- rspec (~> 3)
102
-
103
- BUNDLED WITH
104
- 2.3.10
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'countries'
4
-
5
- require 'country_select/version'
6
- require 'country_select/defaults'
7
- require 'country_select/formats'
8
- require 'country_select/tag_helper'
9
- require 'country_select/country_select_helper'