country_select 2.2.0 → 2.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +5 -5
- data/README.md +4 -0
- data/country_select.gemspec +1 -1
- data/gemfiles/actionpack.edge.gemfile.lock +6 -6
- data/gemfiles/actionpack3.2.gemfile.lock +6 -6
- data/gemfiles/actionpack4.0.gemfile.lock +6 -6
- data/gemfiles/actionpack4.1.gemfile.lock +6 -6
- data/gemfiles/actionpack4.2.gemfile.lock +6 -6
- data/lib/country_select/tag_helper.rb +9 -5
- data/lib/country_select/version.rb +1 -1
- data/spec/country_select_spec.rb +35 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7d31ad272c6336aa0a415ad32bdb421bbe33a6d
|
|
4
|
+
data.tar.gz: 64e1071b675fe599b8f99fb2b6832ce016b49221
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 164c0d398827142767be0edf6a7a51bfa81779981a8b0d71ac97fda68583069912fca91308393438ab012120bae238b74763dc738f87fb47e3d69b5d5914b5f6
|
|
7
|
+
data.tar.gz: efc072970197346ffc68a40357b4efc4b4266a5fd18f03b1103e946649c7204677b270b0991bcfab18d527654b736761031def0c8a9f733ba90caf092e9cdef4
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -2,7 +2,7 @@ PATH
|
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
4
|
country_select (2.2.0)
|
|
5
|
-
countries (~> 0.
|
|
5
|
+
countries (~> 1.0.0)
|
|
6
6
|
sort_alphabetical (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -26,16 +26,16 @@ GEM
|
|
|
26
26
|
multi_json (~> 1.0)
|
|
27
27
|
builder (3.0.4)
|
|
28
28
|
coderay (1.1.0)
|
|
29
|
-
countries (0.
|
|
29
|
+
countries (1.0.0)
|
|
30
30
|
currencies (~> 0.4.2)
|
|
31
|
-
i18n_data (~> 0.
|
|
31
|
+
i18n_data (~> 0.7.0)
|
|
32
32
|
currencies (0.4.2)
|
|
33
33
|
diff-lcs (1.2.5)
|
|
34
34
|
erubis (2.7.0)
|
|
35
35
|
ffi2-generators (0.1.1)
|
|
36
36
|
hike (1.2.3)
|
|
37
37
|
i18n (0.6.11)
|
|
38
|
-
i18n_data (0.
|
|
38
|
+
i18n_data (0.7.0)
|
|
39
39
|
journey (1.0.4)
|
|
40
40
|
method_source (0.8.2)
|
|
41
41
|
multi_json (1.10.1)
|
|
@@ -266,7 +266,7 @@ GEM
|
|
|
266
266
|
rubysl-yaml (2.0.4)
|
|
267
267
|
rubysl-zlib (2.0.1)
|
|
268
268
|
slop (3.6.0)
|
|
269
|
-
sort_alphabetical (1.0.
|
|
269
|
+
sort_alphabetical (1.0.2)
|
|
270
270
|
unicode_utils (>= 1.2.2)
|
|
271
271
|
sprockets (2.2.2)
|
|
272
272
|
hike (~> 1.2)
|
data/README.md
CHANGED
|
@@ -12,6 +12,10 @@ to evaluate the suitability of this list given their user base.
|
|
|
12
12
|
|
|
13
13
|
[**An important message about upgrading from 1.x**](UPGRADING.md)
|
|
14
14
|
|
|
15
|
+
## Reporting issues
|
|
16
|
+
|
|
17
|
+
Open an issue on the [issue tracker](https://github.com/stefanpenner/country_select/issues/new). Ideally provide versions used, and code example that demonstrates the issue.
|
|
18
|
+
|
|
15
19
|
## Installation
|
|
16
20
|
|
|
17
21
|
Install as a gem using
|
data/country_select.gemspec
CHANGED
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_development_dependency 'rspec', '~> 3'
|
|
26
26
|
s.add_development_dependency 'wwtd'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'countries', '~> 0.
|
|
28
|
+
s.add_dependency 'countries', '~> 1.0.0'
|
|
29
29
|
s.add_dependency 'sort_alphabetical', '~> 1.0'
|
|
30
30
|
end
|
|
@@ -25,8 +25,8 @@ GIT
|
|
|
25
25
|
PATH
|
|
26
26
|
remote: ../
|
|
27
27
|
specs:
|
|
28
|
-
country_select (2.
|
|
29
|
-
countries (~> 0.
|
|
28
|
+
country_select (2.3.0)
|
|
29
|
+
countries (~> 1.0.0)
|
|
30
30
|
sort_alphabetical (~> 1.0)
|
|
31
31
|
|
|
32
32
|
GEM
|
|
@@ -34,15 +34,15 @@ GEM
|
|
|
34
34
|
specs:
|
|
35
35
|
builder (3.2.2)
|
|
36
36
|
coderay (1.1.0)
|
|
37
|
-
countries (0.
|
|
37
|
+
countries (1.0.0)
|
|
38
38
|
currencies (~> 0.4.2)
|
|
39
|
-
i18n_data (~> 0.
|
|
39
|
+
i18n_data (~> 0.7.0)
|
|
40
40
|
currencies (0.4.2)
|
|
41
41
|
diff-lcs (1.2.5)
|
|
42
42
|
erubis (2.7.0)
|
|
43
43
|
ffi2-generators (0.1.1)
|
|
44
44
|
i18n (0.7.0)
|
|
45
|
-
i18n_data (0.
|
|
45
|
+
i18n_data (0.7.0)
|
|
46
46
|
json (1.8.2)
|
|
47
47
|
loofah (2.0.1)
|
|
48
48
|
nokogiri (>= 1.5.9)
|
|
@@ -281,7 +281,7 @@ GEM
|
|
|
281
281
|
rubysl-yaml (2.1.0)
|
|
282
282
|
rubysl-zlib (2.0.1)
|
|
283
283
|
slop (3.6.0)
|
|
284
|
-
sort_alphabetical (1.0.
|
|
284
|
+
sort_alphabetical (1.0.2)
|
|
285
285
|
unicode_utils (>= 1.2.2)
|
|
286
286
|
thread_safe (0.3.4)
|
|
287
287
|
tzinfo (1.2.2)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
country_select (2.
|
|
5
|
-
countries (~> 0.
|
|
4
|
+
country_select (2.3.0)
|
|
5
|
+
countries (~> 1.0.0)
|
|
6
6
|
sort_alphabetical (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -26,16 +26,16 @@ GEM
|
|
|
26
26
|
multi_json (~> 1.0)
|
|
27
27
|
builder (3.0.4)
|
|
28
28
|
coderay (1.1.0)
|
|
29
|
-
countries (0.
|
|
29
|
+
countries (1.0.0)
|
|
30
30
|
currencies (~> 0.4.2)
|
|
31
|
-
i18n_data (~> 0.
|
|
31
|
+
i18n_data (~> 0.7.0)
|
|
32
32
|
currencies (0.4.2)
|
|
33
33
|
diff-lcs (1.2.5)
|
|
34
34
|
erubis (2.7.0)
|
|
35
35
|
ffi2-generators (0.1.1)
|
|
36
36
|
hike (1.2.3)
|
|
37
37
|
i18n (0.7.0)
|
|
38
|
-
i18n_data (0.
|
|
38
|
+
i18n_data (0.7.0)
|
|
39
39
|
journey (1.0.4)
|
|
40
40
|
method_source (0.8.2)
|
|
41
41
|
multi_json (1.10.1)
|
|
@@ -263,7 +263,7 @@ GEM
|
|
|
263
263
|
rubysl-yaml (2.1.0)
|
|
264
264
|
rubysl-zlib (2.0.1)
|
|
265
265
|
slop (3.6.0)
|
|
266
|
-
sort_alphabetical (1.0.
|
|
266
|
+
sort_alphabetical (1.0.2)
|
|
267
267
|
unicode_utils (>= 1.2.2)
|
|
268
268
|
sprockets (2.2.3)
|
|
269
269
|
hike (~> 1.2)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
country_select (2.
|
|
5
|
-
countries (~> 0.
|
|
4
|
+
country_select (2.3.0)
|
|
5
|
+
countries (~> 1.0.0)
|
|
6
6
|
sort_alphabetical (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -22,15 +22,15 @@ GEM
|
|
|
22
22
|
tzinfo (~> 0.3.37)
|
|
23
23
|
builder (3.1.4)
|
|
24
24
|
coderay (1.1.0)
|
|
25
|
-
countries (0.
|
|
25
|
+
countries (1.0.0)
|
|
26
26
|
currencies (~> 0.4.2)
|
|
27
|
-
i18n_data (~> 0.
|
|
27
|
+
i18n_data (~> 0.7.0)
|
|
28
28
|
currencies (0.4.2)
|
|
29
29
|
diff-lcs (1.2.5)
|
|
30
30
|
erubis (2.7.0)
|
|
31
31
|
ffi2-generators (0.1.1)
|
|
32
32
|
i18n (0.7.0)
|
|
33
|
-
i18n_data (0.
|
|
33
|
+
i18n_data (0.7.0)
|
|
34
34
|
method_source (0.8.2)
|
|
35
35
|
minitest (4.7.5)
|
|
36
36
|
multi_json (1.10.1)
|
|
@@ -256,7 +256,7 @@ GEM
|
|
|
256
256
|
rubysl-yaml (2.1.0)
|
|
257
257
|
rubysl-zlib (2.0.1)
|
|
258
258
|
slop (3.6.0)
|
|
259
|
-
sort_alphabetical (1.0.
|
|
259
|
+
sort_alphabetical (1.0.2)
|
|
260
260
|
unicode_utils (>= 1.2.2)
|
|
261
261
|
thread_safe (0.3.4)
|
|
262
262
|
tzinfo (0.3.43)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
country_select (2.
|
|
5
|
-
countries (~> 0.
|
|
4
|
+
country_select (2.3.0)
|
|
5
|
+
countries (~> 1.0.0)
|
|
6
6
|
sort_alphabetical (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -25,15 +25,15 @@ GEM
|
|
|
25
25
|
tzinfo (~> 1.1)
|
|
26
26
|
builder (3.2.2)
|
|
27
27
|
coderay (1.1.0)
|
|
28
|
-
countries (0.
|
|
28
|
+
countries (1.0.0)
|
|
29
29
|
currencies (~> 0.4.2)
|
|
30
|
-
i18n_data (~> 0.
|
|
30
|
+
i18n_data (~> 0.7.0)
|
|
31
31
|
currencies (0.4.2)
|
|
32
32
|
diff-lcs (1.2.5)
|
|
33
33
|
erubis (2.7.0)
|
|
34
34
|
ffi2-generators (0.1.1)
|
|
35
35
|
i18n (0.7.0)
|
|
36
|
-
i18n_data (0.
|
|
36
|
+
i18n_data (0.7.0)
|
|
37
37
|
json (1.8.2)
|
|
38
38
|
method_source (0.8.2)
|
|
39
39
|
minitest (5.5.1)
|
|
@@ -259,7 +259,7 @@ GEM
|
|
|
259
259
|
rubysl-yaml (2.1.0)
|
|
260
260
|
rubysl-zlib (2.0.1)
|
|
261
261
|
slop (3.6.0)
|
|
262
|
-
sort_alphabetical (1.0.
|
|
262
|
+
sort_alphabetical (1.0.2)
|
|
263
263
|
unicode_utils (>= 1.2.2)
|
|
264
264
|
thread_safe (0.3.4)
|
|
265
265
|
tzinfo (1.2.2)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
country_select (2.
|
|
5
|
-
countries (~> 0.
|
|
4
|
+
country_select (2.3.0)
|
|
5
|
+
countries (~> 1.0.0)
|
|
6
6
|
sort_alphabetical (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
@@ -29,15 +29,15 @@ GEM
|
|
|
29
29
|
tzinfo (~> 1.1)
|
|
30
30
|
builder (3.2.2)
|
|
31
31
|
coderay (1.1.0)
|
|
32
|
-
countries (0.
|
|
32
|
+
countries (1.0.0)
|
|
33
33
|
currencies (~> 0.4.2)
|
|
34
|
-
i18n_data (~> 0.
|
|
34
|
+
i18n_data (~> 0.7.0)
|
|
35
35
|
currencies (0.4.2)
|
|
36
36
|
diff-lcs (1.2.5)
|
|
37
37
|
erubis (2.7.0)
|
|
38
38
|
ffi2-generators (0.1.1)
|
|
39
39
|
i18n (0.7.0)
|
|
40
|
-
i18n_data (0.
|
|
40
|
+
i18n_data (0.7.0)
|
|
41
41
|
json (1.8.2)
|
|
42
42
|
loofah (2.0.1)
|
|
43
43
|
nokogiri (>= 1.5.9)
|
|
@@ -281,7 +281,7 @@ GEM
|
|
|
281
281
|
rubysl-yaml (2.1.0)
|
|
282
282
|
rubysl-zlib (2.0.1)
|
|
283
283
|
slop (3.6.0)
|
|
284
|
-
sort_alphabetical (1.0.
|
|
284
|
+
sort_alphabetical (1.0.2)
|
|
285
285
|
unicode_utils (>= 1.2.2)
|
|
286
286
|
thor (0.19.1)
|
|
287
287
|
thread_safe (0.3.4)
|
|
@@ -13,7 +13,7 @@ module CountrySelect
|
|
|
13
13
|
option_tags = options_for_select(priority_countries_options, option_tags_options)
|
|
14
14
|
option_tags += html_safe_newline + options_for_select([priority_countries_divider], disabled: priority_countries_divider)
|
|
15
15
|
|
|
16
|
-
if
|
|
16
|
+
if priority_countries_options.map(&:second).include?(option_tags_options[:selected])
|
|
17
17
|
option_tags_options[:selected] = nil
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -53,7 +53,7 @@ module CountrySelect
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def all_country_codes
|
|
56
|
-
codes = ISO3166::Country.
|
|
56
|
+
codes = ISO3166::Country.codes
|
|
57
57
|
|
|
58
58
|
if only_country_codes.present?
|
|
59
59
|
codes & only_country_codes
|
|
@@ -79,9 +79,14 @@ module CountrySelect
|
|
|
79
79
|
raise CountryNotFoundError.new(msg)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
formatted_country = ::CountrySelect::FORMATS[format].call(country)
|
|
83
|
+
|
|
84
|
+
if formatted_country.is_a?(Array)
|
|
85
|
+
formatted_country
|
|
86
|
+
else
|
|
87
|
+
[formatted_country, code]
|
|
88
|
+
end
|
|
83
89
|
|
|
84
|
-
[name,code]
|
|
85
90
|
end
|
|
86
91
|
|
|
87
92
|
if sorted
|
|
@@ -97,4 +102,3 @@ module CountrySelect
|
|
|
97
102
|
end
|
|
98
103
|
end
|
|
99
104
|
end
|
|
100
|
-
|
data/spec/country_select_spec.rb
CHANGED
|
@@ -143,9 +143,9 @@ describe "CountrySelect" do
|
|
|
143
143
|
"United Kingdom",
|
|
144
144
|
"Mexico",
|
|
145
145
|
"Australia",
|
|
146
|
-
"
|
|
146
|
+
"Freedonia"
|
|
147
147
|
]
|
|
148
|
-
error_msg = "Could not find Country with string '
|
|
148
|
+
error_msg = "Could not find Country with string 'Freedonia'"
|
|
149
149
|
|
|
150
150
|
expect do
|
|
151
151
|
builder.country_select(:country_code, country_names)
|
|
@@ -183,5 +183,38 @@ describe "CountrySelect" do
|
|
|
183
183
|
t = builder.country_select(:country_code, format: :with_alpha2)
|
|
184
184
|
expect(t).to include(tag)
|
|
185
185
|
end
|
|
186
|
+
|
|
187
|
+
it "accepts an array for formatter" do
|
|
188
|
+
::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
|
|
189
|
+
[country.name, country.alpha3]
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
tag = options_for_select([['United States', 'USA']], 'USA')
|
|
193
|
+
walrus.country_code = 'USA'
|
|
194
|
+
t = builder.country_select(:country_code, format: :with_alpha3)
|
|
195
|
+
expect(t).to include(tag)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "accepts an array for formatter + custom formatter" do
|
|
199
|
+
::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
|
|
200
|
+
["#{country.name} (#{country.alpha2})", country.alpha3]
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
tag = options_for_select([['United States (US)', 'USA']], 'USA')
|
|
204
|
+
walrus.country_code = 'USA'
|
|
205
|
+
t = builder.country_select(:country_code, format: :with_alpha3)
|
|
206
|
+
expect(t).to include(tag)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
it "marks priority countries as selected only once" do
|
|
210
|
+
::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
|
|
211
|
+
[country.name, country.alpha3]
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
tag = options_for_select([['United States', 'USA']], 'USA')
|
|
215
|
+
walrus.country_code = 'USA'
|
|
216
|
+
t = builder.country_select(:country_code, format: :with_alpha3, priority_countries: ['US'])
|
|
217
|
+
expect(t.scan(Regexp.new(Regexp.escape(tag))).size).to eq 1
|
|
218
|
+
end
|
|
186
219
|
end
|
|
187
220
|
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: 2.
|
|
4
|
+
version: 2.3.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: 2015-
|
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -86,14 +86,14 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
89
|
+
version: 1.0.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: 0.
|
|
96
|
+
version: 1.0.0
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: sort_alphabetical
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|