country_select 4.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -31
- data/CHANGELOG.md +21 -0
- data/Gemfile +0 -6
- data/Gemfile.lock +63 -265
- data/README.md +15 -2
- data/Rakefile +3 -1
- data/country_select.gemspec +7 -9
- data/gemfiles/actionpack.edge.gemfile +0 -6
- data/gemfiles/actionpack.edge.gemfile.lock +63 -268
- data/gemfiles/actionpack5.2.gemfile +2 -8
- data/gemfiles/actionpack5.2.gemfile.lock +59 -266
- data/gemfiles/actionpack6.0.gemfile +6 -0
- data/gemfiles/actionpack6.0.gemfile.lock +107 -0
- data/gemfiles/actionpack6.1.gemfile +6 -0
- data/gemfiles/actionpack6.1.gemfile.lock +106 -0
- data/lib/country_select.rb +2 -6
- data/lib/country_select/defaults.rb +10 -0
- data/lib/country_select/formats.rb +3 -1
- data/lib/country_select/tag_helper.rb +7 -7
- data/lib/country_select/version.rb +1 -1
- data/lib/country_select_without_sort_alphabetical.rb +2 -6
- data/spec/country_select_spec.rb +43 -3
- metadata +25 -34
- data/gemfiles/actionpack3.2.gemfile +0 -11
- data/gemfiles/actionpack3.2.gemfile.lock +0 -297
- data/gemfiles/actionpack4.0.gemfile +0 -11
- data/gemfiles/actionpack4.0.gemfile.lock +0 -286
- data/gemfiles/actionpack4.1.gemfile +0 -11
- data/gemfiles/actionpack4.1.gemfile.lock +0 -290
- data/gemfiles/actionpack4.2.gemfile +0 -14
- data/gemfiles/actionpack4.2.gemfile.lock +0 -306
- data/gemfiles/actionpack5.0.gemfile +0 -12
- data/gemfiles/actionpack5.0.gemfile.lock +0 -311
- data/gemfiles/actionpack5.1.gemfile +0 -12
- data/gemfiles/actionpack5.1.gemfile.lock +0 -311
- data/lib/country_select/rails3/country_select_helper.rb +0 -39
@@ -0,0 +1,106 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
country_select (5.1.0)
|
5
|
+
countries (~> 4.0)
|
6
|
+
sort_alphabetical (~> 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (6.1.3)
|
12
|
+
actionview (= 6.1.3)
|
13
|
+
activesupport (= 6.1.3)
|
14
|
+
rack (~> 2.0, >= 2.0.9)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
+
actionview (6.1.3)
|
19
|
+
activesupport (= 6.1.3)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
+
activesupport (6.1.3)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 1.6, < 2)
|
27
|
+
minitest (>= 5.1)
|
28
|
+
tzinfo (~> 2.0)
|
29
|
+
zeitwerk (~> 2.3)
|
30
|
+
builder (3.2.4)
|
31
|
+
coderay (1.1.3)
|
32
|
+
concurrent-ruby (1.1.8)
|
33
|
+
countries (4.0.0)
|
34
|
+
i18n_data (~> 0.13.0)
|
35
|
+
sixarm_ruby_unaccent (~> 1.1)
|
36
|
+
crass (1.0.6)
|
37
|
+
diff-lcs (1.4.4)
|
38
|
+
erubi (1.10.0)
|
39
|
+
i18n (1.8.9)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
i18n_data (0.13.0)
|
42
|
+
loofah (2.9.0)
|
43
|
+
crass (~> 1.0.2)
|
44
|
+
nokogiri (>= 1.5.9)
|
45
|
+
method_source (1.0.0)
|
46
|
+
mini_portile2 (2.5.0)
|
47
|
+
minitest (5.14.4)
|
48
|
+
nokogiri (1.11.1)
|
49
|
+
mini_portile2 (~> 2.5.0)
|
50
|
+
racc (~> 1.4)
|
51
|
+
pry (0.14.0)
|
52
|
+
coderay (~> 1.1)
|
53
|
+
method_source (~> 1.0)
|
54
|
+
racc (1.5.2)
|
55
|
+
rack (2.2.3)
|
56
|
+
rack-test (1.1.0)
|
57
|
+
rack (>= 1.0, < 3)
|
58
|
+
rails-dom-testing (2.0.3)
|
59
|
+
activesupport (>= 4.2.0)
|
60
|
+
nokogiri (>= 1.6)
|
61
|
+
rails-html-sanitizer (1.3.0)
|
62
|
+
loofah (~> 2.3)
|
63
|
+
railties (6.1.3)
|
64
|
+
actionpack (= 6.1.3)
|
65
|
+
activesupport (= 6.1.3)
|
66
|
+
method_source
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (~> 1.0)
|
69
|
+
rake (13.0.3)
|
70
|
+
rspec (3.10.0)
|
71
|
+
rspec-core (~> 3.10.0)
|
72
|
+
rspec-expectations (~> 3.10.0)
|
73
|
+
rspec-mocks (~> 3.10.0)
|
74
|
+
rspec-core (3.10.1)
|
75
|
+
rspec-support (~> 3.10.0)
|
76
|
+
rspec-expectations (3.10.1)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (~> 3.10.0)
|
79
|
+
rspec-mocks (3.10.2)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.10.0)
|
82
|
+
rspec-support (3.10.2)
|
83
|
+
sixarm_ruby_unaccent (1.2.0)
|
84
|
+
sort_alphabetical (1.1.0)
|
85
|
+
unicode_utils (>= 1.2.2)
|
86
|
+
thor (1.1.0)
|
87
|
+
tzinfo (2.0.4)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
|
+
unicode_utils (1.4.0)
|
90
|
+
wwtd (1.4.1)
|
91
|
+
zeitwerk (2.4.2)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
actionpack (~> 6.1.0)
|
98
|
+
country_select!
|
99
|
+
pry (~> 0)
|
100
|
+
railties (~> 6.1.0)
|
101
|
+
rake (~> 13)
|
102
|
+
rspec (~> 3)
|
103
|
+
wwtd (~> 1)
|
104
|
+
|
105
|
+
BUNDLED WITH
|
106
|
+
2.2.15
|
data/lib/country_select.rb
CHANGED
@@ -4,11 +4,7 @@ require 'countries'
|
|
4
4
|
require 'sort_alphabetical'
|
5
5
|
|
6
6
|
require 'country_select/version'
|
7
|
+
require 'country_select/defaults'
|
7
8
|
require 'country_select/formats'
|
8
9
|
require 'country_select/tag_helper'
|
9
|
-
|
10
|
-
if defined?(ActionView::Helpers::Tags::Base)
|
11
|
-
require 'country_select/country_select_helper'
|
12
|
-
else
|
13
|
-
require 'country_select/rails3/country_select_helper'
|
14
|
-
end
|
10
|
+
require 'country_select/country_select_helper'
|
@@ -2,6 +2,8 @@ module CountrySelect
|
|
2
2
|
FORMATS = {}
|
3
3
|
|
4
4
|
FORMATS[:default] = lambda do |country|
|
5
|
-
|
5
|
+
# Need to use :[] specifically, not :dig, because country.translations is a
|
6
|
+
# ISO3166::Translations object, which overrides :[] to support i18n locale fallbacks
|
7
|
+
country.translations&.send(:[], I18n.locale.to_s) || country.name
|
6
8
|
end
|
7
9
|
end
|
@@ -3,7 +3,7 @@ module CountrySelect
|
|
3
3
|
module TagHelper
|
4
4
|
def country_option_tags
|
5
5
|
# In Rails 5.2+, `value` accepts no arguments and must also be called
|
6
|
-
#
|
6
|
+
# with parens to avoid the local variable of the same name
|
7
7
|
# https://github.com/rails/rails/pull/29791
|
8
8
|
selected_option = @options.fetch(:selected) do
|
9
9
|
if self.method(:value).arity == 0
|
@@ -35,27 +35,27 @@ module CountrySelect
|
|
35
35
|
|
36
36
|
private
|
37
37
|
def locale
|
38
|
-
@options[:locale]
|
38
|
+
@options.fetch(:locale, ::CountrySelect::DEFAULTS[:locale])
|
39
39
|
end
|
40
40
|
|
41
41
|
def priority_countries
|
42
|
-
@options[:priority_countries]
|
42
|
+
@options.fetch(:priority_countries, ::CountrySelect::DEFAULTS[:priority_countries])
|
43
43
|
end
|
44
44
|
|
45
45
|
def priority_countries_divider
|
46
|
-
@options[:priority_countries_divider]
|
46
|
+
@options.fetch(:priority_countries_divider, ::CountrySelect::DEFAULTS[:priority_countries_divider])
|
47
47
|
end
|
48
48
|
|
49
49
|
def only_country_codes
|
50
|
-
@options[:only]
|
50
|
+
@options.fetch(:only, ::CountrySelect::DEFAULTS[:only])
|
51
51
|
end
|
52
52
|
|
53
53
|
def except_country_codes
|
54
|
-
@options[:except]
|
54
|
+
@options.fetch(:except, ::CountrySelect::DEFAULTS[:except])
|
55
55
|
end
|
56
56
|
|
57
57
|
def format
|
58
|
-
@options[:format]
|
58
|
+
@options.fetch(:format, ::CountrySelect::DEFAULTS[:format])
|
59
59
|
end
|
60
60
|
|
61
61
|
def country_options
|
@@ -3,11 +3,7 @@
|
|
3
3
|
require 'countries'
|
4
4
|
|
5
5
|
require 'country_select/version'
|
6
|
+
require 'country_select/defaults'
|
6
7
|
require 'country_select/formats'
|
7
8
|
require 'country_select/tag_helper'
|
8
|
-
|
9
|
-
if defined?(ActionView::Helpers::Tags::Base)
|
10
|
-
require 'country_select/country_select_helper'
|
11
|
-
else
|
12
|
-
require 'country_select/rails3/country_select_helper'
|
13
|
-
end
|
9
|
+
require 'country_select/country_select_helper'
|
data/spec/country_select_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe "CountrySelect" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:walrus) { Walrus.new }
|
23
|
-
let!(:template) { ActionView::Base.new }
|
23
|
+
let!(:template) { ActionView::Base.new(ActionView::LookupContext.new([]), {}, nil) }
|
24
24
|
|
25
25
|
let(:builder) do
|
26
26
|
if defined?(ActionView::Helpers::Tags::Base)
|
@@ -61,6 +61,23 @@ describe "CountrySelect" do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'falls back when given a country-specific locale' do
|
65
|
+
I18n.available_locales = [:en, :de, :'de-AT']
|
66
|
+
ISO3166.reset
|
67
|
+
|
68
|
+
tag = options_for_select([['Deutschland', 'DE']], 'DE')
|
69
|
+
|
70
|
+
walrus.country_code = 'DE'
|
71
|
+
original_locale = I18n.locale
|
72
|
+
begin
|
73
|
+
I18n.locale = :'de-AT'
|
74
|
+
t = builder.country_select(:country_code)
|
75
|
+
expect(t).to include(tag)
|
76
|
+
ensure
|
77
|
+
I18n.locale = original_locale
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
64
81
|
it "accepts a locale option" do
|
65
82
|
I18n.available_locales = [:fr]
|
66
83
|
ISO3166.reset
|
@@ -100,7 +117,6 @@ describe "CountrySelect" do
|
|
100
117
|
|
101
118
|
describe "when selected options is an array" do
|
102
119
|
it "selects all options but only once" do
|
103
|
-
tag = options_for_select([["United States", "US"],["Uruguay", "UY"],["Spain", "ES"]], "US")
|
104
120
|
walrus.country_code = 'US'
|
105
121
|
t = builder.country_select(:country_code, {priority_countries: ['LV','US','ES'], selected: ['UY', 'US']}, multiple: true)
|
106
122
|
expect(t.scan(options_for_select([["United States", "US"]], "US")).length).to be(1)
|
@@ -123,6 +139,23 @@ describe "CountrySelect" do
|
|
123
139
|
expect(t).to_not include(tag)
|
124
140
|
end
|
125
141
|
|
142
|
+
context "when there is a default 'except' configured" do
|
143
|
+
around do |example|
|
144
|
+
old_value = ::CountrySelect::DEFAULTS[:except]
|
145
|
+
example.run
|
146
|
+
::CountrySelect::DEFAULTS[:except] = old_value
|
147
|
+
end
|
148
|
+
|
149
|
+
it "discards countries when configured to" do
|
150
|
+
::CountrySelect::DEFAULTS[:except] = ['US']
|
151
|
+
|
152
|
+
tag = options_for_select([['United States', 'US']])
|
153
|
+
walrus.country_code = 'DE'
|
154
|
+
t = builder.country_select(:country_code)
|
155
|
+
expect(t).to_not include(tag)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
126
159
|
context "using old 1.x syntax" do
|
127
160
|
it "accepts priority countries" do
|
128
161
|
tag = options_for_select(
|
@@ -183,7 +216,14 @@ describe "CountrySelect" do
|
|
183
216
|
end
|
184
217
|
|
185
218
|
it "supports the include_blank option" do
|
186
|
-
|
219
|
+
# Rails 6.1 more closely follows the HTML spec for
|
220
|
+
# empty option tags.
|
221
|
+
# https://github.com/rails/rails/pull/39808
|
222
|
+
tag = if ActionView::VERSION::STRING >= '6.1'
|
223
|
+
'<option value="" label=" "></option>'
|
224
|
+
else
|
225
|
+
'<option value=""></option>'
|
226
|
+
end
|
187
227
|
t = builder.country_select(:country_code, include_blank: true)
|
188
228
|
expect(t).to include(tag)
|
189
229
|
end
|
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: 6.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:
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,46 +70,46 @@ dependencies:
|
|
70
70
|
name: wwtd
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: countries
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '4.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '4.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sort_alphabetical
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
111
|
-
description: Provides a simple helper to get an HTML select list of countries.
|
112
|
-
list of countries comes from the ISO 3166 standard.
|
110
|
+
version: '1.1'
|
111
|
+
description: Provides a simple helper to get an HTML select list of countries. The
|
112
|
+
list of countries comes from the ISO 3166 standard. While it is a relatively neutral
|
113
113
|
source of country names, it will still offend some users.
|
114
114
|
email:
|
115
115
|
- stefan.penner@gmail.com
|
@@ -130,24 +130,16 @@ files:
|
|
130
130
|
- country_select.gemspec
|
131
131
|
- gemfiles/actionpack.edge.gemfile
|
132
132
|
- gemfiles/actionpack.edge.gemfile.lock
|
133
|
-
- gemfiles/actionpack3.2.gemfile
|
134
|
-
- gemfiles/actionpack3.2.gemfile.lock
|
135
|
-
- gemfiles/actionpack4.0.gemfile
|
136
|
-
- gemfiles/actionpack4.0.gemfile.lock
|
137
|
-
- gemfiles/actionpack4.1.gemfile
|
138
|
-
- gemfiles/actionpack4.1.gemfile.lock
|
139
|
-
- gemfiles/actionpack4.2.gemfile
|
140
|
-
- gemfiles/actionpack4.2.gemfile.lock
|
141
|
-
- gemfiles/actionpack5.0.gemfile
|
142
|
-
- gemfiles/actionpack5.0.gemfile.lock
|
143
|
-
- gemfiles/actionpack5.1.gemfile
|
144
|
-
- gemfiles/actionpack5.1.gemfile.lock
|
145
133
|
- gemfiles/actionpack5.2.gemfile
|
146
134
|
- gemfiles/actionpack5.2.gemfile.lock
|
135
|
+
- gemfiles/actionpack6.0.gemfile
|
136
|
+
- gemfiles/actionpack6.0.gemfile.lock
|
137
|
+
- gemfiles/actionpack6.1.gemfile
|
138
|
+
- gemfiles/actionpack6.1.gemfile.lock
|
147
139
|
- lib/country_select.rb
|
148
140
|
- lib/country_select/country_select_helper.rb
|
141
|
+
- lib/country_select/defaults.rb
|
149
142
|
- lib/country_select/formats.rb
|
150
|
-
- lib/country_select/rails3/country_select_helper.rb
|
151
143
|
- lib/country_select/tag_helper.rb
|
152
144
|
- lib/country_select/version.rb
|
153
145
|
- lib/country_select_without_sort_alphabetical.rb
|
@@ -165,15 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
157
|
requirements:
|
166
158
|
- - ">="
|
167
159
|
- !ruby/object:Gem::Version
|
168
|
-
version: '2'
|
160
|
+
version: '2.5'
|
169
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
162
|
requirements:
|
171
163
|
- - ">="
|
172
164
|
- !ruby/object:Gem::Version
|
173
165
|
version: '0'
|
174
166
|
requirements: []
|
175
|
-
|
176
|
-
rubygems_version: 2.7.6
|
167
|
+
rubygems_version: 3.2.13
|
177
168
|
signing_key:
|
178
169
|
specification_version: 4
|
179
170
|
summary: Country Select Plugin
|