country_select 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f79817c4bcf3df9e63c08756f84001c840be85c79ed8b07a4ff6d5cb9dd6b65
4
- data.tar.gz: 7a6e4ac2b315dacc9788ef70264752f9d8013194eba5abd124abbb2475e0a1c5
3
+ metadata.gz: 18cae0fad3906e7184ab1c457ae1b7d162b087f35e14f816a2e4fef4fab200ae
4
+ data.tar.gz: ed929514c9aef114176258c46dc50805774358bd2b393716939d183f8d26575d
5
5
  SHA512:
6
- metadata.gz: 31eb7c557942a0e88c44de468f7c54bc7345348f9f0330515db003b2ad78a70453d18133574ff2a6c1d419e1c8168a9998d62f7feb43661d139c16f8f644f921
7
- data.tar.gz: a4623e97352b356ff04bddaeb70cccfd46e1510f61797e5a6aa17a7a58ce786b2d281498f436e360277aebc2bd44c0cfc54a110625b51b486d4ac8340d7ffd7b
6
+ metadata.gz: 0b84fa702b6a06a80a8e5dc035c6fc17434ec2b33d0775d5d132f02ac4ee578d9b7a29d4a1482408b9d07ca4a034597715319c59c81a1391f0b1f6060699f1aa
7
+ data.tar.gz: c66b11dcb9b1574e66951e320b82a0ba5d8b580d82c18ecb2b4b0bae97a8a1072ab1d387b33b08846cafbf47fc6028e58ac1cd586ee5558b57ebf2f4a3828c6a
data/.travis.yml CHANGED
@@ -3,10 +3,10 @@ cache: bundler
3
3
  language: ruby
4
4
  bundler_args: ""
5
5
  rvm:
6
- - 2.5
7
- - 2.6
8
- - 2.7
9
- - 3.0
6
+ - "2.5"
7
+ - "2.6"
8
+ - "2.7"
9
+ - "3.0"
10
10
  - ruby-head
11
11
  gemfile:
12
12
  - gemfiles/actionpack5.2.gemfile
@@ -15,9 +15,9 @@ gemfile:
15
15
  - gemfiles/actionpack.edge.gemfile
16
16
  jobs:
17
17
  exclude:
18
- - rvm: 2.5
18
+ - rvm: "2.5"
19
19
  gemfile: gemfiles/actionpack.edge.gemfile
20
- - rvm: 2.6
20
+ - rvm: "2.6"
21
21
  gemfile: gemfiles/actionpack.edge.gemfile
22
22
  allow_failures:
23
23
  - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 5.1.0 2021-05-18
2
+
3
+ * #184 - Add ability to configure defaults (@p-wall)
4
+ * Upgrade to countries 3.1.0
5
+
1
6
  ## 5.0.1 2021-03-08
2
7
 
3
8
  * #181 - Fix i18n fallback in country translations (@lavaturtle)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- country_select (5.0.1)
4
+ country_select (5.1.0)
5
5
  countries (~> 3.0)
6
6
  sort_alphabetical (~> 1.1)
7
7
 
@@ -30,8 +30,8 @@ GEM
30
30
  builder (3.2.4)
31
31
  coderay (1.1.3)
32
32
  concurrent-ruby (1.1.8)
33
- countries (3.0.1)
34
- i18n_data (~> 0.10.0)
33
+ countries (3.1.0)
34
+ i18n_data (~> 0.11.0)
35
35
  sixarm_ruby_unaccent (~> 1.1)
36
36
  unicode_utils (~> 1.4)
37
37
  crass (1.0.6)
@@ -39,7 +39,7 @@ GEM
39
39
  erubi (1.10.0)
40
40
  i18n (1.8.9)
41
41
  concurrent-ruby (~> 1.0)
42
- i18n_data (0.10.0)
42
+ i18n_data (0.11.0)
43
43
  loofah (2.9.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
data/README.md CHANGED
@@ -122,6 +122,19 @@ country_select("user", "country", format: :with_alpha2)
122
122
  country_select("user", "country", format: :with_data_attrs)
123
123
  ```
124
124
 
125
+ ### Using customized defaults
126
+
127
+ You can configure overridable defaults for `except`, `format`, `locale`,
128
+ `only`, `priority_countries` and `priority_countries_divider` in an initializer.
129
+
130
+ ````ruby
131
+ # config/initializers/country_select.rb
132
+
133
+ CountrySelect::DEFAULTS[:except] = [ "ZZ" ]
134
+ ````
135
+
136
+ The example would exclude "ZZ" from every `country_select` tag, where no `except` option is given.
137
+
125
138
  ### ISO 3166-1 alpha-2 codes
126
139
  The `option` tags use ISO 3166-1 alpha-2 codes as values and the country
127
140
  names as display strings. For example, the United States would appear as
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/rails/rails.git
3
- revision: 14f35cde18de77cd7ab5d6f17d83fa8bc92ba383
3
+ revision: a34d64d82e213a4054fbb69ad5cd7a5137a5a252
4
4
  specs:
5
5
  actionpack (7.0.0.alpha)
6
6
  actionview (= 7.0.0.alpha)
@@ -25,7 +25,7 @@ GIT
25
25
  PATH
26
26
  remote: ..
27
27
  specs:
28
- country_select (5.0.1)
28
+ country_select (5.1.0)
29
29
  countries (~> 3.0)
30
30
  sort_alphabetical (~> 1.1)
31
31
 
@@ -35,8 +35,8 @@ GEM
35
35
  builder (3.2.4)
36
36
  coderay (1.1.3)
37
37
  concurrent-ruby (1.1.8)
38
- countries (3.0.1)
39
- i18n_data (~> 0.10.0)
38
+ countries (3.1.0)
39
+ i18n_data (~> 0.11.0)
40
40
  sixarm_ruby_unaccent (~> 1.1)
41
41
  unicode_utils (~> 1.4)
42
42
  crass (1.0.6)
@@ -44,7 +44,7 @@ GEM
44
44
  erubi (1.10.0)
45
45
  i18n (1.8.9)
46
46
  concurrent-ruby (~> 1.0)
47
- i18n_data (0.10.0)
47
+ i18n_data (0.11.0)
48
48
  loofah (2.9.0)
49
49
  crass (~> 1.0.2)
50
50
  nokogiri (>= 1.5.9)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- country_select (5.0.1)
4
+ country_select (5.1.0)
5
5
  countries (~> 3.0)
6
6
  sort_alphabetical (~> 1.1)
7
7
 
@@ -29,8 +29,8 @@ GEM
29
29
  builder (3.2.4)
30
30
  coderay (1.1.3)
31
31
  concurrent-ruby (1.1.8)
32
- countries (3.0.1)
33
- i18n_data (~> 0.10.0)
32
+ countries (3.1.0)
33
+ i18n_data (~> 0.11.0)
34
34
  sixarm_ruby_unaccent (~> 1.1)
35
35
  unicode_utils (~> 1.4)
36
36
  crass (1.0.6)
@@ -38,7 +38,7 @@ GEM
38
38
  erubi (1.10.0)
39
39
  i18n (1.8.9)
40
40
  concurrent-ruby (~> 1.0)
41
- i18n_data (0.10.0)
41
+ i18n_data (0.11.0)
42
42
  loofah (2.9.0)
43
43
  crass (~> 1.0.2)
44
44
  nokogiri (>= 1.5.9)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- country_select (5.0.1)
4
+ country_select (5.1.0)
5
5
  countries (~> 3.0)
6
6
  sort_alphabetical (~> 1.1)
7
7
 
@@ -30,8 +30,8 @@ GEM
30
30
  builder (3.2.4)
31
31
  coderay (1.1.3)
32
32
  concurrent-ruby (1.1.8)
33
- countries (3.0.1)
34
- i18n_data (~> 0.10.0)
33
+ countries (3.1.0)
34
+ i18n_data (~> 0.11.0)
35
35
  sixarm_ruby_unaccent (~> 1.1)
36
36
  unicode_utils (~> 1.4)
37
37
  crass (1.0.6)
@@ -39,7 +39,7 @@ GEM
39
39
  erubi (1.10.0)
40
40
  i18n (1.8.9)
41
41
  concurrent-ruby (~> 1.0)
42
- i18n_data (0.10.0)
42
+ i18n_data (0.11.0)
43
43
  loofah (2.9.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- country_select (5.0.1)
4
+ country_select (5.1.0)
5
5
  countries (~> 3.0)
6
6
  sort_alphabetical (~> 1.1)
7
7
 
@@ -30,8 +30,8 @@ GEM
30
30
  builder (3.2.4)
31
31
  coderay (1.1.3)
32
32
  concurrent-ruby (1.1.8)
33
- countries (3.0.1)
34
- i18n_data (~> 0.10.0)
33
+ countries (3.1.0)
34
+ i18n_data (~> 0.11.0)
35
35
  sixarm_ruby_unaccent (~> 1.1)
36
36
  unicode_utils (~> 1.4)
37
37
  crass (1.0.6)
@@ -39,7 +39,7 @@ GEM
39
39
  erubi (1.10.0)
40
40
  i18n (1.8.9)
41
41
  concurrent-ruby (~> 1.0)
42
- i18n_data (0.10.0)
42
+ i18n_data (0.11.0)
43
43
  loofah (2.9.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
@@ -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'
@@ -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
@@ -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 = '5.0.1'
2
+ VERSION = '5.1.0'
3
3
  end
@@ -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(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: country_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Penner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -138,6 +138,7 @@ files:
138
138
  - gemfiles/actionpack6.1.gemfile.lock
139
139
  - lib/country_select.rb
140
140
  - lib/country_select/country_select_helper.rb
141
+ - lib/country_select/defaults.rb
141
142
  - lib/country_select/formats.rb
142
143
  - lib/country_select/tag_helper.rb
143
144
  - lib/country_select/version.rb