country_select 8.0.1 → 8.0.2

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.
@@ -7,20 +7,20 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (6.1.7)
11
- actionview (= 6.1.7)
12
- activesupport (= 6.1.7)
10
+ actionpack (6.1.7.3)
11
+ actionview (= 6.1.7.3)
12
+ activesupport (= 6.1.7.3)
13
13
  rack (~> 2.0, >= 2.0.9)
14
14
  rack-test (>= 0.6.3)
15
15
  rails-dom-testing (~> 2.0)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (6.1.7)
18
- activesupport (= 6.1.7)
17
+ actionview (6.1.7.3)
18
+ activesupport (= 6.1.7.3)
19
19
  builder (~> 3.1)
20
20
  erubi (~> 1.4)
21
21
  rails-dom-testing (~> 2.0)
22
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activesupport (6.1.7)
23
+ activesupport (6.1.7.3)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 1.6, < 2)
26
26
  minitest (>= 5.1)
@@ -28,38 +28,41 @@ GEM
28
28
  zeitwerk (~> 2.3)
29
29
  builder (3.2.4)
30
30
  coderay (1.1.3)
31
- concurrent-ruby (1.1.10)
32
- countries (5.3.0)
31
+ concurrent-ruby (1.2.2)
32
+ countries (5.4.0)
33
33
  unaccent (~> 0.3)
34
34
  crass (1.0.6)
35
35
  diff-lcs (1.5.0)
36
+ docile (1.4.0)
36
37
  erubi (1.12.0)
37
- i18n (1.12.0)
38
+ i18n (1.13.0)
38
39
  concurrent-ruby (~> 1.0)
39
- loofah (2.19.1)
40
+ loofah (2.20.0)
40
41
  crass (~> 1.0.2)
41
42
  nokogiri (>= 1.5.9)
42
43
  method_source (1.0.0)
43
- minitest (5.17.0)
44
+ minitest (5.18.0)
45
+ nokogiri (1.14.0.rc1-arm64-darwin)
46
+ racc (~> 1.4)
44
47
  nokogiri (1.14.0.rc1-x86_64-darwin)
45
48
  racc (~> 1.4)
46
49
  nokogiri (1.14.0.rc1-x86_64-linux)
47
50
  racc (~> 1.4)
48
- pry (0.14.1)
51
+ pry (0.14.2)
49
52
  coderay (~> 1.1)
50
53
  method_source (~> 1.0)
51
54
  racc (1.6.2)
52
- rack (2.2.5)
53
- rack-test (2.0.2)
55
+ rack (2.2.7)
56
+ rack-test (2.1.0)
54
57
  rack (>= 1.3)
55
58
  rails-dom-testing (2.0.3)
56
59
  activesupport (>= 4.2.0)
57
60
  nokogiri (>= 1.6)
58
- rails-html-sanitizer (1.4.4)
61
+ rails-html-sanitizer (1.5.0)
59
62
  loofah (~> 2.19, >= 2.19.1)
60
- railties (6.1.7)
61
- actionpack (= 6.1.7)
62
- activesupport (= 6.1.7)
63
+ railties (6.1.7.3)
64
+ actionpack (= 6.1.7.3)
65
+ activesupport (= 6.1.7.3)
63
66
  method_source
64
67
  rake (>= 12.2)
65
68
  thor (~> 1.0)
@@ -68,22 +71,29 @@ GEM
68
71
  rspec-core (~> 3.12.0)
69
72
  rspec-expectations (~> 3.12.0)
70
73
  rspec-mocks (~> 3.12.0)
71
- rspec-core (3.12.0)
74
+ rspec-core (3.12.2)
72
75
  rspec-support (~> 3.12.0)
73
- rspec-expectations (3.12.1)
76
+ rspec-expectations (3.12.3)
74
77
  diff-lcs (>= 1.2.0, < 2.0)
75
78
  rspec-support (~> 3.12.0)
76
- rspec-mocks (3.12.1)
79
+ rspec-mocks (3.12.5)
77
80
  diff-lcs (>= 1.2.0, < 2.0)
78
81
  rspec-support (~> 3.12.0)
79
82
  rspec-support (3.12.0)
83
+ simplecov (0.22.0)
84
+ docile (~> 1.1)
85
+ simplecov-html (~> 0.11)
86
+ simplecov_json_formatter (~> 0.1)
87
+ simplecov-html (0.12.3)
88
+ simplecov_json_formatter (0.1.4)
80
89
  thor (1.2.1)
81
- tzinfo (2.0.5)
90
+ tzinfo (2.0.6)
82
91
  concurrent-ruby (~> 1.0)
83
92
  unaccent (0.4.0)
84
- zeitwerk (2.6.6)
93
+ zeitwerk (2.6.8)
85
94
 
86
95
  PLATFORMS
96
+ arm64-darwin-22
87
97
  x86_64-darwin-22
88
98
  x86_64-linux
89
99
 
@@ -95,6 +105,7 @@ DEPENDENCIES
95
105
  railties (~> 6.1.0)
96
106
  rake (~> 13)
97
107
  rspec (~> 3)
108
+ simplecov (~> 0.22)
98
109
 
99
110
  BUNDLED WITH
100
111
  2.4.2
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gemspec :path => "../"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "railties", "~> 7.0.0"
6
- gem "actionpack", "~> 7.0.0"
5
+ gemspec path: '../'
6
+
7
+ gem 'railties', '~> 7.0.0'
8
+ gem 'actionpack', '~> 7.0.0'
7
9
  gem 'nokogiri', '= 1.14.0.rc1'
@@ -7,58 +7,61 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (7.0.4)
11
- actionview (= 7.0.4)
12
- activesupport (= 7.0.4)
10
+ actionpack (7.0.4.3)
11
+ actionview (= 7.0.4.3)
12
+ activesupport (= 7.0.4.3)
13
13
  rack (~> 2.0, >= 2.2.0)
14
14
  rack-test (>= 0.6.3)
15
15
  rails-dom-testing (~> 2.0)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (7.0.4)
18
- activesupport (= 7.0.4)
17
+ actionview (7.0.4.3)
18
+ activesupport (= 7.0.4.3)
19
19
  builder (~> 3.1)
20
20
  erubi (~> 1.4)
21
21
  rails-dom-testing (~> 2.0)
22
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activesupport (7.0.4)
23
+ activesupport (7.0.4.3)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 1.6, < 2)
26
26
  minitest (>= 5.1)
27
27
  tzinfo (~> 2.0)
28
28
  builder (3.2.4)
29
29
  coderay (1.1.3)
30
- concurrent-ruby (1.1.10)
31
- countries (5.3.0)
30
+ concurrent-ruby (1.2.2)
31
+ countries (5.4.0)
32
32
  unaccent (~> 0.3)
33
33
  crass (1.0.6)
34
34
  diff-lcs (1.5.0)
35
+ docile (1.4.0)
35
36
  erubi (1.12.0)
36
- i18n (1.12.0)
37
+ i18n (1.13.0)
37
38
  concurrent-ruby (~> 1.0)
38
- loofah (2.19.1)
39
+ loofah (2.20.0)
39
40
  crass (~> 1.0.2)
40
41
  nokogiri (>= 1.5.9)
41
42
  method_source (1.0.0)
42
- minitest (5.17.0)
43
+ minitest (5.18.0)
44
+ nokogiri (1.14.0.rc1-arm64-darwin)
45
+ racc (~> 1.4)
43
46
  nokogiri (1.14.0.rc1-x86_64-darwin)
44
47
  racc (~> 1.4)
45
48
  nokogiri (1.14.0.rc1-x86_64-linux)
46
49
  racc (~> 1.4)
47
- pry (0.14.1)
50
+ pry (0.14.2)
48
51
  coderay (~> 1.1)
49
52
  method_source (~> 1.0)
50
53
  racc (1.6.2)
51
- rack (2.2.5)
52
- rack-test (2.0.2)
54
+ rack (2.2.7)
55
+ rack-test (2.1.0)
53
56
  rack (>= 1.3)
54
57
  rails-dom-testing (2.0.3)
55
58
  activesupport (>= 4.2.0)
56
59
  nokogiri (>= 1.6)
57
- rails-html-sanitizer (1.4.4)
60
+ rails-html-sanitizer (1.5.0)
58
61
  loofah (~> 2.19, >= 2.19.1)
59
- railties (7.0.4)
60
- actionpack (= 7.0.4)
61
- activesupport (= 7.0.4)
62
+ railties (7.0.4.3)
63
+ actionpack (= 7.0.4.3)
64
+ activesupport (= 7.0.4.3)
62
65
  method_source
63
66
  rake (>= 12.2)
64
67
  thor (~> 1.0)
@@ -68,22 +71,29 @@ GEM
68
71
  rspec-core (~> 3.12.0)
69
72
  rspec-expectations (~> 3.12.0)
70
73
  rspec-mocks (~> 3.12.0)
71
- rspec-core (3.12.0)
74
+ rspec-core (3.12.2)
72
75
  rspec-support (~> 3.12.0)
73
- rspec-expectations (3.12.1)
76
+ rspec-expectations (3.12.3)
74
77
  diff-lcs (>= 1.2.0, < 2.0)
75
78
  rspec-support (~> 3.12.0)
76
- rspec-mocks (3.12.1)
79
+ rspec-mocks (3.12.5)
77
80
  diff-lcs (>= 1.2.0, < 2.0)
78
81
  rspec-support (~> 3.12.0)
79
82
  rspec-support (3.12.0)
83
+ simplecov (0.22.0)
84
+ docile (~> 1.1)
85
+ simplecov-html (~> 0.11)
86
+ simplecov_json_formatter (~> 0.1)
87
+ simplecov-html (0.12.3)
88
+ simplecov_json_formatter (0.1.4)
80
89
  thor (1.2.1)
81
- tzinfo (2.0.5)
90
+ tzinfo (2.0.6)
82
91
  concurrent-ruby (~> 1.0)
83
92
  unaccent (0.4.0)
84
- zeitwerk (2.6.6)
93
+ zeitwerk (2.6.8)
85
94
 
86
95
  PLATFORMS
96
+ arm64-darwin-22
87
97
  x86_64-darwin-22
88
98
  x86_64-linux
89
99
 
@@ -95,6 +105,7 @@ DEPENDENCIES
95
105
  railties (~> 7.0.0)
96
106
  rake (~> 13)
97
107
  rspec (~> 3)
108
+ simplecov (~> 0.22)
98
109
 
99
110
  BUNDLED WITH
100
111
  2.4.2
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+
7
+ gem 'railties', '~> 7.1.0.alpha', github: 'rails/rails'
8
+ gem 'actionpack', '~> 7.1.0.alpha', github: 'rails/rails'
9
+ gem 'nokogiri', '~> 1.14'
@@ -0,0 +1,133 @@
1
+ GIT
2
+ remote: https://github.com/rails/rails.git
3
+ revision: 5b2523edaa131eec7b18780b7916760828262df4
4
+ specs:
5
+ actionpack (7.1.0.alpha)
6
+ actionview (= 7.1.0.alpha)
7
+ activesupport (= 7.1.0.alpha)
8
+ nokogiri (>= 1.8.5)
9
+ rack (>= 2.2.4)
10
+ rack-session (>= 1.0.1)
11
+ rack-test (>= 0.6.3)
12
+ rails-dom-testing (~> 2.0)
13
+ rails-html-sanitizer (~> 1.6)
14
+ actionview (7.1.0.alpha)
15
+ activesupport (= 7.1.0.alpha)
16
+ builder (~> 3.1)
17
+ erubi (~> 1.11)
18
+ rails-dom-testing (~> 2.0)
19
+ rails-html-sanitizer (~> 1.6)
20
+ activesupport (7.1.0.alpha)
21
+ concurrent-ruby (~> 1.0, >= 1.0.2)
22
+ connection_pool (>= 2.2.5)
23
+ i18n (>= 1.6, < 2)
24
+ minitest (>= 5.1)
25
+ tzinfo (~> 2.0)
26
+ railties (7.1.0.alpha)
27
+ actionpack (= 7.1.0.alpha)
28
+ activesupport (= 7.1.0.alpha)
29
+ irb
30
+ rackup (>= 1.0.0)
31
+ rake (>= 12.2)
32
+ thor (~> 1.0, >= 1.2.2)
33
+ zeitwerk (~> 2.6)
34
+
35
+ PATH
36
+ remote: ..
37
+ specs:
38
+ country_select (8.0.1)
39
+ countries (~> 5.0)
40
+
41
+ GEM
42
+ remote: https://rubygems.org/
43
+ specs:
44
+ builder (3.2.4)
45
+ coderay (1.1.3)
46
+ concurrent-ruby (1.2.2)
47
+ connection_pool (2.4.1)
48
+ countries (5.5.0)
49
+ unaccent (~> 0.3)
50
+ crass (1.0.6)
51
+ diff-lcs (1.5.0)
52
+ docile (1.4.0)
53
+ erubi (1.12.0)
54
+ i18n (1.14.1)
55
+ concurrent-ruby (~> 1.0)
56
+ io-console (0.6.0)
57
+ irb (1.7.0)
58
+ reline (>= 0.3.0)
59
+ loofah (2.21.3)
60
+ crass (~> 1.0.2)
61
+ nokogiri (>= 1.12.0)
62
+ method_source (1.0.0)
63
+ minitest (5.18.1)
64
+ nokogiri (1.15.2-arm64-darwin)
65
+ racc (~> 1.4)
66
+ nokogiri (1.15.2-x86_64-darwin)
67
+ racc (~> 1.4)
68
+ nokogiri (1.15.2-x86_64-linux)
69
+ racc (~> 1.4)
70
+ pry (0.14.2)
71
+ coderay (~> 1.1)
72
+ method_source (~> 1.0)
73
+ racc (1.7.1)
74
+ rack (3.0.8)
75
+ rack-session (2.0.0)
76
+ rack (>= 3.0.0)
77
+ rack-test (2.1.0)
78
+ rack (>= 1.3)
79
+ rackup (2.1.0)
80
+ rack (>= 3)
81
+ webrick (~> 1.8)
82
+ rails-dom-testing (2.0.3)
83
+ activesupport (>= 4.2.0)
84
+ nokogiri (>= 1.6)
85
+ rails-html-sanitizer (1.6.0)
86
+ loofah (~> 2.21)
87
+ nokogiri (~> 1.14)
88
+ rake (13.0.6)
89
+ reline (0.3.5)
90
+ io-console (~> 0.5)
91
+ rspec (3.12.0)
92
+ rspec-core (~> 3.12.0)
93
+ rspec-expectations (~> 3.12.0)
94
+ rspec-mocks (~> 3.12.0)
95
+ rspec-core (3.12.2)
96
+ rspec-support (~> 3.12.0)
97
+ rspec-expectations (3.12.3)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (~> 3.12.0)
100
+ rspec-mocks (3.12.5)
101
+ diff-lcs (>= 1.2.0, < 2.0)
102
+ rspec-support (~> 3.12.0)
103
+ rspec-support (3.12.1)
104
+ simplecov (0.22.0)
105
+ docile (~> 1.1)
106
+ simplecov-html (~> 0.11)
107
+ simplecov_json_formatter (~> 0.1)
108
+ simplecov-html (0.12.3)
109
+ simplecov_json_formatter (0.1.4)
110
+ thor (1.2.2)
111
+ tzinfo (2.0.6)
112
+ concurrent-ruby (~> 1.0)
113
+ unaccent (0.4.0)
114
+ webrick (1.8.1)
115
+ zeitwerk (2.6.8)
116
+
117
+ PLATFORMS
118
+ arm64-darwin-22
119
+ x86_64-darwin-22
120
+ x86_64-linux
121
+
122
+ DEPENDENCIES
123
+ actionpack (~> 7.1.0.alpha)!
124
+ country_select!
125
+ nokogiri (~> 1.14)
126
+ pry (~> 0)
127
+ railties (~> 7.1.0.alpha)!
128
+ rake (~> 13)
129
+ rspec (~> 3)
130
+ simplecov (~> 0.22)
131
+
132
+ BUNDLED WITH
133
+ 2.4.2
@@ -1,15 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  class FormBuilder
6
+ # def country_select(method, options = {}, html_options = {})
7
+ # @template.country_select(@object_name, method, objectify_options(options), @default_options.merge(html_options))
8
+ # end
4
9
  def country_select(method, priority_or_options = {}, options = {}, html_options = {})
5
- if Hash === priority_or_options
10
+ if priority_or_options.is_a? Hash
6
11
  html_options = options
7
12
  options = priority_or_options
8
13
  else
9
14
  if RUBY_VERSION =~ /^3\.\d\.\d/
10
- warn "DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. Please use the `priority_countries:` option.", uplevel: 1, category: :deprecated
15
+ warn 'DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. \
16
+ Please use the `priority_countries:` option.', uplevel: 1, category: :deprecated
11
17
  else
12
- warn "DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. Please use the `priority_countries:` option.", uplevel: 1
18
+ warn 'DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. \
19
+ Please use the `priority_countries:` option.', uplevel: 1
13
20
  end
14
21
  options[:priority_countries] = priority_or_options
15
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CountrySelect
2
4
  DEFAULTS = {
3
5
  except: nil,
@@ -5,7 +7,7 @@ module CountrySelect
5
7
  locale: nil,
6
8
  only: nil,
7
9
  priority_countries: nil,
8
- priority_countries_divider: "-" * 15,
10
+ priority_countries_divider: '-' * 15,
9
11
  sort_provided: true
10
12
  }
11
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CountrySelect
2
4
  FORMATS = {}
3
5
 
@@ -1,12 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CountrySelect
2
- class CountryNotFoundError < StandardError;end
4
+ class CountryNotFoundError < StandardError; end
5
+
3
6
  module TagHelper
7
+ unless respond_to?(:options_for_select)
8
+ include ActionView::Helpers::FormOptionsHelper
9
+ include ActionView::Helpers::Tags::SelectRenderer if defined?(ActionView::Helpers::Tags::SelectRenderer)
10
+ end
11
+
4
12
  def country_option_tags
5
13
  # In Rails 5.2+, `value` accepts no arguments and must also be called
6
14
  # with parens to avoid the local variable of the same name
7
15
  # https://github.com/rails/rails/pull/29791
8
16
  selected_option = @options.fetch(:selected) do
9
- if self.method(:value).arity == 0
17
+ if self.method(:value).arity.zero?
10
18
  value()
11
19
  else
12
20
  value(@object)
@@ -14,26 +22,19 @@ module CountrySelect
14
22
  end
15
23
 
16
24
  option_tags_options = {
17
- :selected => selected_option,
18
- :disabled => @options[:disabled]
25
+ selected: selected_option,
26
+ disabled: @options[:disabled]
19
27
  }
20
28
 
21
29
  if priority_countries.present?
22
- priority_countries_options = country_options_for(priority_countries, @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided]))
23
-
24
- option_tags = options_for_select(priority_countries_options, option_tags_options)
25
- option_tags += html_safe_newline + options_for_select([priority_countries_divider], disabled: priority_countries_divider)
26
-
27
- option_tags_options[:selected] = [option_tags_options[:selected]] unless option_tags_options[:selected].kind_of?(Array)
28
- option_tags_options[:selected].delete_if{|selected| priority_countries_options.map(&:second).include?(selected)}
29
-
30
- option_tags += html_safe_newline + options_for_select(country_options, option_tags_options)
30
+ options_for_select_with_priority_countries(country_options, option_tags_options)
31
31
  else
32
- option_tags = options_for_select(country_options, option_tags_options)
32
+ options_for_select(country_options, option_tags_options)
33
33
  end
34
34
  end
35
35
 
36
36
  private
37
+
37
38
  def locale
38
39
  @options.fetch(:locale, ::CountrySelect::DEFAULTS[:locale])
39
40
  end
@@ -59,54 +60,63 @@ module CountrySelect
59
60
  end
60
61
 
61
62
  def country_options
63
+ codes = ISO3166::Country.codes
64
+
62
65
  if only_country_codes.present?
63
- codes = only_country_codes & ISO3166::Country.codes
66
+ codes = only_country_codes & codes
64
67
  sort = @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided])
65
- elsif except_country_codes.present?
66
- codes = ISO3166::Country.codes - except_country_codes
67
- sort = true
68
68
  else
69
- codes = ISO3166::Country.codes
69
+ codes -= except_country_codes if except_country_codes.present?
70
70
  sort = true
71
71
  end
72
72
 
73
- country_options_for(codes, sort)
73
+ country_options_for(codes, sorted: sort)
74
74
  end
75
75
 
76
- def country_options_for(country_codes, sorted=true)
76
+ def country_options_for(country_codes, sorted: rue)
77
77
  I18n.with_locale(locale) do
78
- country_list = country_codes.map do |code_or_name|
79
- if country = ISO3166::Country.new(code_or_name)
80
- code = country.alpha2
81
- elsif country = ISO3166::Country.find_country_by_any_name(code_or_name)
82
- code = country.alpha2
83
- end
84
-
85
- unless country.present?
86
- msg = "Could not find Country with string '#{code_or_name}'"
87
- raise CountryNotFoundError.new(msg)
88
- end
89
-
90
- formatted_country = ::CountrySelect::FORMATS[format].call(country)
91
-
92
- if formatted_country.is_a?(Array)
93
- formatted_country
94
- else
95
- [formatted_country, code]
96
- end
78
+ country_list = country_codes.map { |code_or_name| get_formatted_country(code_or_name) }
97
79
 
98
- end
80
+ country_list.sort_by! { |name, _| [I18n.transliterate(name), name] } if sorted
81
+ country_list
82
+ end
83
+ end
99
84
 
100
- if sorted
101
- country_list.sort_by { |name, code| [I18n.transliterate(name), name] }
102
- else
103
- country_list
104
- end
85
+ def options_for_select_with_priority_countries(country_options, tags_options)
86
+ sorted = @options.fetch(:sort_provided, ::CountrySelect::DEFAULTS[:sort_provided])
87
+ priority_countries_options = country_options_for(priority_countries, sorted: sorted)
88
+
89
+ option_tags = priority_options_for_select(priority_countries_options, tags_options)
90
+
91
+ tags_options[:selected] = Array(tags_options[:selected]).delete_if do |selected|
92
+ priority_countries_options.map(&:second).include?(selected)
105
93
  end
94
+
95
+ option_tags += "\n".html_safe + options_for_select(country_options, tags_options)
96
+
97
+ option_tags
106
98
  end
107
99
 
108
- def html_safe_newline
109
- "\n".html_safe
100
+ def priority_options_for_select(priority_countries_options, tags_options)
101
+ option_tags = options_for_select(priority_countries_options, tags_options)
102
+ option_tags += "\n".html_safe +
103
+ options_for_select([priority_countries_divider], disabled: priority_countries_divider)
104
+ end
105
+
106
+ def get_formatted_country(code_or_name)
107
+ country = ISO3166::Country.new(code_or_name) ||
108
+ ISO3166::Country.find_country_by_any_name(code_or_name)
109
+
110
+ raise(CountryNotFoundError, "Could not find Country with string '#{code_or_name}'") unless country.present?
111
+
112
+ code = country.alpha2
113
+ formatted_country = ::CountrySelect::FORMATS[format].call(country)
114
+
115
+ if formatted_country.is_a?(Array)
116
+ formatted_country
117
+ else
118
+ [formatted_country, code]
119
+ end
110
120
  end
111
121
  end
112
122
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CountrySelect
2
- VERSION = '8.0.1'
4
+ VERSION = '8.0.2'
3
5
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'countries'
4
4