country_select 1.2.0 → 4.0.0

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.rspec +1 -0
  4. data/.travis.yml +35 -11
  5. data/CHANGELOG.md +74 -1
  6. data/Gemfile +6 -1
  7. data/Gemfile.lock +300 -0
  8. data/README.md +138 -25
  9. data/Rakefile +3 -17
  10. data/UPGRADING.md +69 -0
  11. data/country_select.gemspec +11 -9
  12. data/gemfiles/actionpack.edge.gemfile +15 -0
  13. data/gemfiles/actionpack.edge.gemfile.lock +310 -0
  14. data/gemfiles/actionpack3.2.gemfile +8 -4
  15. data/gemfiles/actionpack3.2.gemfile.lock +265 -39
  16. data/gemfiles/actionpack4.0.gemfile +7 -3
  17. data/gemfiles/actionpack4.0.gemfile.lock +260 -36
  18. data/gemfiles/actionpack4.1.gemfile +11 -0
  19. data/gemfiles/actionpack4.1.gemfile.lock +290 -0
  20. data/gemfiles/actionpack4.2.gemfile +14 -0
  21. data/gemfiles/actionpack4.2.gemfile.lock +306 -0
  22. data/gemfiles/actionpack5.0.gemfile +12 -0
  23. data/gemfiles/actionpack5.0.gemfile.lock +311 -0
  24. data/gemfiles/actionpack5.1.gemfile +12 -0
  25. data/gemfiles/actionpack5.1.gemfile.lock +311 -0
  26. data/gemfiles/actionpack5.2.gemfile +12 -0
  27. data/gemfiles/actionpack5.2.gemfile.lock +312 -0
  28. data/lib/country_select.rb +10 -118
  29. data/lib/country_select/country_select_helper.rb +38 -0
  30. data/lib/country_select/formats.rb +7 -0
  31. data/lib/country_select/rails3/country_select_helper.rb +39 -0
  32. data/lib/country_select/tag_helper.rb +118 -0
  33. data/lib/country_select/version.rb +1 -1
  34. data/lib/country_select_without_sort_alphabetical.rb +13 -0
  35. data/spec/country_select_spec.rb +239 -111
  36. data/spec/spec_helper.rb +85 -7
  37. metadata +88 -42
  38. data/Appraisals +0 -19
  39. data/gemfiles/actionpack3.0.gemfile +0 -7
  40. data/gemfiles/actionpack3.0.gemfile.lock +0 -64
  41. data/gemfiles/actionpack3.1.gemfile +0 -7
  42. data/gemfiles/actionpack3.1.gemfile.lock +0 -72
  43. data/lib/country_select/countries.rb +0 -256
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ gem "railties", "~> 5.2.0"
6
+ gem "actionpack", "~> 5.2.0"
7
+
8
+ platforms :rbx do
9
+ gem "racc"
10
+ gem "rubysl", "~> 2.0"
11
+ gem "psych"
12
+ end
@@ -0,0 +1,312 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ country_select (4.0.0)
5
+ countries (~> 3.0)
6
+ sort_alphabetical (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (5.2.0)
12
+ actionview (= 5.2.0)
13
+ activesupport (= 5.2.0)
14
+ rack (~> 2.0)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
+ actionview (5.2.0)
19
+ activesupport (= 5.2.0)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
+ activesupport (5.2.0)
25
+ concurrent-ruby (~> 1.0, >= 1.0.2)
26
+ i18n (>= 0.7, < 2)
27
+ minitest (~> 5.1)
28
+ tzinfo (~> 1.1)
29
+ builder (3.2.3)
30
+ coderay (1.1.2)
31
+ concurrent-ruby (1.0.5)
32
+ countries (3.0.0)
33
+ i18n_data (~> 0.8.0)
34
+ sixarm_ruby_unaccent (~> 1.1)
35
+ unicode_utils (~> 1.4)
36
+ crass (1.0.4)
37
+ diff-lcs (1.3)
38
+ erubi (1.7.1)
39
+ ffi2-generators (0.1.1)
40
+ i18n (1.0.1)
41
+ concurrent-ruby (~> 1.0)
42
+ i18n_data (0.8.0)
43
+ loofah (2.2.2)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (0.9.0)
47
+ mini_portile2 (2.3.0)
48
+ minitest (5.11.3)
49
+ nokogiri (1.8.3)
50
+ mini_portile2 (~> 2.3.0)
51
+ pry (0.11.3)
52
+ coderay (~> 1.1.0)
53
+ method_source (~> 0.9.0)
54
+ psych (3.0.2)
55
+ racc (1.4.14)
56
+ rack (2.0.5)
57
+ rack-test (1.0.0)
58
+ rack (>= 1.0, < 3)
59
+ rails-dom-testing (2.0.3)
60
+ activesupport (>= 4.2.0)
61
+ nokogiri (>= 1.6)
62
+ rails-html-sanitizer (1.0.4)
63
+ loofah (~> 2.2, >= 2.2.2)
64
+ railties (5.2.0)
65
+ actionpack (= 5.2.0)
66
+ activesupport (= 5.2.0)
67
+ method_source
68
+ rake (>= 0.8.7)
69
+ thor (>= 0.18.1, < 2.0)
70
+ rake (12.3.1)
71
+ rspec (3.7.0)
72
+ rspec-core (~> 3.7.0)
73
+ rspec-expectations (~> 3.7.0)
74
+ rspec-mocks (~> 3.7.0)
75
+ rspec-core (3.7.1)
76
+ rspec-support (~> 3.7.0)
77
+ rspec-expectations (3.7.0)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.7.0)
80
+ rspec-mocks (3.7.0)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.7.0)
83
+ rspec-support (3.7.1)
84
+ rubysl (2.2.0)
85
+ rubysl-abbrev (~> 2.0)
86
+ rubysl-base64 (~> 2.0)
87
+ rubysl-benchmark (~> 2.0)
88
+ rubysl-bigdecimal (~> 2.0)
89
+ rubysl-cgi (~> 2.0)
90
+ rubysl-cgi-session (~> 2.0)
91
+ rubysl-cmath (~> 2.0)
92
+ rubysl-complex (~> 2.0)
93
+ rubysl-continuation (~> 2.0)
94
+ rubysl-coverage (~> 2.0)
95
+ rubysl-csv (~> 2.0)
96
+ rubysl-curses (~> 2.0)
97
+ rubysl-date (~> 2.0)
98
+ rubysl-delegate (~> 2.0)
99
+ rubysl-digest (~> 2.0)
100
+ rubysl-drb (~> 2.0)
101
+ rubysl-e2mmap (~> 2.0)
102
+ rubysl-english (~> 2.0)
103
+ rubysl-enumerator (~> 2.0)
104
+ rubysl-erb (~> 2.0)
105
+ rubysl-etc (~> 2.0)
106
+ rubysl-expect (~> 2.0)
107
+ rubysl-fcntl (~> 2.0)
108
+ rubysl-fiber (~> 2.0)
109
+ rubysl-fileutils (~> 2.0)
110
+ rubysl-find (~> 2.0)
111
+ rubysl-forwardable (~> 2.0)
112
+ rubysl-getoptlong (~> 2.0)
113
+ rubysl-gserver (~> 2.0)
114
+ rubysl-io-console (~> 2.0)
115
+ rubysl-io-nonblock (~> 2.0)
116
+ rubysl-io-wait (~> 2.0)
117
+ rubysl-ipaddr (~> 2.0)
118
+ rubysl-irb (~> 2.1)
119
+ rubysl-logger (~> 2.0)
120
+ rubysl-mathn (~> 2.0)
121
+ rubysl-matrix (~> 2.0)
122
+ rubysl-mkmf (~> 2.0)
123
+ rubysl-monitor (~> 2.0)
124
+ rubysl-mutex_m (~> 2.0)
125
+ rubysl-net-ftp (~> 2.0)
126
+ rubysl-net-http (~> 2.0)
127
+ rubysl-net-imap (~> 2.0)
128
+ rubysl-net-pop (~> 2.0)
129
+ rubysl-net-protocol (~> 2.0)
130
+ rubysl-net-smtp (~> 2.0)
131
+ rubysl-net-telnet (~> 2.0)
132
+ rubysl-nkf (~> 2.0)
133
+ rubysl-observer (~> 2.0)
134
+ rubysl-open-uri (~> 2.0)
135
+ rubysl-open3 (~> 2.0)
136
+ rubysl-openssl (~> 2.0)
137
+ rubysl-optparse (~> 2.0)
138
+ rubysl-ostruct (~> 2.0)
139
+ rubysl-pathname (~> 2.0)
140
+ rubysl-prettyprint (~> 2.0)
141
+ rubysl-prime (~> 2.0)
142
+ rubysl-profile (~> 2.0)
143
+ rubysl-profiler (~> 2.0)
144
+ rubysl-pstore (~> 2.0)
145
+ rubysl-pty (~> 2.0)
146
+ rubysl-rational (~> 2.0)
147
+ rubysl-resolv (~> 2.0)
148
+ rubysl-rexml (~> 2.0)
149
+ rubysl-rinda (~> 2.0)
150
+ rubysl-rss (~> 2.0)
151
+ rubysl-scanf (~> 2.0)
152
+ rubysl-securerandom (~> 2.0)
153
+ rubysl-set (~> 2.0)
154
+ rubysl-shellwords (~> 2.0)
155
+ rubysl-singleton (~> 2.0)
156
+ rubysl-socket (~> 2.0)
157
+ rubysl-stringio (~> 2.0)
158
+ rubysl-strscan (~> 2.0)
159
+ rubysl-sync (~> 2.0)
160
+ rubysl-syslog (~> 2.0)
161
+ rubysl-tempfile (~> 2.0)
162
+ rubysl-thread (~> 2.0)
163
+ rubysl-thwait (~> 2.0)
164
+ rubysl-time (~> 2.0)
165
+ rubysl-timeout (~> 2.0)
166
+ rubysl-tmpdir (~> 2.0)
167
+ rubysl-tsort (~> 2.0)
168
+ rubysl-un (~> 2.0)
169
+ rubysl-unicode_normalize (~> 2.0)
170
+ rubysl-uri (~> 2.0)
171
+ rubysl-weakref (~> 2.0)
172
+ rubysl-webrick (~> 2.0)
173
+ rubysl-xmlrpc (~> 2.0)
174
+ rubysl-yaml (~> 2.0)
175
+ rubysl-zlib (~> 2.0)
176
+ rubysl-abbrev (2.0.4)
177
+ rubysl-base64 (2.0.0)
178
+ rubysl-benchmark (2.0.1)
179
+ rubysl-bigdecimal (2.0.2)
180
+ rubysl-cgi (2.0.1)
181
+ rubysl-cgi-session (2.1.0)
182
+ rubysl-cmath (2.0.0)
183
+ rubysl-complex (2.0.0)
184
+ rubysl-continuation (2.0.0)
185
+ rubysl-coverage (2.1)
186
+ rubysl-csv (2.0.2)
187
+ rubysl-english (~> 2.0)
188
+ rubysl-curses (2.0.1)
189
+ rubysl-date (2.0.9)
190
+ rubysl-delegate (2.0.1)
191
+ rubysl-digest (2.0.8)
192
+ rubysl-drb (2.0.1)
193
+ rubysl-e2mmap (2.0.0)
194
+ rubysl-english (2.0.0)
195
+ rubysl-enumerator (2.0.0)
196
+ rubysl-erb (2.0.2)
197
+ rubysl-etc (2.0.3)
198
+ ffi2-generators (~> 0.1)
199
+ rubysl-expect (2.0.0)
200
+ rubysl-fcntl (2.0.4)
201
+ ffi2-generators (~> 0.1)
202
+ rubysl-fiber (2.0.0)
203
+ rubysl-fileutils (2.0.3)
204
+ rubysl-find (2.0.1)
205
+ rubysl-forwardable (2.0.1)
206
+ rubysl-getoptlong (2.0.0)
207
+ rubysl-gserver (2.0.0)
208
+ rubysl-socket (~> 2.0)
209
+ rubysl-thread (~> 2.0)
210
+ rubysl-io-console (2.0.0)
211
+ rubysl-io-nonblock (2.0.0)
212
+ rubysl-io-wait (2.0.0)
213
+ rubysl-ipaddr (2.0.0)
214
+ rubysl-irb (2.1.1)
215
+ rubysl-e2mmap (~> 2.0)
216
+ rubysl-mathn (~> 2.0)
217
+ rubysl-thread (~> 2.0)
218
+ rubysl-logger (2.1.0)
219
+ rubysl-mathn (2.0.0)
220
+ rubysl-matrix (2.1.0)
221
+ rubysl-e2mmap (~> 2.0)
222
+ rubysl-mkmf (2.1)
223
+ rubysl-fileutils (~> 2.0)
224
+ rubysl-shellwords (~> 2.0)
225
+ rubysl-monitor (2.1)
226
+ rubysl-mutex_m (2.0.0)
227
+ rubysl-net-ftp (2.0.1)
228
+ rubysl-net-http (2.0.4)
229
+ rubysl-cgi (~> 2.0)
230
+ rubysl-erb (~> 2.0)
231
+ rubysl-singleton (~> 2.0)
232
+ rubysl-net-imap (2.0.1)
233
+ rubysl-net-pop (2.0.1)
234
+ rubysl-net-protocol (2.0.1)
235
+ rubysl-net-smtp (2.0.1)
236
+ rubysl-net-telnet (2.0.0)
237
+ rubysl-nkf (2.0.1)
238
+ rubysl-observer (2.0.0)
239
+ rubysl-open-uri (2.0.0)
240
+ rubysl-open3 (2.0.0)
241
+ rubysl-openssl (2.10)
242
+ rubysl-optparse (2.0.1)
243
+ rubysl-shellwords (~> 2.0)
244
+ rubysl-ostruct (2.1.0)
245
+ rubysl-pathname (2.3)
246
+ rubysl-prettyprint (2.0.3)
247
+ rubysl-prime (2.0.1)
248
+ rubysl-profile (2.0.0)
249
+ rubysl-profiler (2.1)
250
+ rubysl-pstore (2.0.0)
251
+ rubysl-pty (2.0.3)
252
+ rubysl-rational (2.0.1)
253
+ rubysl-resolv (2.1.2)
254
+ rubysl-rexml (2.0.4)
255
+ rubysl-rinda (2.0.1)
256
+ rubysl-rss (2.0.0)
257
+ rubysl-scanf (2.0.0)
258
+ rubysl-securerandom (2.0.0)
259
+ rubysl-set (2.0.1)
260
+ rubysl-shellwords (2.0.0)
261
+ rubysl-singleton (2.0.0)
262
+ rubysl-socket (2.2.1)
263
+ rubysl-fcntl (~> 2.0)
264
+ rubysl-stringio (2.3)
265
+ rubysl-strscan (2.0.0)
266
+ rubysl-sync (2.0.0)
267
+ rubysl-syslog (2.1.0)
268
+ ffi2-generators (~> 0.1)
269
+ rubysl-tempfile (2.0.1)
270
+ rubysl-thread (2.1)
271
+ rubysl-thwait (2.0.0)
272
+ rubysl-time (2.0.3)
273
+ rubysl-timeout (2.0.0)
274
+ rubysl-tmpdir (2.0.1)
275
+ rubysl-tsort (2.0.1)
276
+ rubysl-un (2.0.0)
277
+ rubysl-fileutils (~> 2.0)
278
+ rubysl-optparse (~> 2.0)
279
+ rubysl-unicode_normalize (2.0)
280
+ rubysl-uri (2.0.0)
281
+ rubysl-weakref (2.0.0)
282
+ rubysl-webrick (2.0.0)
283
+ rubysl-xmlrpc (2.0.0)
284
+ rubysl-yaml (2.1.0)
285
+ rubysl-zlib (2.0.1)
286
+ sixarm_ruby_unaccent (1.2.0)
287
+ sort_alphabetical (1.1.0)
288
+ unicode_utils (>= 1.2.2)
289
+ thor (0.20.0)
290
+ thread_safe (0.3.6)
291
+ tzinfo (1.2.5)
292
+ thread_safe (~> 0.1)
293
+ unicode_utils (1.4.0)
294
+ wwtd (1.3.0)
295
+
296
+ PLATFORMS
297
+ ruby
298
+
299
+ DEPENDENCIES
300
+ actionpack (~> 5.2.0)
301
+ country_select!
302
+ pry (~> 0)
303
+ psych
304
+ racc
305
+ railties (~> 5.2.0)
306
+ rake
307
+ rspec (~> 3)
308
+ rubysl (~> 2.0)
309
+ wwtd
310
+
311
+ BUNDLED WITH
312
+ 1.17.1
@@ -1,122 +1,14 @@
1
- # CountrySelect
2
- #
3
- # Adds #country_select method to
4
- # ActionView::FormBuilder
5
- #
6
- require 'country_select/version'
7
- require 'country_select/countries'
8
-
9
- module ActionView
10
- module Helpers
11
- module FormOptionsHelper
12
- #
13
- # Return select and option tags
14
- # for the given object and method,
15
- # using country_options_for_select to
16
- # generate the list of option tags.
17
- #
18
- def country_select(object, method, priority_countries = nil,
19
- options = {},
20
- html_options = {})
21
-
22
- tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
- ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
-
25
- InstanceTag.new(object, method, self, options.delete(:object))
26
- else
27
- CountrySelect.new(object, method, self, options)
28
- end
29
-
30
- tag.to_country_select_tag(priority_countries, options, html_options)
31
- end
32
-
33
- #
34
- # Returns a string of option tags for
35
- # pretty much any country in the world.
36
- #
37
- # You can also supply an array of countries as
38
- # +priority_countries+ so that they will be
39
- # listed above the rest of the (long) list.
40
- #
41
- # NOTE: Only the option tags are returned, you
42
- # have to wrap this call in a regular HTML
43
- # select tag.
44
- #
45
- def country_options_for_select(selected = nil, priority_countries = nil, use_iso_codes = false)
46
- country_options = "".html_safe
47
-
48
- if priority_countries
49
- priority_countries_options = if use_iso_codes
50
- priority_countries.map do |code|
51
- [
52
- ::CountrySelect::COUNTRIES[code],
53
- code
54
- ]
55
- end
56
- else
57
- priority_countries
58
- end
1
+ # encoding: utf-8
59
2
 
60
- country_options += options_for_select(priority_countries_options, selected)
61
- country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n".html_safe
62
- #
63
- # prevents selected from being included
64
- # twice in the HTML which causes
65
- # some browsers to select the second
66
- # selected option (not priority)
67
- # which makes it harder to select an
68
- # alternative priority country
69
- #
70
- selected = nil if priority_countries.include?(selected)
71
- end
3
+ require 'countries'
4
+ require 'sort_alphabetical'
72
5
 
73
- values = if use_iso_codes
74
- ::CountrySelect::ISO_COUNTRIES_FOR_SELECT
75
- else
76
- ::CountrySelect::COUNTRIES_FOR_SELECT
77
- end
78
-
79
- return country_options + options_for_select(values, selected)
80
- end
81
-
82
- # All the countries included in the country_options output.
83
- end
84
-
85
- module ToCountrySelectTag
86
- def to_country_select_tag(priority_countries, options, html_options)
87
- use_iso_codes = options.delete(:iso_codes)
88
- html_options = html_options.stringify_keys
89
- add_default_name_and_id(html_options)
90
- value = value(object)
91
- content_tag("select",
92
- add_options(
93
- country_options_for_select(value, priority_countries, use_iso_codes),
94
- options, value
95
- ), html_options
96
- )
97
- end
98
- end
99
-
100
- if defined?(ActionView::Helpers::InstanceTag) &&
101
- ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
102
- class InstanceTag
103
- include ToCountrySelectTag
104
- end
105
- else
106
- class CountrySelect < Tags::Base
107
- include ToCountrySelectTag
108
- end
109
- end
110
-
111
- class FormBuilder
112
- def country_select(method, priority_countries = nil,
113
- options = {},
114
- html_options = {})
6
+ require 'country_select/version'
7
+ require 'country_select/formats'
8
+ require 'country_select/tag_helper'
115
9
 
116
- @template.country_select(@object_name, method, priority_countries,
117
- options.merge(:object => @object),
118
- html_options)
119
- end
120
- end
121
- end
10
+ if defined?(ActionView::Helpers::Tags::Base)
11
+ require 'country_select/country_select_helper'
12
+ else
13
+ require 'country_select/rails3/country_select_helper'
122
14
  end