country_select 3.1.0 → 5.0.1

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.
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "railties", "~> 5.2.4"
6
+ gem "actionpack", "~> 5.2.4"
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ country_select (5.0.1)
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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "railties", "~> 6.0.2"
6
+ gem "actionpack", "~> 6.0.2"
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ country_select (5.0.1)
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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "railties", "~> 6.1.0"
6
+ gem "actionpack", "~> 6.1.0"
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ country_select (5.0.1)
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
@@ -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,6 +2,8 @@ module CountrySelect
2
2
  FORMATS = {}
3
3
 
4
4
  FORMATS[:default] = lambda do |country|
5
- country.translations[I18n.locale.to_s] || country.name
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
@@ -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 => @options.fetch(:selected) { value(@object) },
17
+ :selected => selected_option,
7
18
  :disabled => @options[:disabled]
8
19
  }
9
20
 
@@ -1,3 +1,3 @@
1
1
  module CountrySelect
2
- VERSION = "3.1.0"
2
+ VERSION = '5.0.1'
3
3
  end
@@ -5,9 +5,4 @@ require 'countries'
5
5
  require 'country_select/version'
6
6
  require 'country_select/formats'
7
7
  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
8
+ require 'country_select/country_select_helper'
@@ -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)
@@ -183,7 +199,14 @@ describe "CountrySelect" do
183
199
  end
184
200
 
185
201
  it "supports the include_blank option" do
186
- tag = '<option value=""></option>'
202
+ # Rails 6.1 more closely follows the HTML spec for
203
+ # empty option tags.
204
+ # https://github.com/rails/rails/pull/39808
205
+ tag = if ActionView::VERSION::STRING >= '6.1'
206
+ '<option value="" label=" "></option>'
207
+ else
208
+ '<option value=""></option>'
209
+ end
187
210
  t = builder.country_select(:country_code, include_blank: true)
188
211
  expect(t).to include(tag)
189
212
  end