country_select 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -3
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/country_select.gemspec +4 -4
- data/gemfiles/actionpack.edge.gemfile.lock +1 -1
- data/gemfiles/actionpack3.2.gemfile.lock +1 -1
- data/gemfiles/actionpack4.0.gemfile.lock +1 -1
- data/gemfiles/actionpack4.1.gemfile.lock +1 -1
- data/gemfiles/actionpack4.2.gemfile.lock +1 -1
- data/lib/country_select.rb +1 -0
- data/lib/country_select/formats.rb +7 -0
- data/lib/country_select/tag_helper.rb +5 -4
- data/lib/country_select/version.rb +1 -1
- data/spec/country_select_spec.rb +14 -0
- metadata +15 -16
- data/gemfiles/actionpack3.0.gemfile +0 -11
- data/gemfiles/actionpack3.1.gemfile +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f72c7a94484b2fc7e537a8addc1ba2e3593edff
|
4
|
+
data.tar.gz: b88516afc9af4968d9e10f427504f9c92883185d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ad51cc6825e7da7fcd12db138716df55812850768e1d293b2ad996b8b5f0500a38bed8b1a6c51b0cd6b0bee4c13fe18d1fc658ddfd04488ca247d0334dfde83
|
7
|
+
data.tar.gz: 4d9fa1e8e639330045a77e9b9dc126eecbf72eb0e2487e53715369383c962c5b80d403c9366e14be62f5f8439d8577b402be8be070b664e4eea5a667347c7b62
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
1
|
+
## 2.1.0 2014-09-29
|
2
|
+
|
3
|
+
* #70 - Allow custom formats for option tag text – See README.md
|
4
|
+
|
5
|
+
## 2.0.1 2014-09-18
|
2
6
|
|
3
7
|
* #72 - Fixed `include_blank` and `prompt` in Rails 3.2
|
4
8
|
* #75 - Raise `CountrySelect::CountryNotFound` error when given a country
|
5
9
|
name or code that is not found in https://github.com/hexorx/countries
|
6
10
|
|
7
|
-
|
11
|
+
## 2.0.0 2014-08-10
|
8
12
|
|
9
13
|
* Removed support for Ruby < 1.9.3
|
10
14
|
* ISO-3166 alpha-2 codes are now on by default, stored in uppercase
|
@@ -20,7 +24,7 @@
|
|
20
24
|
* Add best-guess support for country names when codes aren't provided
|
21
25
|
in options (e.g., priority_countries)
|
22
26
|
|
23
|
-
|
27
|
+
## 1.2.0 2013-07-06
|
24
28
|
|
25
29
|
* Country names have been synced with UTF-8 encoding to the list of
|
26
30
|
countries on [Wikipedia's page for the ISO-3166 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -57,6 +57,21 @@ Supplying additional html options:
|
|
57
57
|
country_select("user", "country", { priority_countries: ["GB", "FR"] }, { selected: "GB", class: 'form-control' })
|
58
58
|
```
|
59
59
|
|
60
|
+
Using a custom formatter
|
61
|
+
|
62
|
+
You can define a custom formatter which will receive an
|
63
|
+
[`ISO3166::Country`](https://github.com/hexorx/countries/blob/master/lib/countries/country.rb)
|
64
|
+
```ruby
|
65
|
+
# config/initializers/country_select.rb
|
66
|
+
CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
|
67
|
+
"#{country.name} (#{country.alpha2})"
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
country_select("user", "country", format: :with_alpha2)
|
73
|
+
```
|
74
|
+
|
60
75
|
### ISO 3166-1 alpha-2 codes
|
61
76
|
The `option` tags use ISO 3166-1 alpha-2 codes as values and the country
|
62
77
|
names as display strings. For example, the United States would appear as
|
data/country_select.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
22
|
s.add_development_dependency 'actionpack', '~> 3'
|
23
|
-
s.add_development_dependency 'pry', '~> 0
|
24
|
-
s.add_development_dependency 'rake'
|
25
|
-
s.add_development_dependency 'rspec', '~> 3
|
26
|
-
s.add_development_dependency 'wwtd'
|
23
|
+
s.add_development_dependency 'pry', '~> 0'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'rspec', '~> 3'
|
26
|
+
s.add_development_dependency 'wwtd'
|
27
27
|
|
28
28
|
s.add_dependency 'countries', '~> 0.9', '>= 0.9.3'
|
29
29
|
end
|
data/lib/country_select.rb
CHANGED
@@ -44,6 +44,10 @@ module CountrySelect
|
|
44
44
|
@options[:except]
|
45
45
|
end
|
46
46
|
|
47
|
+
def format
|
48
|
+
@options[:format] || :default
|
49
|
+
end
|
50
|
+
|
47
51
|
def country_options
|
48
52
|
country_options_for(all_country_codes, true)
|
49
53
|
end
|
@@ -76,10 +80,7 @@ module CountrySelect
|
|
76
80
|
raise CountryNotFoundError.new(msg)
|
77
81
|
end
|
78
82
|
|
79
|
-
|
80
|
-
localized_name = country.translations[I18n.locale.to_s]
|
81
|
-
|
82
|
-
name = localized_name || default_name
|
83
|
+
name = ::CountrySelect::FORMATS[format].call(country)
|
83
84
|
|
84
85
|
[name,code]
|
85
86
|
end
|
data/spec/country_select_spec.rb
CHANGED
@@ -164,4 +164,18 @@ describe "CountrySelect" do
|
|
164
164
|
expect(t).to include(tag)
|
165
165
|
end
|
166
166
|
end
|
167
|
+
|
168
|
+
describe "custom formats" do
|
169
|
+
it "accepts a custom formatter" do
|
170
|
+
::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
|
171
|
+
"#{country.name} (#{country.alpha2})"
|
172
|
+
end
|
173
|
+
|
174
|
+
tag = options_for_select([['United States (US)', 'US']], 'US')
|
175
|
+
|
176
|
+
walrus.country_code = 'US'
|
177
|
+
t = builder.country_select(:country_code, format: :with_alpha2)
|
178
|
+
expect(t).to include(tag)
|
179
|
+
end
|
180
|
+
end
|
167
181
|
end
|
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: 2.0
|
4
|
+
version: 2.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: 2014-09-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -30,56 +30,56 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3
|
61
|
+
version: '3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3
|
68
|
+
version: '3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: wwtd
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: countries
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,8 +122,6 @@ files:
|
|
122
122
|
- country_select.gemspec
|
123
123
|
- gemfiles/actionpack.edge.gemfile
|
124
124
|
- gemfiles/actionpack.edge.gemfile.lock
|
125
|
-
- gemfiles/actionpack3.0.gemfile
|
126
|
-
- gemfiles/actionpack3.1.gemfile
|
127
125
|
- gemfiles/actionpack3.2.gemfile
|
128
126
|
- gemfiles/actionpack3.2.gemfile.lock
|
129
127
|
- gemfiles/actionpack4.0.gemfile
|
@@ -134,6 +132,7 @@ files:
|
|
134
132
|
- gemfiles/actionpack4.2.gemfile.lock
|
135
133
|
- lib/country_select.rb
|
136
134
|
- lib/country_select/country_select_helper.rb
|
135
|
+
- lib/country_select/formats.rb
|
137
136
|
- lib/country_select/rails3/country_select_helper.rb
|
138
137
|
- lib/country_select/tag_helper.rb
|
139
138
|
- lib/country_select/version.rb
|