country_select 3.1.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +14 -26
  3. data/CHANGELOG.md +23 -1
  4. data/Gemfile +0 -6
  5. data/Gemfile.lock +63 -267
  6. data/README.md +31 -3
  7. data/Rakefile +3 -1
  8. data/country_select.gemspec +7 -9
  9. data/gemfiles/actionpack.edge.gemfile +0 -6
  10. data/gemfiles/actionpack.edge.gemfile.lock +63 -270
  11. data/gemfiles/actionpack5.2.gemfile +6 -0
  12. data/gemfiles/actionpack5.2.gemfile.lock +106 -0
  13. data/gemfiles/actionpack6.0.gemfile +6 -0
  14. data/gemfiles/actionpack6.0.gemfile.lock +108 -0
  15. data/gemfiles/actionpack6.1.gemfile +6 -0
  16. data/gemfiles/actionpack6.1.gemfile.lock +107 -0
  17. data/lib/country_select.rb +2 -6
  18. data/lib/country_select/defaults.rb +10 -0
  19. data/lib/country_select/formats.rb +3 -1
  20. data/lib/country_select/tag_helper.rb +7 -7
  21. data/lib/country_select/version.rb +1 -1
  22. data/lib/country_select_without_sort_alphabetical.rb +2 -6
  23. data/spec/country_select_spec.rb +43 -3
  24. metadata +27 -34
  25. data/gemfiles/actionpack3.2.gemfile +0 -11
  26. data/gemfiles/actionpack3.2.gemfile.lock +0 -300
  27. data/gemfiles/actionpack4.0.gemfile +0 -11
  28. data/gemfiles/actionpack4.0.gemfile.lock +0 -289
  29. data/gemfiles/actionpack4.1.gemfile +0 -11
  30. data/gemfiles/actionpack4.1.gemfile.lock +0 -293
  31. data/gemfiles/actionpack4.2.gemfile +0 -14
  32. data/gemfiles/actionpack4.2.gemfile.lock +0 -309
  33. data/gemfiles/actionpack5.0.gemfile +0 -12
  34. data/gemfiles/actionpack5.0.gemfile.lock +0 -314
  35. data/gemfiles/actionpack5.1.gemfile +0 -12
  36. data/gemfiles/actionpack5.1.gemfile.lock +0 -314
  37. data/lib/country_select/rails3/country_select_helper.rb +0 -39
@@ -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.1.0)
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.1.0)
33
+ i18n_data (~> 0.11.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.11.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.1.0)
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.1.0)
34
+ i18n_data (~> 0.11.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.11.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.1.0)
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.1.0)
34
+ i18n_data (~> 0.11.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.11.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
@@ -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'
@@ -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
@@ -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
@@ -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
- # called with parens to avoid the local variable of the same name
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] || "-"*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
@@ -1,3 +1,3 @@
1
1
  module CountrySelect
2
- VERSION = "3.1.1"
2
+ VERSION = '5.1.0'
3
3
  end
@@ -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'