country_select 5.0.1 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ country_select (6.1.1)
5
+ countries (~> 4.2)
6
+ sort_alphabetical (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (6.1.4.4)
12
+ actionview (= 6.1.4.4)
13
+ activesupport (= 6.1.4.4)
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.4.4)
19
+ activesupport (= 6.1.4.4)
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.4.4)
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.9)
33
+ countries (4.2.1)
34
+ i18n_data (~> 0.15.0)
35
+ sixarm_ruby_unaccent (~> 1.1)
36
+ crass (1.0.6)
37
+ diff-lcs (1.5.0)
38
+ erubi (1.10.0)
39
+ i18n (1.8.11)
40
+ concurrent-ruby (~> 1.0)
41
+ i18n_data (0.15.0)
42
+ simple_po_parser (~> 1.1)
43
+ loofah (2.13.0)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (1.0.0)
47
+ mini_portile2 (2.7.1)
48
+ minitest (5.15.0)
49
+ nokogiri (1.13.1)
50
+ mini_portile2 (~> 2.7.0)
51
+ racc (~> 1.4)
52
+ nokogiri (1.13.1-arm64-darwin)
53
+ racc (~> 1.4)
54
+ nokogiri (1.13.1-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
+ railties (6.1.4.4)
69
+ actionpack (= 6.1.4.4)
70
+ activesupport (= 6.1.4.4)
71
+ method_source
72
+ rake (>= 0.13)
73
+ thor (~> 1.0)
74
+ rake (13.0.6)
75
+ rspec (3.10.0)
76
+ rspec-core (~> 3.10.0)
77
+ rspec-expectations (~> 3.10.0)
78
+ rspec-mocks (~> 3.10.0)
79
+ rspec-core (3.10.1)
80
+ rspec-support (~> 3.10.0)
81
+ rspec-expectations (3.10.2)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-mocks (3.10.2)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-support (3.10.3)
88
+ simple_po_parser (1.1.5)
89
+ sixarm_ruby_unaccent (1.2.0)
90
+ sort_alphabetical (1.1.0)
91
+ unicode_utils (>= 1.2.2)
92
+ thor (1.2.1)
93
+ tzinfo (2.0.4)
94
+ concurrent-ruby (~> 1.0)
95
+ unicode_utils (1.4.0)
96
+ zeitwerk (2.5.3)
97
+
98
+ PLATFORMS
99
+ arm64-darwin-21
100
+ ruby
101
+ x86_64-linux
102
+
103
+ DEPENDENCIES
104
+ actionpack (~> 6.1)
105
+ country_select!
106
+ pry (~> 0)
107
+ railties (~> 6.1)
108
+ rake (~> 13)
109
+ rspec (~> 3)
110
+
111
+ BUNDLED WITH
112
+ 2.3.3
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "railties", "~> 7.0"
6
+ gem "actionpack", "~> 7.0"
@@ -1,108 +1,112 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- country_select (5.0.1)
5
- countries (~> 3.0)
4
+ country_select (6.1.1)
5
+ countries (~> 4.2)
6
6
  sort_alphabetical (~> 1.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
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)
11
+ actionpack (7.0.1)
12
+ actionview (= 7.0.1)
13
+ activesupport (= 7.0.1)
14
+ rack (~> 2.0, >= 2.2.0)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.0.3.5)
19
- activesupport (= 6.0.3.5)
18
+ actionview (7.0.1)
19
+ activesupport (= 7.0.1)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (6.0.3.5)
24
+ activesupport (7.0.1)
25
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)
26
+ i18n (>= 1.6, < 2)
27
+ minitest (>= 5.1)
28
+ tzinfo (~> 2.0)
30
29
  builder (3.2.4)
31
30
  coderay (1.1.3)
32
- concurrent-ruby (1.1.8)
33
- countries (3.0.1)
34
- i18n_data (~> 0.10.0)
31
+ concurrent-ruby (1.1.9)
32
+ countries (4.2.1)
33
+ i18n_data (~> 0.15.0)
35
34
  sixarm_ruby_unaccent (~> 1.1)
36
- unicode_utils (~> 1.4)
37
35
  crass (1.0.6)
38
- diff-lcs (1.4.4)
36
+ diff-lcs (1.5.0)
39
37
  erubi (1.10.0)
40
- i18n (1.8.9)
38
+ i18n (1.8.11)
41
39
  concurrent-ruby (~> 1.0)
42
- i18n_data (0.10.0)
43
- loofah (2.9.0)
40
+ i18n_data (0.15.0)
41
+ simple_po_parser (~> 1.1)
42
+ loofah (2.13.0)
44
43
  crass (~> 1.0.2)
45
44
  nokogiri (>= 1.5.9)
46
45
  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)
46
+ mini_portile2 (2.7.1)
47
+ minitest (5.15.0)
48
+ nokogiri (1.13.1)
49
+ mini_portile2 (~> 2.7.0)
51
50
  racc (~> 1.4)
52
- pry (0.14.0)
51
+ nokogiri (1.13.1-arm64-darwin)
52
+ racc (~> 1.4)
53
+ nokogiri (1.13.1-x86_64-linux)
54
+ racc (~> 1.4)
55
+ pry (0.14.1)
53
56
  coderay (~> 1.1)
54
57
  method_source (~> 1.0)
55
- racc (1.5.2)
58
+ racc (1.6.0)
56
59
  rack (2.2.3)
57
60
  rack-test (1.1.0)
58
61
  rack (>= 1.0, < 3)
59
62
  rails-dom-testing (2.0.3)
60
63
  activesupport (>= 4.2.0)
61
64
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.3.0)
65
+ rails-html-sanitizer (1.4.2)
63
66
  loofah (~> 2.3)
64
- railties (6.0.3.5)
65
- actionpack (= 6.0.3.5)
66
- activesupport (= 6.0.3.5)
67
+ railties (7.0.1)
68
+ actionpack (= 7.0.1)
69
+ activesupport (= 7.0.1)
67
70
  method_source
68
- rake (>= 0.8.7)
69
- thor (>= 0.20.3, < 2.0)
70
- rake (13.0.3)
71
+ rake (>= 12.2)
72
+ thor (~> 1.0)
73
+ zeitwerk (~> 2.5)
74
+ rake (13.0.6)
71
75
  rspec (3.10.0)
72
76
  rspec-core (~> 3.10.0)
73
77
  rspec-expectations (~> 3.10.0)
74
78
  rspec-mocks (~> 3.10.0)
75
79
  rspec-core (3.10.1)
76
80
  rspec-support (~> 3.10.0)
77
- rspec-expectations (3.10.1)
81
+ rspec-expectations (3.10.2)
78
82
  diff-lcs (>= 1.2.0, < 2.0)
79
83
  rspec-support (~> 3.10.0)
80
84
  rspec-mocks (3.10.2)
81
85
  diff-lcs (>= 1.2.0, < 2.0)
82
86
  rspec-support (~> 3.10.0)
83
- rspec-support (3.10.2)
87
+ rspec-support (3.10.3)
88
+ simple_po_parser (1.1.5)
84
89
  sixarm_ruby_unaccent (1.2.0)
85
90
  sort_alphabetical (1.1.0)
86
91
  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)
92
+ thor (1.2.1)
93
+ tzinfo (2.0.4)
94
+ concurrent-ruby (~> 1.0)
91
95
  unicode_utils (1.4.0)
92
- wwtd (1.4.1)
93
- zeitwerk (2.4.2)
96
+ zeitwerk (2.5.3)
94
97
 
95
98
  PLATFORMS
99
+ arm64-darwin-21
96
100
  ruby
101
+ x86_64-linux
97
102
 
98
103
  DEPENDENCIES
99
- actionpack (~> 6.0.2)
104
+ actionpack (~> 7.0)
100
105
  country_select!
101
106
  pry (~> 0)
102
- railties (~> 6.0.2)
107
+ railties (~> 7.0)
103
108
  rake (~> 13)
104
109
  rspec (~> 3)
105
- wwtd (~> 1)
106
110
 
107
111
  BUNDLED WITH
108
- 2.2.13
112
+ 2.3.3
@@ -1,32 +1,31 @@
1
1
  GIT
2
2
  remote: https://github.com/rails/rails.git
3
- revision: 14f35cde18de77cd7ab5d6f17d83fa8bc92ba383
3
+ revision: 10ef5321c1e0f783b58f26d238cd61145bc3cb96
4
4
  specs:
5
- actionpack (7.0.0.alpha)
6
- actionview (= 7.0.0.alpha)
7
- activesupport (= 7.0.0.alpha)
8
- rack (~> 2.0, >= 2.0.9)
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
9
  rack-test (>= 0.6.3)
10
10
  rails-dom-testing (~> 2.0)
11
11
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
12
- actionview (7.0.0.alpha)
13
- activesupport (= 7.0.0.alpha)
12
+ actionview (7.1.0.alpha)
13
+ activesupport (= 7.1.0.alpha)
14
14
  builder (~> 3.1)
15
15
  erubi (~> 1.4)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
18
- activesupport (7.0.0.alpha)
18
+ activesupport (7.1.0.alpha)
19
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
20
  i18n (>= 1.6, < 2)
21
21
  minitest (>= 5.1)
22
22
  tzinfo (~> 2.0)
23
- zeitwerk (~> 2.3)
24
23
 
25
24
  PATH
26
25
  remote: ..
27
26
  specs:
28
- country_select (5.0.1)
29
- countries (~> 3.0)
27
+ country_select (6.1.1)
28
+ countries (~> 4.2)
30
29
  sort_alphabetical (~> 1.1)
31
30
 
32
31
  GEM
@@ -34,63 +33,68 @@ GEM
34
33
  specs:
35
34
  builder (3.2.4)
36
35
  coderay (1.1.3)
37
- concurrent-ruby (1.1.8)
38
- countries (3.0.1)
39
- i18n_data (~> 0.10.0)
36
+ concurrent-ruby (1.1.9)
37
+ countries (4.2.1)
38
+ i18n_data (~> 0.15.0)
40
39
  sixarm_ruby_unaccent (~> 1.1)
41
- unicode_utils (~> 1.4)
42
40
  crass (1.0.6)
43
- diff-lcs (1.4.4)
41
+ diff-lcs (1.5.0)
44
42
  erubi (1.10.0)
45
- i18n (1.8.9)
43
+ i18n (1.8.11)
46
44
  concurrent-ruby (~> 1.0)
47
- i18n_data (0.10.0)
48
- loofah (2.9.0)
45
+ i18n_data (0.15.0)
46
+ simple_po_parser (~> 1.1)
47
+ loofah (2.13.0)
49
48
  crass (~> 1.0.2)
50
49
  nokogiri (>= 1.5.9)
51
50
  method_source (1.0.0)
52
- mini_portile2 (2.5.0)
53
- minitest (5.14.4)
54
- nokogiri (1.11.1)
55
- mini_portile2 (~> 2.5.0)
51
+ mini_portile2 (2.7.1)
52
+ minitest (5.15.0)
53
+ nokogiri (1.13.1)
54
+ mini_portile2 (~> 2.7.0)
56
55
  racc (~> 1.4)
57
- pry (0.14.0)
56
+ nokogiri (1.13.1-arm64-darwin)
57
+ racc (~> 1.4)
58
+ nokogiri (1.13.1-x86_64-linux)
59
+ racc (~> 1.4)
60
+ pry (0.14.1)
58
61
  coderay (~> 1.1)
59
62
  method_source (~> 1.0)
60
- racc (1.5.2)
63
+ racc (1.6.0)
61
64
  rack (2.2.3)
62
65
  rack-test (1.1.0)
63
66
  rack (>= 1.0, < 3)
64
67
  rails-dom-testing (2.0.3)
65
68
  activesupport (>= 4.2.0)
66
69
  nokogiri (>= 1.6)
67
- rails-html-sanitizer (1.3.0)
70
+ rails-html-sanitizer (1.4.2)
68
71
  loofah (~> 2.3)
69
- rake (13.0.3)
72
+ rake (13.0.6)
70
73
  rspec (3.10.0)
71
74
  rspec-core (~> 3.10.0)
72
75
  rspec-expectations (~> 3.10.0)
73
76
  rspec-mocks (~> 3.10.0)
74
77
  rspec-core (3.10.1)
75
78
  rspec-support (~> 3.10.0)
76
- rspec-expectations (3.10.1)
79
+ rspec-expectations (3.10.2)
77
80
  diff-lcs (>= 1.2.0, < 2.0)
78
81
  rspec-support (~> 3.10.0)
79
82
  rspec-mocks (3.10.2)
80
83
  diff-lcs (>= 1.2.0, < 2.0)
81
84
  rspec-support (~> 3.10.0)
82
- rspec-support (3.10.2)
85
+ rspec-support (3.10.3)
86
+ simple_po_parser (1.1.5)
83
87
  sixarm_ruby_unaccent (1.2.0)
84
88
  sort_alphabetical (1.1.0)
85
89
  unicode_utils (>= 1.2.2)
86
90
  tzinfo (2.0.4)
87
91
  concurrent-ruby (~> 1.0)
88
92
  unicode_utils (1.4.0)
89
- wwtd (1.4.1)
90
- zeitwerk (2.4.2)
91
93
 
92
94
  PLATFORMS
95
+ arm64-darwin-21
93
96
  ruby
97
+ x86_64-linux
94
98
 
95
99
  DEPENDENCIES
96
100
  actionpack!
@@ -100,7 +104,6 @@ DEPENDENCIES
100
104
  pry (~> 0)
101
105
  rake (~> 13)
102
106
  rspec (~> 3)
103
- wwtd (~> 1)
104
107
 
105
108
  BUNDLED WITH
106
- 2.2.13
109
+ 2.3.3
@@ -0,0 +1,10 @@
1
+ module CountrySelect
2
+ DEFAULTS = {
3
+ except: nil,
4
+ format: :default,
5
+ locale: nil,
6
+ only: nil,
7
+ priority_countries: nil,
8
+ priority_countries_divider: "-" * 15
9
+ }
10
+ end
@@ -4,6 +4,6 @@ module CountrySelect
4
4
  FORMATS[:default] = lambda do |country|
5
5
  # Need to use :[] specifically, not :dig, because country.translations is a
6
6
  # ISO3166::Translations object, which overrides :[] to support i18n locale fallbacks
7
- country.translations&.send(:[], I18n.locale.to_s) || country.name
7
+ country.translations&.send(:[], I18n.locale.to_s) || country.iso_short_name
8
8
  end
9
9
  end
@@ -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] || "-"*15
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] || :default
58
+ @options.fetch(:format, ::CountrySelect::DEFAULTS[:format])
59
59
  end
60
60
 
61
61
  def country_options
@@ -79,7 +79,7 @@ module CountrySelect
79
79
  country_list = country_codes.map do |code_or_name|
80
80
  if country = ISO3166::Country.new(code_or_name)
81
81
  code = country.alpha2
82
- elsif country = ISO3166::Country.find_by_name(code_or_name)
82
+ elsif country = ISO3166::Country.find_by_unofficial_names(code_or_name)
83
83
  code = country.first
84
84
  country = ISO3166::Country.new(code)
85
85
  end
@@ -1,3 +1,3 @@
1
1
  module CountrySelect
2
- VERSION = '5.0.1'
2
+ VERSION = '6.1.1'
3
3
  end
@@ -4,6 +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
  require 'country_select/country_select_helper'
@@ -3,6 +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
  require 'country_select/country_select_helper'
@@ -139,6 +139,23 @@ describe "CountrySelect" do
139
139
  expect(t).to_not include(tag)
140
140
  end
141
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
+
142
159
  context "using old 1.x syntax" do
143
160
  it "accepts priority countries" do
144
161
  tag = options_for_select(
@@ -238,7 +255,7 @@ describe "CountrySelect" do
238
255
  describe "custom formats" do
239
256
  it "accepts a custom formatter" do
240
257
  ::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
241
- "#{country.name} (#{country.alpha2})"
258
+ "#{country.iso_short_name} (#{country.alpha2})"
242
259
  end
243
260
 
244
261
  tag = options_for_select([['United States of America (US)', 'US']], 'US')
@@ -250,7 +267,7 @@ describe "CountrySelect" do
250
267
 
251
268
  it "accepts an array for formatter" do
252
269
  ::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
253
- [country.name, country.alpha3]
270
+ [country.iso_short_name, country.alpha3]
254
271
  end
255
272
 
256
273
  tag = options_for_select([['United States of America', 'USA']], 'USA')
@@ -261,7 +278,7 @@ describe "CountrySelect" do
261
278
 
262
279
  it "accepts an array for formatter + custom formatter" do
263
280
  ::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
264
- ["#{country.name} (#{country.alpha2})", country.alpha3]
281
+ ["#{country.iso_short_name} (#{country.alpha2})", country.alpha3]
265
282
  end
266
283
 
267
284
  tag = options_for_select([['United States of America (US)', 'USA']], 'USA')
@@ -272,7 +289,7 @@ describe "CountrySelect" do
272
289
 
273
290
  it "marks priority countries as selected only once" do
274
291
  ::CountrySelect::FORMATS[:with_alpha3] = lambda do |country|
275
- [country.name, country.alpha3]
292
+ [country.iso_short_name, country.alpha3]
276
293
  end
277
294
 
278
295
  tag = options_for_select([['United States of America', 'USA']], 'USA')