country_select 1.1.3 → 2.5.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.
- checksums.yaml +7 -0
- data/.gitignore +3 -1
- data/.rspec +3 -0
- data/.travis.yml +31 -0
- data/CHANGELOG.md +69 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +293 -0
- data/README.md +146 -14
- data/Rakefile +10 -1
- data/UPGRADING.md +69 -0
- data/country_select.gemspec +17 -11
- data/gemfiles/actionpack.edge.gemfile +15 -0
- data/gemfiles/actionpack.edge.gemfile.lock +309 -0
- data/gemfiles/actionpack3.2.gemfile +11 -0
- data/gemfiles/actionpack3.2.gemfile.lock +293 -0
- data/gemfiles/actionpack4.0.gemfile +11 -0
- data/gemfiles/actionpack4.0.gemfile.lock +282 -0
- data/gemfiles/actionpack4.1.gemfile +11 -0
- data/gemfiles/actionpack4.1.gemfile.lock +286 -0
- data/gemfiles/actionpack4.2.gemfile +12 -0
- data/gemfiles/actionpack4.2.gemfile.lock +310 -0
- data/lib/country_select/country_select_helper.rb +38 -0
- data/lib/country_select/formats.rb +7 -0
- data/lib/country_select/rails3/country_select_helper.rb +39 -0
- data/lib/country_select/tag_helper.rb +103 -0
- data/lib/country_select/version.rb +1 -1
- data/lib/country_select.rb +10 -101
- data/spec/country_select_spec.rb +232 -0
- data/spec/spec_helper.rb +98 -0
- metadata +134 -21
- data/VERSION +0 -1
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1dea784fe1d78c8a7b7d35502636b0de1b64879e
|
|
4
|
+
data.tar.gz: ca5c6e5be03c82625ae7396a126759b456e5d04f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: df7361d081db570f9195f0bd04e079a3ddd82a2083bfafb7fe1c9b2c6c20462b986001d17e551b54707a0bf02c5dbef98a178f6a32348b6650160df9e0b8c818
|
|
7
|
+
data.tar.gz: 1019eeb1f5d5b9b323bed52bb37253a330829ad09093649b86291b070f67a27efd55406dfbd23f889f246638b923e57d86b0bb51bc087a0cdbab30e9c55de450
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
sudo: false
|
|
2
|
+
cache: bundler
|
|
3
|
+
language: ruby
|
|
4
|
+
script: "bundle exec rspec"
|
|
5
|
+
rvm:
|
|
6
|
+
- 1.9.3
|
|
7
|
+
- 2.0.0
|
|
8
|
+
- 2.1.5
|
|
9
|
+
- 2.2.1
|
|
10
|
+
- jruby-19mode
|
|
11
|
+
- jruby-head
|
|
12
|
+
- rbx-2
|
|
13
|
+
- ruby-head
|
|
14
|
+
gemfile:
|
|
15
|
+
- gemfiles/actionpack3.2.gemfile
|
|
16
|
+
- gemfiles/actionpack4.0.gemfile
|
|
17
|
+
- gemfiles/actionpack4.1.gemfile
|
|
18
|
+
- gemfiles/actionpack4.2.gemfile
|
|
19
|
+
- gemfiles/actionpack.edge.gemfile
|
|
20
|
+
matrix:
|
|
21
|
+
allow_failures:
|
|
22
|
+
- rvm: ruby-head
|
|
23
|
+
- rvm: jruby-head
|
|
24
|
+
- rvm: rbx-2
|
|
25
|
+
exclude:
|
|
26
|
+
- rvm: 1.9.3
|
|
27
|
+
gemfile: gemfiles/actionpack.edge.gemfile
|
|
28
|
+
- rvm: 2.0.0
|
|
29
|
+
gemfile: gemfiles/actionpack.edge.gemfile
|
|
30
|
+
- rvm: jruby-19mode
|
|
31
|
+
gemfile: gemfiles/actionpack.edge.gemfile
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
## 2.5.2 2015-11-10
|
|
2
|
+
|
|
3
|
+
* #127 - Fix multi-selects - @jjballano
|
|
4
|
+
|
|
5
|
+
## 2.5.1 2015-11-10
|
|
6
|
+
|
|
7
|
+
* #118 - Fix bad require of countries gem that caused issues if you
|
|
8
|
+
already had a `Country` class
|
|
9
|
+
|
|
10
|
+
## 2.5.0 2015-11-06
|
|
11
|
+
|
|
12
|
+
* #117 - Update countries gem to ~> v1.2.0
|
|
13
|
+
|
|
14
|
+
## 2.4.0 2015-08-25
|
|
15
|
+
|
|
16
|
+
* #111 - Update countries gem to ~> v1.1.0
|
|
17
|
+
|
|
18
|
+
## 2.3.0 2015-08-25
|
|
19
|
+
|
|
20
|
+
* #107,#108 - Update countries gem to ~> v1.0.0
|
|
21
|
+
|
|
22
|
+
## 2.2.0 2015-03-19
|
|
23
|
+
|
|
24
|
+
* #101 - Update countries gem to ~> v0.11.0
|
|
25
|
+
|
|
26
|
+
## 2.1.1 2015-02-02
|
|
27
|
+
|
|
28
|
+
* #94 - Prevent usage of countries v0.10.0 due to poor performance
|
|
29
|
+
|
|
30
|
+
## 2.1.0 2014-09-29
|
|
31
|
+
|
|
32
|
+
* #70 - Allow custom formats for option tag text – See README.md
|
|
33
|
+
|
|
34
|
+
## 2.0.1 2014-09-18
|
|
35
|
+
|
|
36
|
+
* #72 - Fixed `include_blank` and `prompt` in Rails 3.2
|
|
37
|
+
* #75 - Raise `CountrySelect::CountryNotFound` error when given a country
|
|
38
|
+
name or code that is not found in https://github.com/hexorx/countries
|
|
39
|
+
|
|
40
|
+
## 2.0.0 2014-08-10
|
|
41
|
+
|
|
42
|
+
* Removed support for Ruby < 1.9.3
|
|
43
|
+
* ISO-3166 alpha-2 codes are now on by default, stored in uppercase
|
|
44
|
+
(e.g., US)
|
|
45
|
+
* Localization is always on
|
|
46
|
+
* The `country_select` method will always attempt to localize
|
|
47
|
+
country names based on the value of `I18n.locale` via translations
|
|
48
|
+
stored in the `countries` gem
|
|
49
|
+
* Priority countries should now be set via the `priority_countries` option
|
|
50
|
+
* The original 1.x syntax is still available
|
|
51
|
+
* The list of countries can now be limited with the `only` and
|
|
52
|
+
`except` options
|
|
53
|
+
* Add best-guess support for country names when codes aren't provided
|
|
54
|
+
in options (e.g., priority_countries)
|
|
55
|
+
|
|
56
|
+
## 1.2.0 2013-07-06
|
|
57
|
+
|
|
58
|
+
* Country names have been synced with UTF-8 encoding to the list of
|
|
59
|
+
countries on [Wikipedia's page for the ISO-3166 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
|
|
60
|
+
* NOTE: This could be a breaking change with some of the country
|
|
61
|
+
names that have been fixed since the list was last updated.
|
|
62
|
+
* For more information you can checkout all country mappings with
|
|
63
|
+
`::CountrySelect::COUNTRIES`
|
|
64
|
+
|
|
65
|
+
* You can now store your country values using the
|
|
66
|
+
[ISO-3166 Alpha-2 codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
|
67
|
+
with the `iso_codes` option. See the README.md for details.
|
|
68
|
+
* This should help alleviate the problem of country names
|
|
69
|
+
in ISO-3166 being changed and/or corrected.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
country_select (2.5.1)
|
|
5
|
+
countries (~> 1.2.0)
|
|
6
|
+
sort_alphabetical (~> 1.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actionpack (3.2.22)
|
|
12
|
+
activemodel (= 3.2.22)
|
|
13
|
+
activesupport (= 3.2.22)
|
|
14
|
+
builder (~> 3.0.0)
|
|
15
|
+
erubis (~> 2.7.0)
|
|
16
|
+
journey (~> 1.0.4)
|
|
17
|
+
rack (~> 1.4.5)
|
|
18
|
+
rack-cache (~> 1.2)
|
|
19
|
+
rack-test (~> 0.6.1)
|
|
20
|
+
sprockets (~> 2.2.1)
|
|
21
|
+
activemodel (3.2.22)
|
|
22
|
+
activesupport (= 3.2.22)
|
|
23
|
+
builder (~> 3.0.0)
|
|
24
|
+
activesupport (3.2.22)
|
|
25
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
26
|
+
multi_json (~> 1.0)
|
|
27
|
+
builder (3.0.4)
|
|
28
|
+
coderay (1.1.0)
|
|
29
|
+
countries (1.2.1)
|
|
30
|
+
currencies (~> 0.4.2)
|
|
31
|
+
i18n_data (~> 0.7.0)
|
|
32
|
+
currencies (0.4.2)
|
|
33
|
+
diff-lcs (1.2.5)
|
|
34
|
+
erubis (2.7.0)
|
|
35
|
+
ffi2-generators (0.1.1)
|
|
36
|
+
hike (1.2.3)
|
|
37
|
+
i18n (0.7.0)
|
|
38
|
+
i18n_data (0.7.0)
|
|
39
|
+
journey (1.0.4)
|
|
40
|
+
method_source (0.8.2)
|
|
41
|
+
multi_json (1.11.2)
|
|
42
|
+
pry (0.10.1)
|
|
43
|
+
coderay (~> 1.1.0)
|
|
44
|
+
method_source (~> 0.8.1)
|
|
45
|
+
slop (~> 3.4)
|
|
46
|
+
psych (2.0.15)
|
|
47
|
+
racc (1.4.12)
|
|
48
|
+
rack (1.4.7)
|
|
49
|
+
rack-cache (1.2)
|
|
50
|
+
rack (>= 0.4)
|
|
51
|
+
rack-test (0.6.3)
|
|
52
|
+
rack (>= 1.0)
|
|
53
|
+
rake (10.4.2)
|
|
54
|
+
rspec (3.3.0)
|
|
55
|
+
rspec-core (~> 3.3.0)
|
|
56
|
+
rspec-expectations (~> 3.3.0)
|
|
57
|
+
rspec-mocks (~> 3.3.0)
|
|
58
|
+
rspec-core (3.3.2)
|
|
59
|
+
rspec-support (~> 3.3.0)
|
|
60
|
+
rspec-expectations (3.3.1)
|
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
62
|
+
rspec-support (~> 3.3.0)
|
|
63
|
+
rspec-mocks (3.3.2)
|
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
|
+
rspec-support (~> 3.3.0)
|
|
66
|
+
rspec-support (3.3.0)
|
|
67
|
+
rubysl (2.1.0)
|
|
68
|
+
rubysl-abbrev (~> 2.0)
|
|
69
|
+
rubysl-base64 (~> 2.0)
|
|
70
|
+
rubysl-benchmark (~> 2.0)
|
|
71
|
+
rubysl-bigdecimal (~> 2.0)
|
|
72
|
+
rubysl-cgi (~> 2.0)
|
|
73
|
+
rubysl-cgi-session (~> 2.0)
|
|
74
|
+
rubysl-cmath (~> 2.0)
|
|
75
|
+
rubysl-complex (~> 2.0)
|
|
76
|
+
rubysl-continuation (~> 2.0)
|
|
77
|
+
rubysl-coverage (~> 2.0)
|
|
78
|
+
rubysl-csv (~> 2.0)
|
|
79
|
+
rubysl-curses (~> 2.0)
|
|
80
|
+
rubysl-date (~> 2.0)
|
|
81
|
+
rubysl-delegate (~> 2.0)
|
|
82
|
+
rubysl-digest (~> 2.0)
|
|
83
|
+
rubysl-drb (~> 2.0)
|
|
84
|
+
rubysl-e2mmap (~> 2.0)
|
|
85
|
+
rubysl-english (~> 2.0)
|
|
86
|
+
rubysl-enumerator (~> 2.0)
|
|
87
|
+
rubysl-erb (~> 2.0)
|
|
88
|
+
rubysl-etc (~> 2.0)
|
|
89
|
+
rubysl-expect (~> 2.0)
|
|
90
|
+
rubysl-fcntl (~> 2.0)
|
|
91
|
+
rubysl-fiber (~> 2.0)
|
|
92
|
+
rubysl-fileutils (~> 2.0)
|
|
93
|
+
rubysl-find (~> 2.0)
|
|
94
|
+
rubysl-forwardable (~> 2.0)
|
|
95
|
+
rubysl-getoptlong (~> 2.0)
|
|
96
|
+
rubysl-gserver (~> 2.0)
|
|
97
|
+
rubysl-io-console (~> 2.0)
|
|
98
|
+
rubysl-io-nonblock (~> 2.0)
|
|
99
|
+
rubysl-io-wait (~> 2.0)
|
|
100
|
+
rubysl-ipaddr (~> 2.0)
|
|
101
|
+
rubysl-irb (~> 2.1)
|
|
102
|
+
rubysl-logger (~> 2.0)
|
|
103
|
+
rubysl-mathn (~> 2.0)
|
|
104
|
+
rubysl-matrix (~> 2.0)
|
|
105
|
+
rubysl-mkmf (~> 2.0)
|
|
106
|
+
rubysl-monitor (~> 2.0)
|
|
107
|
+
rubysl-mutex_m (~> 2.0)
|
|
108
|
+
rubysl-net-ftp (~> 2.0)
|
|
109
|
+
rubysl-net-http (~> 2.0)
|
|
110
|
+
rubysl-net-imap (~> 2.0)
|
|
111
|
+
rubysl-net-pop (~> 2.0)
|
|
112
|
+
rubysl-net-protocol (~> 2.0)
|
|
113
|
+
rubysl-net-smtp (~> 2.0)
|
|
114
|
+
rubysl-net-telnet (~> 2.0)
|
|
115
|
+
rubysl-nkf (~> 2.0)
|
|
116
|
+
rubysl-observer (~> 2.0)
|
|
117
|
+
rubysl-open-uri (~> 2.0)
|
|
118
|
+
rubysl-open3 (~> 2.0)
|
|
119
|
+
rubysl-openssl (~> 2.0)
|
|
120
|
+
rubysl-optparse (~> 2.0)
|
|
121
|
+
rubysl-ostruct (~> 2.0)
|
|
122
|
+
rubysl-pathname (~> 2.0)
|
|
123
|
+
rubysl-prettyprint (~> 2.0)
|
|
124
|
+
rubysl-prime (~> 2.0)
|
|
125
|
+
rubysl-profile (~> 2.0)
|
|
126
|
+
rubysl-profiler (~> 2.0)
|
|
127
|
+
rubysl-pstore (~> 2.0)
|
|
128
|
+
rubysl-pty (~> 2.0)
|
|
129
|
+
rubysl-rational (~> 2.0)
|
|
130
|
+
rubysl-resolv (~> 2.0)
|
|
131
|
+
rubysl-rexml (~> 2.0)
|
|
132
|
+
rubysl-rinda (~> 2.0)
|
|
133
|
+
rubysl-rss (~> 2.0)
|
|
134
|
+
rubysl-scanf (~> 2.0)
|
|
135
|
+
rubysl-securerandom (~> 2.0)
|
|
136
|
+
rubysl-set (~> 2.0)
|
|
137
|
+
rubysl-shellwords (~> 2.0)
|
|
138
|
+
rubysl-singleton (~> 2.0)
|
|
139
|
+
rubysl-socket (~> 2.0)
|
|
140
|
+
rubysl-stringio (~> 2.0)
|
|
141
|
+
rubysl-strscan (~> 2.0)
|
|
142
|
+
rubysl-sync (~> 2.0)
|
|
143
|
+
rubysl-syslog (~> 2.0)
|
|
144
|
+
rubysl-tempfile (~> 2.0)
|
|
145
|
+
rubysl-thread (~> 2.0)
|
|
146
|
+
rubysl-thwait (~> 2.0)
|
|
147
|
+
rubysl-time (~> 2.0)
|
|
148
|
+
rubysl-timeout (~> 2.0)
|
|
149
|
+
rubysl-tmpdir (~> 2.0)
|
|
150
|
+
rubysl-tsort (~> 2.0)
|
|
151
|
+
rubysl-un (~> 2.0)
|
|
152
|
+
rubysl-uri (~> 2.0)
|
|
153
|
+
rubysl-weakref (~> 2.0)
|
|
154
|
+
rubysl-webrick (~> 2.0)
|
|
155
|
+
rubysl-xmlrpc (~> 2.0)
|
|
156
|
+
rubysl-yaml (~> 2.0)
|
|
157
|
+
rubysl-zlib (~> 2.0)
|
|
158
|
+
rubysl-abbrev (2.0.4)
|
|
159
|
+
rubysl-base64 (2.0.0)
|
|
160
|
+
rubysl-benchmark (2.0.1)
|
|
161
|
+
rubysl-bigdecimal (2.0.2)
|
|
162
|
+
rubysl-cgi (2.0.1)
|
|
163
|
+
rubysl-cgi-session (2.0.1)
|
|
164
|
+
rubysl-cmath (2.0.0)
|
|
165
|
+
rubysl-complex (2.0.0)
|
|
166
|
+
rubysl-continuation (2.0.0)
|
|
167
|
+
rubysl-coverage (2.0.3)
|
|
168
|
+
rubysl-csv (2.0.2)
|
|
169
|
+
rubysl-english (~> 2.0)
|
|
170
|
+
rubysl-curses (2.0.1)
|
|
171
|
+
rubysl-date (2.0.9)
|
|
172
|
+
rubysl-delegate (2.0.1)
|
|
173
|
+
rubysl-digest (2.0.8)
|
|
174
|
+
rubysl-drb (2.0.1)
|
|
175
|
+
rubysl-e2mmap (2.0.0)
|
|
176
|
+
rubysl-english (2.0.0)
|
|
177
|
+
rubysl-enumerator (2.0.0)
|
|
178
|
+
rubysl-erb (2.0.2)
|
|
179
|
+
rubysl-etc (2.0.3)
|
|
180
|
+
ffi2-generators (~> 0.1)
|
|
181
|
+
rubysl-expect (2.0.0)
|
|
182
|
+
rubysl-fcntl (2.0.4)
|
|
183
|
+
ffi2-generators (~> 0.1)
|
|
184
|
+
rubysl-fiber (2.0.0)
|
|
185
|
+
rubysl-fileutils (2.0.3)
|
|
186
|
+
rubysl-find (2.0.1)
|
|
187
|
+
rubysl-forwardable (2.0.1)
|
|
188
|
+
rubysl-getoptlong (2.0.0)
|
|
189
|
+
rubysl-gserver (2.0.0)
|
|
190
|
+
rubysl-socket (~> 2.0)
|
|
191
|
+
rubysl-thread (~> 2.0)
|
|
192
|
+
rubysl-io-console (2.0.0)
|
|
193
|
+
rubysl-io-nonblock (2.0.0)
|
|
194
|
+
rubysl-io-wait (2.0.0)
|
|
195
|
+
rubysl-ipaddr (2.0.0)
|
|
196
|
+
rubysl-irb (2.1.1)
|
|
197
|
+
rubysl-e2mmap (~> 2.0)
|
|
198
|
+
rubysl-mathn (~> 2.0)
|
|
199
|
+
rubysl-thread (~> 2.0)
|
|
200
|
+
rubysl-logger (2.1.0)
|
|
201
|
+
rubysl-mathn (2.0.0)
|
|
202
|
+
rubysl-matrix (2.1.0)
|
|
203
|
+
rubysl-e2mmap (~> 2.0)
|
|
204
|
+
rubysl-mkmf (2.0.1)
|
|
205
|
+
rubysl-fileutils (~> 2.0)
|
|
206
|
+
rubysl-shellwords (~> 2.0)
|
|
207
|
+
rubysl-monitor (2.0.0)
|
|
208
|
+
rubysl-mutex_m (2.0.0)
|
|
209
|
+
rubysl-net-ftp (2.0.1)
|
|
210
|
+
rubysl-net-http (2.0.4)
|
|
211
|
+
rubysl-cgi (~> 2.0)
|
|
212
|
+
rubysl-erb (~> 2.0)
|
|
213
|
+
rubysl-singleton (~> 2.0)
|
|
214
|
+
rubysl-net-imap (2.0.1)
|
|
215
|
+
rubysl-net-pop (2.0.1)
|
|
216
|
+
rubysl-net-protocol (2.0.1)
|
|
217
|
+
rubysl-net-smtp (2.0.1)
|
|
218
|
+
rubysl-net-telnet (2.0.0)
|
|
219
|
+
rubysl-nkf (2.0.1)
|
|
220
|
+
rubysl-observer (2.0.0)
|
|
221
|
+
rubysl-open-uri (2.0.0)
|
|
222
|
+
rubysl-open3 (2.0.0)
|
|
223
|
+
rubysl-openssl (2.3.0)
|
|
224
|
+
rubysl-optparse (2.0.1)
|
|
225
|
+
rubysl-shellwords (~> 2.0)
|
|
226
|
+
rubysl-ostruct (2.0.4)
|
|
227
|
+
rubysl-pathname (2.1.0)
|
|
228
|
+
rubysl-prettyprint (2.0.3)
|
|
229
|
+
rubysl-prime (2.0.1)
|
|
230
|
+
rubysl-profile (2.0.0)
|
|
231
|
+
rubysl-profiler (2.0.1)
|
|
232
|
+
rubysl-pstore (2.0.0)
|
|
233
|
+
rubysl-pty (2.0.3)
|
|
234
|
+
rubysl-rational (2.0.1)
|
|
235
|
+
rubysl-resolv (2.1.2)
|
|
236
|
+
rubysl-rexml (2.0.4)
|
|
237
|
+
rubysl-rinda (2.0.1)
|
|
238
|
+
rubysl-rss (2.0.0)
|
|
239
|
+
rubysl-scanf (2.0.0)
|
|
240
|
+
rubysl-securerandom (2.0.0)
|
|
241
|
+
rubysl-set (2.0.1)
|
|
242
|
+
rubysl-shellwords (2.0.0)
|
|
243
|
+
rubysl-singleton (2.0.0)
|
|
244
|
+
rubysl-socket (2.0.1)
|
|
245
|
+
rubysl-stringio (2.0.0)
|
|
246
|
+
rubysl-strscan (2.0.0)
|
|
247
|
+
rubysl-sync (2.0.0)
|
|
248
|
+
rubysl-syslog (2.1.0)
|
|
249
|
+
ffi2-generators (~> 0.1)
|
|
250
|
+
rubysl-tempfile (2.0.1)
|
|
251
|
+
rubysl-thread (2.0.3)
|
|
252
|
+
rubysl-thwait (2.0.0)
|
|
253
|
+
rubysl-time (2.0.3)
|
|
254
|
+
rubysl-timeout (2.0.0)
|
|
255
|
+
rubysl-tmpdir (2.0.1)
|
|
256
|
+
rubysl-tsort (2.0.1)
|
|
257
|
+
rubysl-un (2.0.0)
|
|
258
|
+
rubysl-fileutils (~> 2.0)
|
|
259
|
+
rubysl-optparse (~> 2.0)
|
|
260
|
+
rubysl-uri (2.0.0)
|
|
261
|
+
rubysl-weakref (2.0.0)
|
|
262
|
+
rubysl-webrick (2.0.0)
|
|
263
|
+
rubysl-xmlrpc (2.0.0)
|
|
264
|
+
rubysl-yaml (2.1.0)
|
|
265
|
+
rubysl-zlib (2.0.1)
|
|
266
|
+
slop (3.6.0)
|
|
267
|
+
sort_alphabetical (1.0.2)
|
|
268
|
+
unicode_utils (>= 1.2.2)
|
|
269
|
+
sprockets (2.2.3)
|
|
270
|
+
hike (~> 1.2)
|
|
271
|
+
multi_json (~> 1.0)
|
|
272
|
+
rack (~> 1.0)
|
|
273
|
+
tilt (~> 1.1, != 1.3.0)
|
|
274
|
+
tilt (1.4.1)
|
|
275
|
+
unicode_utils (1.4.0)
|
|
276
|
+
wwtd (1.1.1)
|
|
277
|
+
|
|
278
|
+
PLATFORMS
|
|
279
|
+
ruby
|
|
280
|
+
|
|
281
|
+
DEPENDENCIES
|
|
282
|
+
actionpack (~> 3)
|
|
283
|
+
country_select!
|
|
284
|
+
pry (~> 0)
|
|
285
|
+
psych
|
|
286
|
+
racc
|
|
287
|
+
rake
|
|
288
|
+
rspec (~> 3)
|
|
289
|
+
rubysl (~> 2.0)
|
|
290
|
+
wwtd
|
|
291
|
+
|
|
292
|
+
BUNDLED WITH
|
|
293
|
+
1.10.6
|
data/README.md
CHANGED
|
@@ -1,34 +1,166 @@
|
|
|
1
|
-
|
|
1
|
+
# Rails – Country Select
|
|
2
|
+
[](https://travis-ci.org/stefanpenner/country_select)
|
|
2
3
|
|
|
3
|
-
Provides a simple helper to get an HTML select list of countries
|
|
4
|
-
|
|
5
|
-
still offend some users.
|
|
4
|
+
Provides a simple helper to get an HTML select list of countries using the
|
|
5
|
+
[ISO 3166-1 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
While the ISO 3166 standard is a relatively neutral source of country
|
|
8
|
+
names, it may still offend some users. Developers are strongly advised
|
|
9
|
+
to evaluate the suitability of this list given their user base.
|
|
10
|
+
|
|
11
|
+
## UPGRADING
|
|
12
|
+
|
|
13
|
+
[**An important message about upgrading from 1.x**](UPGRADING.md)
|
|
14
|
+
|
|
15
|
+
## Reporting issues
|
|
16
|
+
|
|
17
|
+
Open an issue on the [issue tracker](https://github.com/stefanpenner/country_select/issues/new). Ideally provide versions used, and code example that demonstrates the issue.
|
|
8
18
|
|
|
9
19
|
## Installation
|
|
10
20
|
|
|
11
21
|
Install as a gem using
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
```shell
|
|
24
|
+
gem install country_select
|
|
25
|
+
```
|
|
15
26
|
Or put the following in your Gemfile
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
```ruby
|
|
29
|
+
gem 'country_select'
|
|
30
|
+
```
|
|
18
31
|
|
|
19
|
-
##
|
|
32
|
+
## Usage
|
|
20
33
|
|
|
21
34
|
Simple use supplying model and attribute as parameters:
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
```ruby
|
|
37
|
+
country_select("user", "country")
|
|
38
|
+
```
|
|
24
39
|
|
|
25
40
|
Supplying priority countries to be placed at the top of the list:
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
```ruby
|
|
43
|
+
country_select("user", "country", priority_countries: ["GB", "FR", "DE"])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Supplying only certain countries:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
country_select("user", "country", only: ["GB", "FR", "DE"])
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Discarding certain countries:
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
country_select("user", "country", except: ["GB", "FR", "DE"])
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Pre-selecting a particular country:
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
country_select("user", "country", selected: "GB")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Using existing `select` options:
|
|
65
|
+
```ruby
|
|
66
|
+
country_select("user", "country", include_blank: true)
|
|
67
|
+
country_select("user", "country", { include_blank: 'Select a country' }, { class: 'country-select-box' })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Supplying additional html options:
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
country_select("user", "country", { priority_countries: ["GB", "FR"], selected: "GB" }, { class: 'form-control', data: { attribute: "value" } })
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Using a custom formatter
|
|
77
|
+
|
|
78
|
+
You can define a custom formatter which will receive an
|
|
79
|
+
[`ISO3166::Country`](https://github.com/hexorx/countries/blob/master/lib/countries/country.rb)
|
|
80
|
+
```ruby
|
|
81
|
+
# config/initializers/country_select.rb
|
|
82
|
+
CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
|
|
83
|
+
"#{country.name} (#{country.alpha2})"
|
|
84
|
+
end
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
country_select("user", "country", format: :with_alpha2)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### ISO 3166-1 alpha-2 codes
|
|
92
|
+
The `option` tags use ISO 3166-1 alpha-2 codes as values and the country
|
|
93
|
+
names as display strings. For example, the United States would appear as
|
|
94
|
+
`<option value="US">United States of America</option>`
|
|
95
|
+
|
|
96
|
+
Country names are automatically localized based on the value of
|
|
97
|
+
`I18n.locale` thanks to the wonderful
|
|
98
|
+
[countries gem](https://github.com/hexorx/countries/).
|
|
99
|
+
|
|
100
|
+
Current translations include:
|
|
101
|
+
|
|
102
|
+
* en
|
|
103
|
+
* de
|
|
104
|
+
* es
|
|
105
|
+
* fr
|
|
106
|
+
* it
|
|
107
|
+
* ja
|
|
108
|
+
* nl
|
|
109
|
+
|
|
110
|
+
In the event a translation is not available, it will revert to the
|
|
111
|
+
globally assigned locale (by default, "en").
|
|
112
|
+
|
|
113
|
+
This is the only way to use `country_select` as of version `2.0`. It
|
|
114
|
+
is the recommended way to store your country data since it will be
|
|
115
|
+
resistant to country names changing.
|
|
116
|
+
|
|
117
|
+
The locale can be overridden locally:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
country_select("user", "country_code", locale: 'es')
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Getting the Country Name from the countries gem
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
class User < ActiveRecord::Base
|
|
127
|
+
|
|
128
|
+
# Assuming country_select is used with User attribute `country_code`
|
|
129
|
+
# This will attempt to translate the country name and use the default
|
|
130
|
+
# (usually English) name if no translation is available
|
|
131
|
+
def country_name
|
|
132
|
+
country = ISO3166::Country[country_code]
|
|
133
|
+
country.translations[I18n.locale.to_s] || country.name
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Example Application
|
|
140
|
+
|
|
141
|
+
An example Rails application demonstrating the different options is
|
|
142
|
+
available at [scudco/country_select_test](https://github.com/scudco/country_select_test).
|
|
143
|
+
The relevant view files live [here](https://github.com/scudco/country_select_test/tree/master/app/views/welcome).
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
### Tests
|
|
148
|
+
|
|
149
|
+
```shell
|
|
150
|
+
bundle
|
|
151
|
+
bundle exec rake
|
|
152
|
+
```
|
|
28
153
|
|
|
29
|
-
|
|
30
|
-
|
|
154
|
+
### Updating gemfiles
|
|
155
|
+
The default rake task will run the tests against multiple versions of
|
|
156
|
+
Rails. That means the gemfiles need occasional updating, especially when
|
|
157
|
+
changing the dependencies in the gemspec.
|
|
31
158
|
|
|
32
|
-
|
|
159
|
+
```shell
|
|
160
|
+
for i in gemfiles/*.gemfile
|
|
161
|
+
do
|
|
162
|
+
BUNDLE_GEMFILE=$i bundle install --no-deployment
|
|
163
|
+
done
|
|
164
|
+
```
|
|
33
165
|
|
|
34
166
|
Copyright (c) 2008 Michael Koziarski, released under the MIT license
|
data/Rakefile
CHANGED
data/UPGRADING.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Upgrading from 1.x
|
|
2
|
+
|
|
3
|
+
`country_select` 2.0 has brought a few small changes, but these changes
|
|
4
|
+
can have a big impact on existing production systems. Please read these
|
|
5
|
+
points carefully and consider whether upgrading to 2.0 is a good idea.
|
|
6
|
+
|
|
7
|
+
Please post any implications we may have missed as a GitHub Issue
|
|
8
|
+
or Pull Request.
|
|
9
|
+
|
|
10
|
+
## ISO codes are always on
|
|
11
|
+
|
|
12
|
+
If you upgrade to 2.0 and are currently storing countries by the names
|
|
13
|
+
produced by this gem, your setup will break. It is recommended that you
|
|
14
|
+
stick with 1.x until developing a data migration strategy that allows
|
|
15
|
+
you to map your existing country names to country codes.
|
|
16
|
+
|
|
17
|
+
## i18n country names are always on (when available)
|
|
18
|
+
|
|
19
|
+
Country names will be generated using `I18n.locale` if a translation
|
|
20
|
+
from the countries gem is available.
|
|
21
|
+
|
|
22
|
+
## Codes are UPCASED
|
|
23
|
+
|
|
24
|
+
The official ISO 3166-1 standard uses UPCASED codes. This is an easy
|
|
25
|
+
data change, but may affect areas of code dependent on lowercase country
|
|
26
|
+
codes.
|
|
27
|
+
|
|
28
|
+
Here's a sample SQL migration that could address a `users` table with
|
|
29
|
+
lowercased country codes stored in the `country_code` column:
|
|
30
|
+
|
|
31
|
+
```sql
|
|
32
|
+
UPDATE users SET country_code = UPPER(country_code);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Priority countries are now in the options hash
|
|
36
|
+
|
|
37
|
+
The priority countries syntax has changed from
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
country_select(:user, :country_code, ["GB","FR"])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
to
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
country_select(:user, :country_code, priority_countries: ["GB","FR"])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### A note on 1.x Syntax
|
|
50
|
+
|
|
51
|
+
In order to seamlessly support popular libraries dependent on
|
|
52
|
+
`country_select`, specifically `formatstic` and `simple_form`, 1.x
|
|
53
|
+
priority syntax is still supported, but will probably be removed in the
|
|
54
|
+
next major release (i.e., 3.0). We'll be working with `simple_form` and
|
|
55
|
+
`formtastic` maintainers to transition away from the old 1.x syntax.
|
|
56
|
+
|
|
57
|
+
## You can choose to only display a chosen set of countries
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
country_select(:user, :country_code, only: ["LV","SG"])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
country_select(:user, :country_code, except: ["US","GB"])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Ruby 1.9+
|
|
68
|
+
|
|
69
|
+
`country_select` will no longer be tested in Ruby `< 1.9`.
|