country_select 1.2.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85cd9956d8ad64b2416fb3709b58b6cbd0690594
4
+ data.tar.gz: 46a5e1a828ccd13f6bb7fcccb481a4abfd23a905
5
+ SHA512:
6
+ metadata.gz: 3f23d5d029d2c64cd52415d184c369d2c9e78224946a886cde30e7905ad08de1370cc02efdbda7dd7ae1284f1dd3bbd38f8c3f9a3ee4965651500ffb57383d55
7
+ data.tar.gz: 875ea57ddb1bfd27a1eb7e7571124e9df206ba8e02ca46f6c60b5701110eabdcb3ded1407422d5f5ab5bb1f6943a15eb27c32a391c67ea6c19cd9c82a9ff5487
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ c����0�SeXxlx��䔸�0��8T_B~7h���݌���6���,z"*�B�Yb�F�ŭ똓1��-AR�_UV5�.�.�Ii>!�����00��cf��b����X���T�C������pwخ[��(�v�����1&��V���=�m�D��na������x��5o�7n��V�F��-p*a{���W�x\a�6�]m�]��C��V �~�����e�=��?ʏ����T�,|�g�@c��cX|��ȵ�[���3]�8{�%#gU
data.tar.gz.sig ADDED
Binary file
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  .bundle
4
4
  Gemfile.lock
5
5
  pkg/*
6
+ .ruby-version
data/.travis.yml CHANGED
@@ -1,17 +1,19 @@
1
1
  language: ruby
2
2
  script: "bundle exec rake appraisal:integration"
3
3
  rvm:
4
- - ruby-head
5
- - 2.0.0
6
- - 1.9.3
7
- - 1.9.2
8
4
  - 1.8.7
9
- - ree
10
- - jruby-head
11
- - jruby-19mode
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
12
9
  - jruby-18mode
13
- - rbx-19mode
14
- - rbx-18mode
10
+ - jruby-19mode
11
+ - jruby-head
12
+ - rbx
13
+ - ree
14
+ - ruby-head
15
15
  matrix:
16
16
  allow_failures:
17
17
  - rvm: ruby-head
18
+ - rvm: jruby-head
19
+ - rvm: rbx
data/Appraisals CHANGED
@@ -1,7 +1,3 @@
1
- # appraise 'actionpack2.3' do
2
- # gem 'actionpack', '~> 2.3.0'
3
- # end
4
-
5
1
  appraise 'actionpack3.0' do
6
2
  gem 'actionpack', '~> 3.0.0'
7
3
  end
@@ -17,3 +13,7 @@ end
17
13
  appraise 'actionpack4.0' do
18
14
  gem 'actionpack', '~> 4.0.0'
19
15
  end
16
+
17
+ appraise 'actionpack4.1' do
18
+ gem 'actionpack', '~> 4.1.0.beta1'
19
+ end
data/Gemfile CHANGED
@@ -2,3 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in country_select.gemspec
4
4
  gemspec
5
+
6
+ # Duplicating this in Gemfile until thoughtbot pushes latest version
7
+ # that supports Bundler `platform` directive for rbx support in travis-ci
8
+ # Once appraisal 1.0.0 is released, this line can be removed
9
+ gem 'appraisal', :github => 'thoughtbot/appraisal', :ref => '6d599f'
10
+
11
+ platforms :rbx do
12
+ gem 'racc'
13
+ gem 'rubysl', '~> 2.0'
14
+ gem 'psych'
15
+ end
data/README.md CHANGED
@@ -27,7 +27,7 @@ Or put the following in your Gemfile
27
27
  gem 'country_select'
28
28
  ```
29
29
 
30
- ## Example
30
+ ## Usage
31
31
 
32
32
  Simple use supplying model and attribute as parameters:
33
33
 
@@ -41,10 +41,24 @@ Supplying priority countries to be placed at the top of the list:
41
41
  country_select("user", "country", [ "Great Britain", "France", "Germany" ])
42
42
  ```
43
43
 
44
+ ### Using Country Name Localization
45
+ Country names are automatically localized based on the value of
46
+ `I18n.locale` thanks to the wonderful
47
+ [countries gem](https://github.com/hexorx/countries/).
48
+
49
+ Current translations include:
50
+ en, it, de, fr, es, ja, nl, but may not be complete. In the event a translation is
51
+ not available, it will revert to the globally assigned locale (by default, "en").
52
+
53
+ The locale can be overridden locally:
54
+ ```ruby
55
+ country_select(:country_name, ['US'], {:iso_codes => true, :locale => 'es'})
56
+ ```
57
+
44
58
  ### Using ISO 3166-1 alpha-2 codes as values
45
59
  You can have the `option` tags use ISO 3166-1 alpha-2 codes as values
46
60
  and the country names as display strings. For example, the United States
47
- would appear as `<option value="us">United States</option>`
61
+ would appear as `<option value="US">United States</option>`
48
62
 
49
63
  If you're starting a new project, this is the recommended way to store
50
64
  your country data since it will be more resistant to country names
@@ -55,7 +69,14 @@ country_select("user", "country_code", nil, iso_codes: true)
55
69
  ```
56
70
 
57
71
  ```ruby
58
- country_select("user", "country_code", [ "gb", "fr", "de" ], iso_codes: true)
72
+ country_select("user", "country_code", [ "GB", "FR", "DE" ], iso_codes: true)
73
+ ```
74
+
75
+ #### Global configuration to always use ISO codes
76
+ Add the following configuration to an initializer.
77
+
78
+ ```ruby
79
+ ::CountrySelect.use_iso_codes = true
59
80
  ```
60
81
 
61
82
  #### Getting the Country from ISO codes
@@ -64,12 +85,18 @@ country_select("user", "country_code", [ "gb", "fr", "de" ], iso_codes: true)
64
85
  class User < ActiveRecord::Base
65
86
 
66
87
  # Assuming country_select is used with User attribute `country_code`
88
+ # This will attempt to translate the country name and use the default
89
+ # (usually English) name if no translation is available
67
90
  def country_name
68
- ::CountrySelect::COUNTRIES[country_code]
91
+ country = Country[country_code]
92
+ country.translations[I18n.locale.to_s] || country.name
69
93
  end
70
94
 
71
95
  end
72
96
  ```
97
+ ## Example Application
98
+
99
+ An example Rails application demonstrating the different options is available at [scudco/country_select_test](https://github.com/scudco/country_select_test). The relevant view file lives [here](https://github.com/scudco/country_select_test/blob/master/app/views/welcome/index.html.erb).
73
100
 
74
101
  ## Tests
75
102
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ namespace :appraisal do
13
13
  desc "Run the given task for a particular integration's appraisals"
14
14
  task :integration do
15
15
  Appraisal::File.each do |appraisal|
16
- if RUBY_VERSION < '1.9.3' and appraisal.name == 'actionpack4.0'
16
+ if RUBY_VERSION < '1.9.3' && appraisal.name =~ /actionpack4/
17
17
  # skip rails 4 for ruby < 1.9.3
18
18
  else
19
19
  appraisal.install
@@ -5,6 +5,7 @@ require 'country_select/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'country_select'
7
7
  s.version = CountrySelect::VERSION
8
+ s.licenses = ['MIT']
8
9
  s.authors = ['Stefan Penner']
9
10
  s.email = ['stefan.penner@gmail.com']
10
11
  s.homepage = 'https://github.com/stefanpenner/country_select'
@@ -19,12 +20,15 @@ Gem::Specification.new do |s|
19
20
  s.require_paths = ['lib']
20
21
 
21
22
  # specify any dependencies here; for example:
22
- s.add_development_dependency 'rspec'
23
+ s.add_development_dependency 'rspec', '~> 2'
23
24
  if RUBY_VERSION < '1.9.3'
24
25
  s.add_development_dependency 'actionpack', '~> 3.2.13'
25
26
  else
26
- s.add_development_dependency 'actionpack'
27
+ s.add_development_dependency 'actionpack', '~> 3'
27
28
  end
28
- s.add_development_dependency 'appraisal'
29
- s.add_development_dependency 'pry'
29
+ # Putting this directly in Gemfile until thoughtbot pushes latest version
30
+ # that supports Bundler `platform` directive for rbx support in travis-ci
31
+ #s.add_development_dependency 'appraisal'
32
+ s.add_development_dependency 'pry', '~> 0'
33
+ s.add_dependency 'countries', '0.9.3'
30
34
  end
@@ -2,6 +2,13 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
5
6
  gem "actionpack", "~> 3.0.0"
6
7
 
7
- gemspec :path=>"../"
8
+ platforms :rbx do
9
+ gem "racc"
10
+ gem "rubysl", "~> 2.0"
11
+ gem "psych"
12
+ end
13
+
14
+ gemspec :path=>".././"
@@ -1,7 +1,18 @@
1
+ GIT
2
+ remote: git://github.com/thoughtbot/appraisal.git
3
+ revision: 6d599ff1f2418d199ba2357b7c0297a63521ab13
4
+ ref: 6d599f
5
+ specs:
6
+ appraisal (1.0.0.beta2)
7
+ bundler
8
+ rake
9
+ thor (>= 0.14.0)
10
+
1
11
  PATH
2
- remote: /Users/scudco/projects/country_select
12
+ remote: ../
3
13
  specs:
4
- country_select (1.1.3)
14
+ country_select (1.3.1)
15
+ countries (= 0.9.3)
5
16
 
6
17
  GEM
7
18
  remote: https://rubygems.org/
@@ -22,20 +33,23 @@ GEM
22
33
  builder (~> 2.1.2)
23
34
  i18n (~> 0.5.0)
24
35
  activesupport (3.0.20)
25
- appraisal (0.5.2)
26
- bundler
27
- rake
28
36
  builder (2.1.2)
29
37
  coderay (1.0.9)
38
+ countries (0.9.3)
39
+ currencies (~> 0.4.2)
40
+ currencies (0.4.2)
30
41
  diff-lcs (1.2.4)
31
42
  erubis (2.6.6)
32
43
  abstract (>= 1.0.0)
44
+ ffi2-generators (0.1.1)
33
45
  i18n (0.5.0)
34
46
  method_source (0.8.1)
35
47
  pry (0.9.12.2)
36
48
  coderay (~> 1.0.5)
37
49
  method_source (~> 0.8)
38
50
  slop (~> 3.4)
51
+ psych (2.0.2)
52
+ racc (1.4.11)
39
53
  rack (1.2.8)
40
54
  rack-mount (0.6.14)
41
55
  rack (>= 1.0.0)
@@ -50,7 +64,210 @@ GEM
50
64
  rspec-expectations (2.13.0)
51
65
  diff-lcs (>= 1.1.3, < 2.0)
52
66
  rspec-mocks (2.13.1)
67
+ rubysl (2.0.15)
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.0)
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-readline (~> 2.0)
131
+ rubysl-resolv (~> 2.0)
132
+ rubysl-rexml (~> 2.0)
133
+ rubysl-rinda (~> 2.0)
134
+ rubysl-rss (~> 2.0)
135
+ rubysl-scanf (~> 2.0)
136
+ rubysl-securerandom (~> 2.0)
137
+ rubysl-set (~> 2.0)
138
+ rubysl-shellwords (~> 2.0)
139
+ rubysl-singleton (~> 2.0)
140
+ rubysl-socket (~> 2.0)
141
+ rubysl-stringio (~> 2.0)
142
+ rubysl-strscan (~> 2.0)
143
+ rubysl-sync (~> 2.0)
144
+ rubysl-syslog (~> 2.0)
145
+ rubysl-tempfile (~> 2.0)
146
+ rubysl-thread (~> 2.0)
147
+ rubysl-thwait (~> 2.0)
148
+ rubysl-time (~> 2.0)
149
+ rubysl-timeout (~> 2.0)
150
+ rubysl-tmpdir (~> 2.0)
151
+ rubysl-tsort (~> 2.0)
152
+ rubysl-un (~> 2.0)
153
+ rubysl-uri (~> 2.0)
154
+ rubysl-weakref (~> 2.0)
155
+ rubysl-webrick (~> 2.0)
156
+ rubysl-xmlrpc (~> 2.0)
157
+ rubysl-yaml (~> 2.0)
158
+ rubysl-zlib (~> 2.0)
159
+ rubysl-abbrev (2.0.4)
160
+ rubysl-base64 (2.0.0)
161
+ rubysl-benchmark (2.0.1)
162
+ rubysl-bigdecimal (2.0.2)
163
+ rubysl-cgi (2.0.1)
164
+ rubysl-cgi-session (2.0.1)
165
+ rubysl-cmath (2.0.0)
166
+ rubysl-complex (2.0.0)
167
+ rubysl-continuation (2.0.0)
168
+ rubysl-coverage (2.0.3)
169
+ rubysl-csv (2.0.2)
170
+ rubysl-english (~> 2.0)
171
+ rubysl-curses (2.0.1)
172
+ rubysl-date (2.0.6)
173
+ rubysl-delegate (2.0.1)
174
+ rubysl-digest (2.0.3)
175
+ rubysl-drb (2.0.1)
176
+ rubysl-e2mmap (2.0.0)
177
+ rubysl-english (2.0.0)
178
+ rubysl-enumerator (2.0.0)
179
+ rubysl-erb (2.0.1)
180
+ rubysl-etc (2.0.3)
181
+ ffi2-generators (~> 0.1)
182
+ rubysl-expect (2.0.0)
183
+ rubysl-fcntl (2.0.4)
184
+ ffi2-generators (~> 0.1)
185
+ rubysl-fiber (2.0.0)
186
+ rubysl-fileutils (2.0.3)
187
+ rubysl-find (2.0.1)
188
+ rubysl-forwardable (2.0.1)
189
+ rubysl-getoptlong (2.0.0)
190
+ rubysl-gserver (2.0.0)
191
+ rubysl-socket (~> 2.0)
192
+ rubysl-thread (~> 2.0)
193
+ rubysl-io-console (2.0.0)
194
+ rubysl-io-nonblock (2.0.0)
195
+ rubysl-io-wait (2.0.0)
196
+ rubysl-ipaddr (2.0.0)
197
+ rubysl-irb (2.0.4)
198
+ rubysl-e2mmap (~> 2.0)
199
+ rubysl-mathn (~> 2.0)
200
+ rubysl-readline (~> 2.0)
201
+ rubysl-thread (~> 2.0)
202
+ rubysl-logger (2.0.0)
203
+ rubysl-mathn (2.0.0)
204
+ rubysl-matrix (2.1.0)
205
+ rubysl-e2mmap (~> 2.0)
206
+ rubysl-mkmf (2.0.1)
207
+ rubysl-fileutils (~> 2.0)
208
+ rubysl-shellwords (~> 2.0)
209
+ rubysl-monitor (2.0.0)
210
+ rubysl-mutex_m (2.0.0)
211
+ rubysl-net-ftp (2.0.1)
212
+ rubysl-net-http (2.0.4)
213
+ rubysl-cgi (~> 2.0)
214
+ rubysl-erb (~> 2.0)
215
+ rubysl-singleton (~> 2.0)
216
+ rubysl-net-imap (2.0.1)
217
+ rubysl-net-pop (2.0.1)
218
+ rubysl-net-protocol (2.0.1)
219
+ rubysl-net-smtp (2.0.1)
220
+ rubysl-net-telnet (2.0.0)
221
+ rubysl-nkf (2.0.1)
222
+ rubysl-observer (2.0.0)
223
+ rubysl-open-uri (2.0.0)
224
+ rubysl-open3 (2.0.0)
225
+ rubysl-openssl (2.1.0)
226
+ rubysl-optparse (2.0.1)
227
+ rubysl-shellwords (~> 2.0)
228
+ rubysl-ostruct (2.0.4)
229
+ rubysl-pathname (2.0.0)
230
+ rubysl-prettyprint (2.0.2)
231
+ rubysl-prime (2.0.1)
232
+ rubysl-profile (2.0.0)
233
+ rubysl-profiler (2.0.1)
234
+ rubysl-pstore (2.0.0)
235
+ rubysl-pty (2.0.2)
236
+ rubysl-rational (2.0.1)
237
+ rubysl-readline (2.0.2)
238
+ rubysl-resolv (2.0.0)
239
+ rubysl-rexml (2.0.2)
240
+ rubysl-rinda (2.0.1)
241
+ rubysl-rss (2.0.0)
242
+ rubysl-scanf (2.0.0)
243
+ rubysl-securerandom (2.0.0)
244
+ rubysl-set (2.0.1)
245
+ rubysl-shellwords (2.0.0)
246
+ rubysl-singleton (2.0.0)
247
+ rubysl-socket (2.0.1)
248
+ rubysl-stringio (2.0.0)
249
+ rubysl-strscan (2.0.0)
250
+ rubysl-sync (2.0.0)
251
+ rubysl-syslog (2.0.1)
252
+ ffi2-generators (~> 0.1)
253
+ rubysl-tempfile (2.0.1)
254
+ rubysl-thread (2.0.2)
255
+ rubysl-thwait (2.0.0)
256
+ rubysl-time (2.0.3)
257
+ rubysl-timeout (2.0.0)
258
+ rubysl-tmpdir (2.0.0)
259
+ rubysl-tsort (2.0.1)
260
+ rubysl-un (2.0.0)
261
+ rubysl-fileutils (~> 2.0)
262
+ rubysl-optparse (~> 2.0)
263
+ rubysl-uri (2.0.0)
264
+ rubysl-weakref (2.0.0)
265
+ rubysl-webrick (2.0.0)
266
+ rubysl-xmlrpc (2.0.0)
267
+ rubysl-yaml (2.0.4)
268
+ rubysl-zlib (2.0.1)
53
269
  slop (3.4.5)
270
+ thor (0.18.1)
54
271
  tzinfo (0.3.37)
55
272
 
56
273
  PLATFORMS
@@ -58,7 +275,10 @@ PLATFORMS
58
275
 
59
276
  DEPENDENCIES
60
277
  actionpack (~> 3.0.0)
61
- appraisal
278
+ appraisal!
62
279
  country_select!
63
- pry
64
- rspec
280
+ pry (~> 0)
281
+ psych
282
+ racc
283
+ rspec (~> 2)
284
+ rubysl (~> 2.0)