country_select 7.0.0 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +2 -2
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +38 -43
- data/README.md +8 -10
- data/Rakefile +26 -0
- data/country_select.gemspec +0 -1
- data/gemfiles/actionpack-5.2.gemfile +3 -2
- data/gemfiles/actionpack-5.2.gemfile.lock +42 -49
- data/gemfiles/actionpack-6.0.gemfile +3 -2
- data/gemfiles/actionpack-6.0.gemfile.lock +52 -58
- data/gemfiles/actionpack-6.1.gemfile +3 -2
- data/gemfiles/actionpack-6.1.gemfile.lock +44 -51
- data/gemfiles/actionpack-7.0.gemfile +3 -2
- data/gemfiles/actionpack-7.0.gemfile.lock +43 -50
- data/lib/country_select/country_select_helper.rb +5 -0
- data/lib/country_select/defaults.rb +2 -1
- data/lib/country_select/tag_helper.rb +10 -15
- data/lib/country_select/version.rb +1 -1
- data/lib/country_select.rb +0 -1
- data/spec/country_select_spec.rb +65 -18
- metadata +3 -20
- data/gemfiles/actionpack-head.gemfile +0 -9
- data/gemfiles/actionpack-head.gemfile.lock +0 -104
- data/lib/country_select_without_sort_alphabetical.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 674674f152073e1e9b8834bbe5bf012c704ac9f128c664a2b2b46891081bc502
|
4
|
+
data.tar.gz: 9b0670886ec8b5ad3961c446adf4a9a4497e5edbeb1822c7c5cb94fbf6694a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd10c341e06f4f72318446e7f8115cf63da4800d2314955c755fab4f0328b53cecdf784385011d55c45edec12bca5d2929c7dd4f21605e46c10227db1d17871e
|
7
|
+
data.tar.gz: 93c7f859aada39e88724fed5a6b508bc84155191a168b1a007c0478b01339faf831752e5c22b25d3ddf98c3c5211e5b35bfd691581818e7e0edcb89ab88e765c
|
data/.github/workflows/build.yml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
fail-fast: false
|
14
14
|
matrix:
|
15
|
-
ruby: [2.7, '3.0', 3.1]
|
15
|
+
ruby: [2.7, '3.0', 3.1, 3.2]
|
16
16
|
gemfile: [5.2, '6.0', 6.1, '7.0']
|
17
17
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
18
18
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/actionpack-${{ matrix.gemfile }}.gemfile
|
19
19
|
steps:
|
20
|
-
- uses: actions/checkout@
|
20
|
+
- uses: actions/checkout@v3
|
21
21
|
- uses: ruby/setup-ruby@v1
|
22
22
|
with:
|
23
23
|
ruby-version: ${{ matrix.ruby }}
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## 8.0.1 2023-01-03
|
2
|
+
|
3
|
+
* Update README.md by (@ron-shinall)
|
4
|
+
* Update installation instructions by (@henrik)
|
5
|
+
* Fix deprecated File.exists? on ruby 3.2.0 by (@JNajera212)
|
6
|
+
* Fix priority country sorting bug by (@pmor)
|
7
|
+
* Update countries gem to 5.3.0 (@pmor)
|
8
|
+
|
9
|
+
## 8.0.0 2022-06-30
|
10
|
+
|
11
|
+
* Update countries gem to 5.1.0 (@pmor)
|
12
|
+
* Add deprecation warning for old priority country syntax (@pmor)
|
13
|
+
* Allow option to preserve the sort order as inputted in the `only` array of countries (@pmor)
|
14
|
+
* Remove `sort_alphabetical` dependency (@pmor)
|
15
|
+
|
1
16
|
## 7.0.0 2022-04-03
|
2
17
|
|
3
18
|
* #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 (
|
4
|
+
country_select (8.0.1)
|
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.
|
12
|
-
actionview (= 7.0.
|
13
|
-
activesupport (= 7.0.
|
10
|
+
actionpack (7.0.4)
|
11
|
+
actionview (= 7.0.4)
|
12
|
+
activesupport (= 7.0.4)
|
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.
|
19
|
-
activesupport (= 7.0.
|
17
|
+
actionview (7.0.4)
|
18
|
+
activesupport (= 7.0.4)
|
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.
|
23
|
+
activesupport (7.0.4)
|
25
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
25
|
i18n (>= 1.6, < 2)
|
27
26
|
minitest (>= 5.1)
|
@@ -29,59 +28,55 @@ GEM
|
|
29
28
|
builder (3.2.4)
|
30
29
|
coderay (1.1.3)
|
31
30
|
concurrent-ruby (1.1.10)
|
32
|
-
countries (5.
|
33
|
-
|
34
|
-
sixarm_ruby_unaccent (~> 1.1)
|
31
|
+
countries (5.3.0)
|
32
|
+
unaccent (~> 0.3)
|
35
33
|
crass (1.0.6)
|
36
34
|
diff-lcs (1.5.0)
|
37
|
-
erubi (1.
|
38
|
-
i18n (1.
|
35
|
+
erubi (1.12.0)
|
36
|
+
i18n (1.12.0)
|
39
37
|
concurrent-ruby (~> 1.0)
|
40
|
-
|
41
|
-
simple_po_parser (~> 1.1)
|
42
|
-
loofah (2.16.0)
|
38
|
+
loofah (2.19.1)
|
43
39
|
crass (~> 1.0.2)
|
44
40
|
nokogiri (>= 1.5.9)
|
45
41
|
method_source (1.0.0)
|
46
|
-
minitest (5.
|
47
|
-
nokogiri (1.
|
42
|
+
minitest (5.17.0)
|
43
|
+
nokogiri (1.14.0.rc1-x86_64-darwin)
|
44
|
+
racc (~> 1.4)
|
45
|
+
nokogiri (1.14.0.rc1-x86_64-linux)
|
48
46
|
racc (~> 1.4)
|
49
47
|
pry (0.14.1)
|
50
48
|
coderay (~> 1.1)
|
51
49
|
method_source (~> 1.0)
|
52
|
-
racc (1.6.
|
53
|
-
rack (2.2.
|
54
|
-
rack-test (
|
55
|
-
rack (>= 1.
|
50
|
+
racc (1.6.2)
|
51
|
+
rack (2.2.5)
|
52
|
+
rack-test (2.0.2)
|
53
|
+
rack (>= 1.3)
|
56
54
|
rails-dom-testing (2.0.3)
|
57
55
|
activesupport (>= 4.2.0)
|
58
56
|
nokogiri (>= 1.6)
|
59
|
-
rails-html-sanitizer (1.4.
|
60
|
-
loofah (~> 2.
|
57
|
+
rails-html-sanitizer (1.4.4)
|
58
|
+
loofah (~> 2.19, >= 2.19.1)
|
61
59
|
rake (13.0.6)
|
62
|
-
rspec (3.
|
63
|
-
rspec-core (~> 3.
|
64
|
-
rspec-expectations (~> 3.
|
65
|
-
rspec-mocks (~> 3.
|
66
|
-
rspec-core (3.
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-expectations (3.
|
60
|
+
rspec (3.12.0)
|
61
|
+
rspec-core (~> 3.12.0)
|
62
|
+
rspec-expectations (~> 3.12.0)
|
63
|
+
rspec-mocks (~> 3.12.0)
|
64
|
+
rspec-core (3.12.0)
|
65
|
+
rspec-support (~> 3.12.0)
|
66
|
+
rspec-expectations (3.12.1)
|
69
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
-
rspec-support (~> 3.
|
71
|
-
rspec-mocks (3.
|
68
|
+
rspec-support (~> 3.12.0)
|
69
|
+
rspec-mocks (3.12.1)
|
72
70
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-support (3.
|
75
|
-
|
76
|
-
sixarm_ruby_unaccent (1.2.0)
|
77
|
-
sort_alphabetical (1.1.0)
|
78
|
-
unicode_utils (>= 1.2.2)
|
79
|
-
tzinfo (2.0.4)
|
71
|
+
rspec-support (~> 3.12.0)
|
72
|
+
rspec-support (3.12.0)
|
73
|
+
tzinfo (2.0.5)
|
80
74
|
concurrent-ruby (~> 1.0)
|
81
|
-
|
75
|
+
unaccent (0.4.0)
|
82
76
|
|
83
77
|
PLATFORMS
|
84
|
-
x86_64-darwin-
|
78
|
+
x86_64-darwin-22
|
79
|
+
x86_64-linux
|
85
80
|
|
86
81
|
DEPENDENCIES
|
87
82
|
actionpack (~> 7.0)
|
@@ -91,4 +86,4 @@ DEPENDENCIES
|
|
91
86
|
rspec (~> 3)
|
92
87
|
|
93
88
|
BUNDLED WITH
|
94
|
-
2.
|
89
|
+
2.4.2
|
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
|
|
@@ -29,13 +29,7 @@ gem install country_select
|
|
29
29
|
Or put the following in your Gemfile
|
30
30
|
|
31
31
|
```ruby
|
32
|
-
gem 'country_select', '~>
|
33
|
-
```
|
34
|
-
|
35
|
-
If you don't want to require `sort_alphabetical` (it depends on `unicode_utils` which is known to use lots of memory) you can opt out of using it as follows:
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
gem 'country_select', require: 'country_select_without_sort_alphabetical'
|
32
|
+
gem 'country_select', '~> 8.0'
|
39
33
|
```
|
40
34
|
|
41
35
|
## Usage
|
@@ -57,13 +51,17 @@ country_select("user", "country")
|
|
57
51
|
Supplying priority countries to be placed at the top of the list:
|
58
52
|
|
59
53
|
```ruby
|
60
|
-
country_select("user", "country", priority_countries: ["GB", "FR", "DE"])
|
54
|
+
country_select("user", "country", priority_countries: ["GB", "FR", "DE"]) # Countries will be sorted by name according to the current locale
|
55
|
+
# or
|
56
|
+
country_select("user", "country", priority_countries: ["GB", "FR", "DE"], sort_provided: false) # Countries will be displayed is the provided order
|
61
57
|
```
|
62
58
|
|
63
59
|
Supplying only certain countries:
|
64
60
|
|
65
61
|
```ruby
|
66
|
-
country_select("user", "country", only: ["GB", "FR", "DE"])
|
62
|
+
country_select("user", "country", only: ["GB", "FR", "DE"]) # Countries will be sorted by name according to the current locale
|
63
|
+
# or
|
64
|
+
country_select("user", "country", only: ["GB", "FR", "DE"], sort_provided: false) # Countries will be displayed is the provided order
|
67
65
|
```
|
68
66
|
|
69
67
|
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.exist? 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
|
data/country_select.gemspec
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
country_select (
|
4
|
+
country_select (8.0.1)
|
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.
|
12
|
-
actionview (= 5.2.
|
13
|
-
activesupport (= 5.2.
|
10
|
+
actionpack (5.2.8.1)
|
11
|
+
actionview (= 5.2.8.1)
|
12
|
+
activesupport (= 5.2.8.1)
|
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.
|
19
|
-
activesupport (= 5.2.
|
17
|
+
actionview (5.2.8.1)
|
18
|
+
activesupport (= 5.2.8.1)
|
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.
|
23
|
+
activesupport (5.2.8.1)
|
25
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
25
|
i18n (>= 0.7, < 2)
|
27
26
|
minitest (~> 5.1)
|
@@ -29,78 +28,72 @@ GEM
|
|
29
28
|
builder (3.2.4)
|
30
29
|
coderay (1.1.3)
|
31
30
|
concurrent-ruby (1.1.10)
|
32
|
-
countries (5.
|
33
|
-
|
34
|
-
sixarm_ruby_unaccent (~> 1.1)
|
31
|
+
countries (5.3.0)
|
32
|
+
unaccent (~> 0.3)
|
35
33
|
crass (1.0.6)
|
36
34
|
diff-lcs (1.5.0)
|
37
|
-
erubi (1.
|
38
|
-
i18n (1.
|
35
|
+
erubi (1.12.0)
|
36
|
+
i18n (1.12.0)
|
39
37
|
concurrent-ruby (~> 1.0)
|
40
|
-
|
41
|
-
simple_po_parser (~> 1.1)
|
42
|
-
loofah (2.16.0)
|
38
|
+
loofah (2.19.1)
|
43
39
|
crass (~> 1.0.2)
|
44
40
|
nokogiri (>= 1.5.9)
|
45
41
|
method_source (1.0.0)
|
46
|
-
minitest (5.
|
47
|
-
nokogiri (1.
|
42
|
+
minitest (5.17.0)
|
43
|
+
nokogiri (1.14.0.rc1-x86_64-darwin)
|
48
44
|
racc (~> 1.4)
|
49
|
-
nokogiri (1.
|
45
|
+
nokogiri (1.14.0.rc1-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
|
-
racc (1.6.
|
55
|
-
rack (2.2.
|
56
|
-
rack-test (
|
57
|
-
rack (>= 1.
|
50
|
+
racc (1.6.2)
|
51
|
+
rack (2.2.5)
|
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.
|
62
|
-
loofah (~> 2.
|
63
|
-
railties (5.2.
|
64
|
-
actionpack (= 5.2.
|
65
|
-
activesupport (= 5.2.
|
57
|
+
rails-html-sanitizer (1.4.4)
|
58
|
+
loofah (~> 2.19, >= 2.19.1)
|
59
|
+
railties (5.2.8.1)
|
60
|
+
actionpack (= 5.2.8.1)
|
61
|
+
activesupport (= 5.2.8.1)
|
66
62
|
method_source
|
67
63
|
rake (>= 0.8.7)
|
68
64
|
thor (>= 0.19.0, < 2.0)
|
69
65
|
rake (13.0.6)
|
70
|
-
rspec (3.
|
71
|
-
rspec-core (~> 3.
|
72
|
-
rspec-expectations (~> 3.
|
73
|
-
rspec-mocks (~> 3.
|
74
|
-
rspec-core (3.
|
75
|
-
rspec-support (~> 3.
|
76
|
-
rspec-expectations (3.
|
66
|
+
rspec (3.12.0)
|
67
|
+
rspec-core (~> 3.12.0)
|
68
|
+
rspec-expectations (~> 3.12.0)
|
69
|
+
rspec-mocks (~> 3.12.0)
|
70
|
+
rspec-core (3.12.0)
|
71
|
+
rspec-support (~> 3.12.0)
|
72
|
+
rspec-expectations (3.12.1)
|
77
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.
|
79
|
-
rspec-mocks (3.
|
74
|
+
rspec-support (~> 3.12.0)
|
75
|
+
rspec-mocks (3.12.1)
|
80
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.
|
82
|
-
rspec-support (3.
|
83
|
-
simple_po_parser (1.1.6)
|
84
|
-
sixarm_ruby_unaccent (1.2.0)
|
85
|
-
sort_alphabetical (1.1.0)
|
86
|
-
unicode_utils (>= 1.2.2)
|
77
|
+
rspec-support (~> 3.12.0)
|
78
|
+
rspec-support (3.12.0)
|
87
79
|
thor (1.2.1)
|
88
80
|
thread_safe (0.3.6)
|
89
|
-
tzinfo (1.2.
|
81
|
+
tzinfo (1.2.10)
|
90
82
|
thread_safe (~> 0.1)
|
91
|
-
|
83
|
+
unaccent (0.4.0)
|
92
84
|
|
93
85
|
PLATFORMS
|
94
|
-
x86_64-darwin-
|
86
|
+
x86_64-darwin-22
|
95
87
|
x86_64-linux
|
96
88
|
|
97
89
|
DEPENDENCIES
|
98
|
-
actionpack (~> 5.2)
|
90
|
+
actionpack (~> 5.2.0)
|
99
91
|
country_select!
|
92
|
+
nokogiri (= 1.14.0.rc1)
|
100
93
|
pry (~> 0)
|
101
|
-
railties (~> 5.2)
|
94
|
+
railties (~> 5.2.0)
|
102
95
|
rake (~> 13)
|
103
96
|
rspec (~> 3)
|
104
97
|
|
105
98
|
BUNDLED WITH
|
106
|
-
2.
|
99
|
+
2.4.2
|
@@ -1,107 +1,101 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
country_select (
|
4
|
+
country_select (8.0.1)
|
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.
|
12
|
-
actionview (= 6.
|
13
|
-
activesupport (= 6.
|
14
|
-
rack (~> 2.0, >= 2.0.
|
10
|
+
actionpack (6.0.6)
|
11
|
+
actionview (= 6.0.6)
|
12
|
+
activesupport (= 6.0.6)
|
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.
|
19
|
-
activesupport (= 6.
|
17
|
+
actionview (6.0.6)
|
18
|
+
activesupport (= 6.0.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.
|
23
|
+
activesupport (6.0.6)
|
25
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
-
i18n (>=
|
27
|
-
minitest (
|
28
|
-
tzinfo (~>
|
29
|
-
zeitwerk (~> 2.
|
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.
|
34
|
-
|
35
|
-
sixarm_ruby_unaccent (~> 1.1)
|
32
|
+
countries (5.3.0)
|
33
|
+
unaccent (~> 0.3)
|
36
34
|
crass (1.0.6)
|
37
35
|
diff-lcs (1.5.0)
|
38
|
-
erubi (1.
|
39
|
-
i18n (1.
|
36
|
+
erubi (1.12.0)
|
37
|
+
i18n (1.12.0)
|
40
38
|
concurrent-ruby (~> 1.0)
|
41
|
-
|
42
|
-
simple_po_parser (~> 1.1)
|
43
|
-
loofah (2.16.0)
|
39
|
+
loofah (2.19.1)
|
44
40
|
crass (~> 1.0.2)
|
45
41
|
nokogiri (>= 1.5.9)
|
46
42
|
method_source (1.0.0)
|
47
|
-
minitest (5.
|
48
|
-
nokogiri (1.
|
43
|
+
minitest (5.17.0)
|
44
|
+
nokogiri (1.14.0.rc1-x86_64-darwin)
|
49
45
|
racc (~> 1.4)
|
50
|
-
nokogiri (1.
|
46
|
+
nokogiri (1.14.0.rc1-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
|
-
racc (1.6.
|
56
|
-
rack (2.2.
|
57
|
-
rack-test (
|
58
|
-
rack (>= 1.
|
51
|
+
racc (1.6.2)
|
52
|
+
rack (2.2.5)
|
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.
|
63
|
-
loofah (~> 2.
|
64
|
-
railties (6.
|
65
|
-
actionpack (= 6.
|
66
|
-
activesupport (= 6.
|
58
|
+
rails-html-sanitizer (1.4.4)
|
59
|
+
loofah (~> 2.19, >= 2.19.1)
|
60
|
+
railties (6.0.6)
|
61
|
+
actionpack (= 6.0.6)
|
62
|
+
activesupport (= 6.0.6)
|
67
63
|
method_source
|
68
|
-
rake (>= 0.
|
69
|
-
thor (
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
thor (>= 0.20.3, < 2.0)
|
70
66
|
rake (13.0.6)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
75
|
-
rspec-core (3.
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-expectations (3.
|
67
|
+
rspec (3.12.0)
|
68
|
+
rspec-core (~> 3.12.0)
|
69
|
+
rspec-expectations (~> 3.12.0)
|
70
|
+
rspec-mocks (~> 3.12.0)
|
71
|
+
rspec-core (3.12.0)
|
72
|
+
rspec-support (~> 3.12.0)
|
73
|
+
rspec-expectations (3.12.1)
|
78
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
75
|
+
rspec-support (~> 3.12.0)
|
76
|
+
rspec-mocks (3.12.1)
|
81
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
simple_po_parser (1.1.6)
|
85
|
-
sixarm_ruby_unaccent (1.2.0)
|
86
|
-
sort_alphabetical (1.1.0)
|
87
|
-
unicode_utils (>= 1.2.2)
|
78
|
+
rspec-support (~> 3.12.0)
|
79
|
+
rspec-support (3.12.0)
|
88
80
|
thor (1.2.1)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
81
|
+
thread_safe (0.3.6)
|
82
|
+
tzinfo (1.2.10)
|
83
|
+
thread_safe (~> 0.1)
|
84
|
+
unaccent (0.4.0)
|
85
|
+
zeitwerk (2.6.6)
|
93
86
|
|
94
87
|
PLATFORMS
|
95
|
-
x86_64-darwin-
|
88
|
+
x86_64-darwin-22
|
96
89
|
x86_64-linux
|
97
90
|
|
98
91
|
DEPENDENCIES
|
99
|
-
actionpack (~> 6.0)
|
92
|
+
actionpack (~> 6.0.0)
|
100
93
|
country_select!
|
94
|
+
nokogiri (= 1.14.0.rc1)
|
101
95
|
pry (~> 0)
|
102
|
-
railties (~> 6.0)
|
96
|
+
railties (~> 6.0.0)
|
103
97
|
rake (~> 13)
|
104
98
|
rspec (~> 3)
|
105
99
|
|
106
100
|
BUNDLED WITH
|
107
|
-
2.
|
101
|
+
2.4.2
|
@@ -1,27 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
country_select (
|
4
|
+
country_select (8.0.1)
|
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.
|
12
|
-
actionview (= 6.1.
|
13
|
-
activesupport (= 6.1.
|
10
|
+
actionpack (6.1.7)
|
11
|
+
actionview (= 6.1.7)
|
12
|
+
activesupport (= 6.1.7)
|
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.
|
19
|
-
activesupport (= 6.1.
|
17
|
+
actionview (6.1.7)
|
18
|
+
activesupport (= 6.1.7)
|
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.
|
23
|
+
activesupport (6.1.7)
|
25
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
25
|
i18n (>= 1.6, < 2)
|
27
26
|
minitest (>= 5.1)
|
@@ -30,78 +29,72 @@ GEM
|
|
30
29
|
builder (3.2.4)
|
31
30
|
coderay (1.1.3)
|
32
31
|
concurrent-ruby (1.1.10)
|
33
|
-
countries (5.
|
34
|
-
|
35
|
-
sixarm_ruby_unaccent (~> 1.1)
|
32
|
+
countries (5.3.0)
|
33
|
+
unaccent (~> 0.3)
|
36
34
|
crass (1.0.6)
|
37
35
|
diff-lcs (1.5.0)
|
38
|
-
erubi (1.
|
39
|
-
i18n (1.
|
36
|
+
erubi (1.12.0)
|
37
|
+
i18n (1.12.0)
|
40
38
|
concurrent-ruby (~> 1.0)
|
41
|
-
|
42
|
-
simple_po_parser (~> 1.1)
|
43
|
-
loofah (2.16.0)
|
39
|
+
loofah (2.19.1)
|
44
40
|
crass (~> 1.0.2)
|
45
41
|
nokogiri (>= 1.5.9)
|
46
42
|
method_source (1.0.0)
|
47
|
-
minitest (5.
|
48
|
-
nokogiri (1.
|
43
|
+
minitest (5.17.0)
|
44
|
+
nokogiri (1.14.0.rc1-x86_64-darwin)
|
49
45
|
racc (~> 1.4)
|
50
|
-
nokogiri (1.
|
46
|
+
nokogiri (1.14.0.rc1-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
|
-
racc (1.6.
|
56
|
-
rack (2.2.
|
57
|
-
rack-test (
|
58
|
-
rack (>= 1.
|
51
|
+
racc (1.6.2)
|
52
|
+
rack (2.2.5)
|
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.
|
63
|
-
loofah (~> 2.
|
64
|
-
railties (6.1.
|
65
|
-
actionpack (= 6.1.
|
66
|
-
activesupport (= 6.1.
|
58
|
+
rails-html-sanitizer (1.4.4)
|
59
|
+
loofah (~> 2.19, >= 2.19.1)
|
60
|
+
railties (6.1.7)
|
61
|
+
actionpack (= 6.1.7)
|
62
|
+
activesupport (= 6.1.7)
|
67
63
|
method_source
|
68
|
-
rake (>=
|
64
|
+
rake (>= 12.2)
|
69
65
|
thor (~> 1.0)
|
70
66
|
rake (13.0.6)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
75
|
-
rspec-core (3.
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-expectations (3.
|
67
|
+
rspec (3.12.0)
|
68
|
+
rspec-core (~> 3.12.0)
|
69
|
+
rspec-expectations (~> 3.12.0)
|
70
|
+
rspec-mocks (~> 3.12.0)
|
71
|
+
rspec-core (3.12.0)
|
72
|
+
rspec-support (~> 3.12.0)
|
73
|
+
rspec-expectations (3.12.1)
|
78
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
75
|
+
rspec-support (~> 3.12.0)
|
76
|
+
rspec-mocks (3.12.1)
|
81
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
simple_po_parser (1.1.6)
|
85
|
-
sixarm_ruby_unaccent (1.2.0)
|
86
|
-
sort_alphabetical (1.1.0)
|
87
|
-
unicode_utils (>= 1.2.2)
|
78
|
+
rspec-support (~> 3.12.0)
|
79
|
+
rspec-support (3.12.0)
|
88
80
|
thor (1.2.1)
|
89
|
-
tzinfo (2.0.
|
81
|
+
tzinfo (2.0.5)
|
90
82
|
concurrent-ruby (~> 1.0)
|
91
|
-
|
92
|
-
zeitwerk (2.
|
83
|
+
unaccent (0.4.0)
|
84
|
+
zeitwerk (2.6.6)
|
93
85
|
|
94
86
|
PLATFORMS
|
95
|
-
x86_64-darwin-
|
87
|
+
x86_64-darwin-22
|
96
88
|
x86_64-linux
|
97
89
|
|
98
90
|
DEPENDENCIES
|
99
|
-
actionpack (~> 6.1)
|
91
|
+
actionpack (~> 6.1.0)
|
100
92
|
country_select!
|
93
|
+
nokogiri (= 1.14.0.rc1)
|
101
94
|
pry (~> 0)
|
102
|
-
railties (~> 6.1)
|
95
|
+
railties (~> 6.1.0)
|
103
96
|
rake (~> 13)
|
104
97
|
rspec (~> 3)
|
105
98
|
|
106
99
|
BUNDLED WITH
|
107
|
-
2.
|
100
|
+
2.4.2
|
@@ -1,27 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
country_select (
|
4
|
+
country_select (8.0.1)
|
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.
|
12
|
-
actionview (= 7.0.
|
13
|
-
activesupport (= 7.0.
|
10
|
+
actionpack (7.0.4)
|
11
|
+
actionview (= 7.0.4)
|
12
|
+
activesupport (= 7.0.4)
|
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.
|
19
|
-
activesupport (= 7.0.
|
17
|
+
actionview (7.0.4)
|
18
|
+
activesupport (= 7.0.4)
|
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.
|
23
|
+
activesupport (7.0.4)
|
25
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
25
|
i18n (>= 1.6, < 2)
|
27
26
|
minitest (>= 5.1)
|
@@ -29,79 +28,73 @@ GEM
|
|
29
28
|
builder (3.2.4)
|
30
29
|
coderay (1.1.3)
|
31
30
|
concurrent-ruby (1.1.10)
|
32
|
-
countries (5.
|
33
|
-
|
34
|
-
sixarm_ruby_unaccent (~> 1.1)
|
31
|
+
countries (5.3.0)
|
32
|
+
unaccent (~> 0.3)
|
35
33
|
crass (1.0.6)
|
36
34
|
diff-lcs (1.5.0)
|
37
|
-
erubi (1.
|
38
|
-
i18n (1.
|
35
|
+
erubi (1.12.0)
|
36
|
+
i18n (1.12.0)
|
39
37
|
concurrent-ruby (~> 1.0)
|
40
|
-
|
41
|
-
simple_po_parser (~> 1.1)
|
42
|
-
loofah (2.16.0)
|
38
|
+
loofah (2.19.1)
|
43
39
|
crass (~> 1.0.2)
|
44
40
|
nokogiri (>= 1.5.9)
|
45
41
|
method_source (1.0.0)
|
46
|
-
minitest (5.
|
47
|
-
nokogiri (1.
|
42
|
+
minitest (5.17.0)
|
43
|
+
nokogiri (1.14.0.rc1-x86_64-darwin)
|
48
44
|
racc (~> 1.4)
|
49
|
-
nokogiri (1.
|
45
|
+
nokogiri (1.14.0.rc1-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
|
-
racc (1.6.
|
55
|
-
rack (2.2.
|
56
|
-
rack-test (
|
57
|
-
rack (>= 1.
|
50
|
+
racc (1.6.2)
|
51
|
+
rack (2.2.5)
|
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.
|
62
|
-
loofah (~> 2.
|
63
|
-
railties (7.0.
|
64
|
-
actionpack (= 7.0.
|
65
|
-
activesupport (= 7.0.
|
57
|
+
rails-html-sanitizer (1.4.4)
|
58
|
+
loofah (~> 2.19, >= 2.19.1)
|
59
|
+
railties (7.0.4)
|
60
|
+
actionpack (= 7.0.4)
|
61
|
+
activesupport (= 7.0.4)
|
66
62
|
method_source
|
67
63
|
rake (>= 12.2)
|
68
64
|
thor (~> 1.0)
|
69
65
|
zeitwerk (~> 2.5)
|
70
66
|
rake (13.0.6)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
75
|
-
rspec-core (3.
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-expectations (3.
|
67
|
+
rspec (3.12.0)
|
68
|
+
rspec-core (~> 3.12.0)
|
69
|
+
rspec-expectations (~> 3.12.0)
|
70
|
+
rspec-mocks (~> 3.12.0)
|
71
|
+
rspec-core (3.12.0)
|
72
|
+
rspec-support (~> 3.12.0)
|
73
|
+
rspec-expectations (3.12.1)
|
78
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
75
|
+
rspec-support (~> 3.12.0)
|
76
|
+
rspec-mocks (3.12.1)
|
81
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
simple_po_parser (1.1.6)
|
85
|
-
sixarm_ruby_unaccent (1.2.0)
|
86
|
-
sort_alphabetical (1.1.0)
|
87
|
-
unicode_utils (>= 1.2.2)
|
78
|
+
rspec-support (~> 3.12.0)
|
79
|
+
rspec-support (3.12.0)
|
88
80
|
thor (1.2.1)
|
89
|
-
tzinfo (2.0.
|
81
|
+
tzinfo (2.0.5)
|
90
82
|
concurrent-ruby (~> 1.0)
|
91
|
-
|
92
|
-
zeitwerk (2.
|
83
|
+
unaccent (0.4.0)
|
84
|
+
zeitwerk (2.6.6)
|
93
85
|
|
94
86
|
PLATFORMS
|
95
|
-
x86_64-darwin-
|
87
|
+
x86_64-darwin-22
|
96
88
|
x86_64-linux
|
97
89
|
|
98
90
|
DEPENDENCIES
|
99
|
-
actionpack (~> 7.0)
|
91
|
+
actionpack (~> 7.0.0)
|
100
92
|
country_select!
|
93
|
+
nokogiri (= 1.14.0.rc1)
|
101
94
|
pry (~> 0)
|
102
|
-
railties (~> 7.0)
|
95
|
+
railties (~> 7.0.0)
|
103
96
|
rake (~> 13)
|
104
97
|
rspec (~> 3)
|
105
98
|
|
106
99
|
BUNDLED WITH
|
107
|
-
2.
|
100
|
+
2.4.2
|
@@ -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
|
|
@@ -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,
|
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,19 +59,18 @@ module CountrySelect
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def country_options
|
62
|
-
country_options_for(all_country_codes, true)
|
63
|
-
end
|
64
|
-
|
65
|
-
def all_country_codes
|
66
|
-
codes = ISO3166::Country.codes
|
67
|
-
|
68
62
|
if only_country_codes.present?
|
69
|
-
codes &
|
63
|
+
codes = only_country_codes & ISO3166::Country.codes
|
64
|
+
sort = @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided])
|
70
65
|
elsif except_country_codes.present?
|
71
|
-
codes - except_country_codes
|
66
|
+
codes = ISO3166::Country.codes - except_country_codes
|
67
|
+
sort = true
|
72
68
|
else
|
73
|
-
codes
|
69
|
+
codes = ISO3166::Country.codes
|
70
|
+
sort = true
|
74
71
|
end
|
72
|
+
|
73
|
+
country_options_for(codes, sort)
|
75
74
|
end
|
76
75
|
|
77
76
|
def country_options_for(country_codes, sorted=true)
|
@@ -99,11 +98,7 @@ module CountrySelect
|
|
99
98
|
end
|
100
99
|
|
101
100
|
if sorted
|
102
|
-
|
103
|
-
country_list.sort_alphabetical
|
104
|
-
else
|
105
|
-
country_list.sort
|
106
|
-
end
|
101
|
+
country_list.sort_by { |name, code| [I18n.transliterate(name), name] }
|
107
102
|
else
|
108
103
|
country_list
|
109
104
|
end
|
data/lib/country_select.rb
CHANGED
data/spec/country_select_spec.rb
CHANGED
@@ -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,41 @@ 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
|
+
|
143
|
+
it "priority countries with `sort_provided: false` still sorts the non-priority countries by name" do
|
144
|
+
tag = options_for_select(
|
145
|
+
[
|
146
|
+
['Latvia','LV'],
|
147
|
+
['United States','US'],
|
148
|
+
['Denmark', 'DK'],
|
149
|
+
['-'*15,'-'*15],
|
150
|
+
['Afghanistan','AF']
|
151
|
+
],
|
152
|
+
selected: 'AF',
|
153
|
+
disabled: '-'*15
|
154
|
+
)
|
155
|
+
|
156
|
+
walrus.country_code = 'AF'
|
157
|
+
t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'], sort_provided: false)
|
158
|
+
expect(t).to include(tag)
|
159
|
+
end
|
160
|
+
|
109
161
|
describe "when selected options is not an array" do
|
110
162
|
it "selects only the first matching option" do
|
111
163
|
tag = options_for_select([["United States", "US"],["Uruguay", "UY"]], "US")
|
@@ -139,6 +191,18 @@ describe "CountrySelect" do
|
|
139
191
|
expect(t).to_not include(tag)
|
140
192
|
end
|
141
193
|
|
194
|
+
it "countries provided in `only` are sorted by name by default" do
|
195
|
+
t = builder.country_select(:country_code, only: ['PT','DE','AR'])
|
196
|
+
order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
|
197
|
+
expect(order).to eq(['AR', 'DE', 'PT'])
|
198
|
+
end
|
199
|
+
|
200
|
+
it "countries provided in `only` with `sort_provided` to false keeps the order of the provided countries" do
|
201
|
+
t = builder.country_select(:country_code, only: ['PT','DE','AR'], sort_provided: false)
|
202
|
+
order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
|
203
|
+
expect(order).to eq(['PT','DE','AR'])
|
204
|
+
end
|
205
|
+
|
142
206
|
context "when there is a default 'except' configured" do
|
143
207
|
around do |example|
|
144
208
|
old_value = ::CountrySelect::DEFAULTS[:except]
|
@@ -160,9 +224,9 @@ describe "CountrySelect" do
|
|
160
224
|
it "accepts priority countries" do
|
161
225
|
tag = options_for_select(
|
162
226
|
[
|
227
|
+
['Denmark', 'DK'],
|
163
228
|
['Latvia','LV'],
|
164
229
|
['United States','US'],
|
165
|
-
['Denmark', 'DK'],
|
166
230
|
['-'*15,'-'*15]
|
167
231
|
],
|
168
232
|
selected: 'US',
|
@@ -235,23 +299,6 @@ describe "CountrySelect" do
|
|
235
299
|
expect(order).to eq(['AF', 'AX', 'AL', 'ZW'])
|
236
300
|
end
|
237
301
|
|
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
302
|
describe "custom formats" do
|
256
303
|
it "accepts a custom formatter" do
|
257
304
|
::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:
|
4
|
+
version: 8.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Penner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-03 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
|
@@ -156,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
139
|
- !ruby/object:Gem::Version
|
157
140
|
version: '0'
|
158
141
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.4.2
|
160
143
|
signing_key:
|
161
144
|
specification_version: 4
|
162
145
|
summary: Country Select Plugin
|
@@ -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
|