country_select 3.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +14 -28
- data/CHANGELOG.md +22 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +76 -274
- data/README.md +37 -3
- data/Rakefile +3 -1
- data/country_select.gemspec +7 -9
- data/gemfiles/actionpack.edge.gemfile +0 -6
- data/gemfiles/actionpack.edge.gemfile.lock +73 -280
- data/gemfiles/actionpack5.2.gemfile +6 -0
- data/gemfiles/actionpack5.2.gemfile.lock +106 -0
- data/gemfiles/actionpack6.0.gemfile +6 -0
- data/gemfiles/actionpack6.0.gemfile.lock +108 -0
- data/gemfiles/actionpack6.1.gemfile +6 -0
- data/gemfiles/actionpack6.1.gemfile.lock +107 -0
- data/lib/country_select.rb +1 -6
- data/lib/country_select/formats.rb +1 -1
- data/lib/country_select/tag_helper.rb +17 -2
- data/lib/country_select/version.rb +1 -1
- data/lib/country_select_without_sort_alphabetical.rb +8 -0
- data/spec/country_select_spec.rb +26 -3
- metadata +27 -32
- data/gemfiles/actionpack3.2.gemfile +0 -11
- data/gemfiles/actionpack3.2.gemfile.lock +0 -300
- data/gemfiles/actionpack4.0.gemfile +0 -11
- data/gemfiles/actionpack4.0.gemfile.lock +0 -289
- data/gemfiles/actionpack4.1.gemfile +0 -11
- data/gemfiles/actionpack4.1.gemfile.lock +0 -293
- data/gemfiles/actionpack4.2.gemfile +0 -11
- data/gemfiles/actionpack4.2.gemfile.lock +0 -310
- data/gemfiles/actionpack5.0.gemfile +0 -12
- data/gemfiles/actionpack5.0.gemfile.lock +0 -314
- 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.0.0.pre)
|
5
|
+
countries (~> 3.0)
|
6
|
+
sort_alphabetical (~> 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (5.2.4.5)
|
12
|
+
actionview (= 5.2.4.5)
|
13
|
+
activesupport (= 5.2.4.5)
|
14
|
+
rack (~> 2.0, >= 2.0.8)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
+
actionview (5.2.4.5)
|
19
|
+
activesupport (= 5.2.4.5)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
+
activesupport (5.2.4.5)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
builder (3.2.4)
|
30
|
+
coderay (1.1.3)
|
31
|
+
concurrent-ruby (1.1.8)
|
32
|
+
countries (3.0.1)
|
33
|
+
i18n_data (~> 0.10.0)
|
34
|
+
sixarm_ruby_unaccent (~> 1.1)
|
35
|
+
unicode_utils (~> 1.4)
|
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.10.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 (5.2.4.5)
|
64
|
+
actionpack (= 5.2.4.5)
|
65
|
+
activesupport (= 5.2.4.5)
|
66
|
+
method_source
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (>= 0.19.0, < 2.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
|
+
thread_safe (0.3.6)
|
88
|
+
tzinfo (1.2.9)
|
89
|
+
thread_safe (~> 0.1)
|
90
|
+
unicode_utils (1.4.0)
|
91
|
+
wwtd (1.4.1)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
actionpack (~> 5.2.4)
|
98
|
+
country_select!
|
99
|
+
pry (~> 0)
|
100
|
+
railties (~> 5.2.4)
|
101
|
+
rake (~> 13)
|
102
|
+
rspec (~> 3)
|
103
|
+
wwtd (~> 1)
|
104
|
+
|
105
|
+
BUNDLED WITH
|
106
|
+
2.2.13
|
@@ -0,0 +1,108 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
country_select (5.0.0.pre)
|
5
|
+
countries (~> 3.0)
|
6
|
+
sort_alphabetical (~> 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (6.0.3.5)
|
12
|
+
actionview (= 6.0.3.5)
|
13
|
+
activesupport (= 6.0.3.5)
|
14
|
+
rack (~> 2.0, >= 2.0.8)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
+
actionview (6.0.3.5)
|
19
|
+
activesupport (= 6.0.3.5)
|
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.0.3.5)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
30
|
+
builder (3.2.4)
|
31
|
+
coderay (1.1.3)
|
32
|
+
concurrent-ruby (1.1.8)
|
33
|
+
countries (3.0.1)
|
34
|
+
i18n_data (~> 0.10.0)
|
35
|
+
sixarm_ruby_unaccent (~> 1.1)
|
36
|
+
unicode_utils (~> 1.4)
|
37
|
+
crass (1.0.6)
|
38
|
+
diff-lcs (1.4.4)
|
39
|
+
erubi (1.10.0)
|
40
|
+
i18n (1.8.9)
|
41
|
+
concurrent-ruby (~> 1.0)
|
42
|
+
i18n_data (0.10.0)
|
43
|
+
loofah (2.9.0)
|
44
|
+
crass (~> 1.0.2)
|
45
|
+
nokogiri (>= 1.5.9)
|
46
|
+
method_source (1.0.0)
|
47
|
+
mini_portile2 (2.5.0)
|
48
|
+
minitest (5.14.4)
|
49
|
+
nokogiri (1.11.1)
|
50
|
+
mini_portile2 (~> 2.5.0)
|
51
|
+
racc (~> 1.4)
|
52
|
+
pry (0.14.0)
|
53
|
+
coderay (~> 1.1)
|
54
|
+
method_source (~> 1.0)
|
55
|
+
racc (1.5.2)
|
56
|
+
rack (2.2.3)
|
57
|
+
rack-test (1.1.0)
|
58
|
+
rack (>= 1.0, < 3)
|
59
|
+
rails-dom-testing (2.0.3)
|
60
|
+
activesupport (>= 4.2.0)
|
61
|
+
nokogiri (>= 1.6)
|
62
|
+
rails-html-sanitizer (1.3.0)
|
63
|
+
loofah (~> 2.3)
|
64
|
+
railties (6.0.3.5)
|
65
|
+
actionpack (= 6.0.3.5)
|
66
|
+
activesupport (= 6.0.3.5)
|
67
|
+
method_source
|
68
|
+
rake (>= 0.8.7)
|
69
|
+
thor (>= 0.20.3, < 2.0)
|
70
|
+
rake (13.0.3)
|
71
|
+
rspec (3.10.0)
|
72
|
+
rspec-core (~> 3.10.0)
|
73
|
+
rspec-expectations (~> 3.10.0)
|
74
|
+
rspec-mocks (~> 3.10.0)
|
75
|
+
rspec-core (3.10.1)
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-expectations (3.10.1)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-mocks (3.10.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-support (3.10.2)
|
84
|
+
sixarm_ruby_unaccent (1.2.0)
|
85
|
+
sort_alphabetical (1.1.0)
|
86
|
+
unicode_utils (>= 1.2.2)
|
87
|
+
thor (1.1.0)
|
88
|
+
thread_safe (0.3.6)
|
89
|
+
tzinfo (1.2.9)
|
90
|
+
thread_safe (~> 0.1)
|
91
|
+
unicode_utils (1.4.0)
|
92
|
+
wwtd (1.4.1)
|
93
|
+
zeitwerk (2.4.2)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
ruby
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
actionpack (~> 6.0.2)
|
100
|
+
country_select!
|
101
|
+
pry (~> 0)
|
102
|
+
railties (~> 6.0.2)
|
103
|
+
rake (~> 13)
|
104
|
+
rspec (~> 3)
|
105
|
+
wwtd (~> 1)
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
2.2.13
|
@@ -0,0 +1,107 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
country_select (5.0.0.pre)
|
5
|
+
countries (~> 3.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 (3.0.1)
|
34
|
+
i18n_data (~> 0.10.0)
|
35
|
+
sixarm_ruby_unaccent (~> 1.1)
|
36
|
+
unicode_utils (~> 1.4)
|
37
|
+
crass (1.0.6)
|
38
|
+
diff-lcs (1.4.4)
|
39
|
+
erubi (1.10.0)
|
40
|
+
i18n (1.8.9)
|
41
|
+
concurrent-ruby (~> 1.0)
|
42
|
+
i18n_data (0.10.0)
|
43
|
+
loofah (2.9.0)
|
44
|
+
crass (~> 1.0.2)
|
45
|
+
nokogiri (>= 1.5.9)
|
46
|
+
method_source (1.0.0)
|
47
|
+
mini_portile2 (2.5.0)
|
48
|
+
minitest (5.14.4)
|
49
|
+
nokogiri (1.11.1)
|
50
|
+
mini_portile2 (~> 2.5.0)
|
51
|
+
racc (~> 1.4)
|
52
|
+
pry (0.14.0)
|
53
|
+
coderay (~> 1.1)
|
54
|
+
method_source (~> 1.0)
|
55
|
+
racc (1.5.2)
|
56
|
+
rack (2.2.3)
|
57
|
+
rack-test (1.1.0)
|
58
|
+
rack (>= 1.0, < 3)
|
59
|
+
rails-dom-testing (2.0.3)
|
60
|
+
activesupport (>= 4.2.0)
|
61
|
+
nokogiri (>= 1.6)
|
62
|
+
rails-html-sanitizer (1.3.0)
|
63
|
+
loofah (~> 2.3)
|
64
|
+
railties (6.1.3)
|
65
|
+
actionpack (= 6.1.3)
|
66
|
+
activesupport (= 6.1.3)
|
67
|
+
method_source
|
68
|
+
rake (>= 0.8.7)
|
69
|
+
thor (~> 1.0)
|
70
|
+
rake (13.0.3)
|
71
|
+
rspec (3.10.0)
|
72
|
+
rspec-core (~> 3.10.0)
|
73
|
+
rspec-expectations (~> 3.10.0)
|
74
|
+
rspec-mocks (~> 3.10.0)
|
75
|
+
rspec-core (3.10.1)
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-expectations (3.10.1)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-mocks (3.10.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-support (3.10.2)
|
84
|
+
sixarm_ruby_unaccent (1.2.0)
|
85
|
+
sort_alphabetical (1.1.0)
|
86
|
+
unicode_utils (>= 1.2.2)
|
87
|
+
thor (1.1.0)
|
88
|
+
tzinfo (2.0.4)
|
89
|
+
concurrent-ruby (~> 1.0)
|
90
|
+
unicode_utils (1.4.0)
|
91
|
+
wwtd (1.4.1)
|
92
|
+
zeitwerk (2.4.2)
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
actionpack (~> 6.1.0)
|
99
|
+
country_select!
|
100
|
+
pry (~> 0)
|
101
|
+
railties (~> 6.1.0)
|
102
|
+
rake (~> 13)
|
103
|
+
rspec (~> 3)
|
104
|
+
wwtd (~> 1)
|
105
|
+
|
106
|
+
BUNDLED WITH
|
107
|
+
2.2.13
|
data/lib/country_select.rb
CHANGED
@@ -6,9 +6,4 @@ require 'sort_alphabetical'
|
|
6
6
|
require 'country_select/version'
|
7
7
|
require 'country_select/formats'
|
8
8
|
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
|
9
|
+
require 'country_select/country_select_helper'
|
@@ -2,8 +2,19 @@ module CountrySelect
|
|
2
2
|
class CountryNotFoundError < StandardError;end
|
3
3
|
module TagHelper
|
4
4
|
def country_option_tags
|
5
|
+
# In Rails 5.2+, `value` accepts no arguments and must also be called
|
6
|
+
# with parens to avoid the local variable of the same name
|
7
|
+
# https://github.com/rails/rails/pull/29791
|
8
|
+
selected_option = @options.fetch(:selected) do
|
9
|
+
if self.method(:value).arity == 0
|
10
|
+
value()
|
11
|
+
else
|
12
|
+
value(@object)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
5
16
|
option_tags_options = {
|
6
|
-
:selected =>
|
17
|
+
:selected => selected_option,
|
7
18
|
:disabled => @options[:disabled]
|
8
19
|
}
|
9
20
|
|
@@ -89,7 +100,11 @@ module CountrySelect
|
|
89
100
|
end
|
90
101
|
|
91
102
|
if sorted
|
92
|
-
country_list.sort_alphabetical
|
103
|
+
if country_list.respond_to?(:sort_alphabetical)
|
104
|
+
country_list.sort_alphabetical
|
105
|
+
else
|
106
|
+
country_list.sort
|
107
|
+
end
|
93
108
|
else
|
94
109
|
country_list
|
95
110
|
end
|
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)
|
@@ -100,7 +100,6 @@ describe "CountrySelect" do
|
|
100
100
|
|
101
101
|
describe "when selected options is an array" do
|
102
102
|
it "selects all options but only once" do
|
103
|
-
tag = options_for_select([["United States", "US"],["Uruguay", "UY"],["Spain", "ES"]], "US")
|
104
103
|
walrus.country_code = 'US'
|
105
104
|
t = builder.country_select(:country_code, {priority_countries: ['LV','US','ES'], selected: ['UY', 'US']}, multiple: true)
|
106
105
|
expect(t.scan(options_for_select([["United States", "US"]], "US")).length).to be(1)
|
@@ -183,7 +182,14 @@ describe "CountrySelect" do
|
|
183
182
|
end
|
184
183
|
|
185
184
|
it "supports the include_blank option" do
|
186
|
-
|
185
|
+
# Rails 6.1 more closely follows the HTML spec for
|
186
|
+
# empty option tags.
|
187
|
+
# https://github.com/rails/rails/pull/39808
|
188
|
+
tag = if ActionView::VERSION::STRING >= '6.1'
|
189
|
+
'<option value="" label=" "></option>'
|
190
|
+
else
|
191
|
+
'<option value=""></option>'
|
192
|
+
end
|
187
193
|
t = builder.country_select(:country_code, include_blank: true)
|
188
194
|
expect(t).to include(tag)
|
189
195
|
end
|
@@ -195,6 +201,23 @@ describe "CountrySelect" do
|
|
195
201
|
expect(order).to eq(['AF', 'AX', 'AL', 'ZW'])
|
196
202
|
end
|
197
203
|
|
204
|
+
context "without sort_alphabetical" do
|
205
|
+
before do
|
206
|
+
Enumerable.send(:alias_method, :_sort_alphabetical, :sort_alphabetical)
|
207
|
+
Enumerable.send(:remove_method, :sort_alphabetical)
|
208
|
+
end
|
209
|
+
|
210
|
+
after do
|
211
|
+
Enumerable.send(:alias_method, :sort_alphabetical, :_sort_alphabetical)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'falls back to regular sort' do
|
215
|
+
tag = builder.country_select(:country_code, only: ['AX', 'AL', 'AF', 'ZW'])
|
216
|
+
order = tag.scan(/value="(\w{2})"/).map { |o| o[0] }
|
217
|
+
expect(order).to eq(['AF', 'AL', 'ZW', 'AX'])
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
198
221
|
describe "custom formats" do
|
199
222
|
it "accepts a custom formatter" do
|
200
223
|
::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
|