country-select 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +11 -18
- data/lib/country-select.rb +273 -42
- metadata +9 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4c8c1c1ed046fc52c624bda54584f1efff4ef0dc
|
4
|
+
data.tar.gz: 3bc92ba69f7a85b719f66cfd27e727a47d7b8aa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c060a9b620357736ffbd3650c21b841bbbdc25d68dcf9d6042658fd854d42e19518e75081d0290740db5141e16116dce5571fcc82fe5ca5981ceb7aa4e370263
|
7
|
+
data.tar.gz: cedba4dcf3bcc321280d3bdcb5b9d165d4fd7f98a83312ed2638100620d56de8180ae84a3d11acfb4d6a1ce15de90c6cc2f0836462a3007914ff39ea749ead8c
|
data/README.md
CHANGED
@@ -1,20 +1,10 @@
|
|
1
1
|
# Country-Select
|
2
2
|
|
3
|
-
|
3
|
+
_Compatible with Rails 5.2_
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Latest Changes
|
8
|
-
|
9
|
-
**1.1.1**
|
10
|
-
|
11
|
-
- Fixed incompatibility with Rails 3.2.2 (thanks to [jmazzi](https://github.com/jamesds/country-select/pull/4))
|
5
|
+
Provides a simple helper to get a HTML select list of countries. The list of countries comes from the ISO 3166 standard. While it is a relatively neutral source of country names, it may still offend some users.
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
- Updated the country list to change the name of *Libyan Arab Jamahiriya* to *Libya* according to the [latest ISO 3166 newsletter](http://www.iso.org/iso/nl_vi-11_name_change_for_libya.pdf)
|
16
|
-
- A country in the priority list will be selected there and not in the main list (thanks to [yyyc514](https://github.com/jamesds/country-select/pull/3))
|
17
|
-
- Removed relics from the pre-gem days
|
7
|
+
Users are strongly advised to evaluate the suitability of this list given their user base.
|
18
8
|
|
19
9
|
## Installation
|
20
10
|
|
@@ -35,12 +25,15 @@ Simple use supplying model and attribute as parameters:
|
|
35
25
|
Supplying priority countries to be placed at the top of the list:
|
36
26
|
|
37
27
|
country_select("user", "country_name", [ "United Kingdom", "France", "Germany" ])
|
28
|
+
|
29
|
+
Supplying additiontal options:
|
30
|
+
|
31
|
+
country_select("user", "country_name", [ "United Kingdom", "France", "Germany" ], {:prompt => "Choose Country"}, {:class => "country-chooser"})
|
38
32
|
|
39
|
-
|
33
|
+
Using together with `form_for` or `fields_for`:
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
- **1.0.2** - forked the plugin and made it into a gem
|
35
|
+
<%= form_for @user do |f| %>
|
36
|
+
<%= f.country_select("country_name") %>
|
37
|
+
<% end %>
|
45
38
|
|
46
39
|
Copyright (c) 2008 Michael Koziarski, released under the MIT license
|
data/lib/country-select.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
# CountrySelect
|
2
3
|
module ActionView
|
3
4
|
module Helpers
|
4
5
|
module FormOptionsHelper
|
5
6
|
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
6
7
|
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
7
|
-
|
8
|
+
if Rails.version.starts_with?("3")
|
9
|
+
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
|
10
|
+
else
|
11
|
+
Tags::CountrySelect.new(object, method, self, options).to_country_select_tag(priority_countries, options, html_options)
|
12
|
+
end
|
8
13
|
end
|
9
14
|
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
|
10
15
|
# have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
|
@@ -33,53 +38,265 @@ module ActionView
|
|
33
38
|
end
|
34
39
|
|
35
40
|
# All the countries included in the country_options output.
|
36
|
-
COUNTRIES = [
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"
|
40
|
-
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
|
74
|
-
|
41
|
+
COUNTRIES = [
|
42
|
+
"Afghanistan",
|
43
|
+
"Åland Islands",
|
44
|
+
"Albania",
|
45
|
+
"Algeria",
|
46
|
+
"American Samoa",
|
47
|
+
"Andorra",
|
48
|
+
"Angola",
|
49
|
+
"Anguilla",
|
50
|
+
"Antarctica",
|
51
|
+
"Antigua and Barbuda",
|
52
|
+
"Argentina",
|
53
|
+
"Armenia",
|
54
|
+
"Aruba",
|
55
|
+
"Australia",
|
56
|
+
"Austria",
|
57
|
+
"Azerbaijan",
|
58
|
+
"Bahamas",
|
59
|
+
"Bahrain",
|
60
|
+
"Bangladesh",
|
61
|
+
"Barbados",
|
62
|
+
"Belarus",
|
63
|
+
"Belgium",
|
64
|
+
"Belize",
|
65
|
+
"Benin",
|
66
|
+
"Bermuda",
|
67
|
+
"Bhutan",
|
68
|
+
"Bolivia",
|
69
|
+
"Bonaire, Sint Eustatius and Saba",
|
70
|
+
"Bosnia and Herzegovina",
|
71
|
+
"Botswana",
|
72
|
+
"Bouvet Island",
|
73
|
+
"Brazil",
|
74
|
+
"British Indian Ocean Territory",
|
75
|
+
"Brunei Darussalam",
|
76
|
+
"Bulgaria",
|
77
|
+
"Burkina Faso",
|
78
|
+
"Burundi",
|
79
|
+
"Cambodia",
|
80
|
+
"Cameroon",
|
81
|
+
"Canada",
|
82
|
+
"Cape Verde",
|
83
|
+
"Cayman Islands",
|
84
|
+
"Central African Republic",
|
85
|
+
"Chad",
|
86
|
+
"Chile",
|
87
|
+
"China",
|
88
|
+
"Christmas Island",
|
89
|
+
"Cocos (Keeling) Islands",
|
90
|
+
"Colombia",
|
91
|
+
"Comoros",
|
92
|
+
"Congo",
|
93
|
+
"Congo, The Democratic Republic of the",
|
94
|
+
"Cook Islands",
|
95
|
+
"Costa Rica",
|
96
|
+
"Côte d'Ivoire",
|
97
|
+
"Croatia",
|
98
|
+
"Cuba",
|
99
|
+
"Curaçao",
|
100
|
+
"Cyprus",
|
101
|
+
"Czech Republic",
|
102
|
+
"Denmark",
|
103
|
+
"Djibouti",
|
104
|
+
"Dominica",
|
105
|
+
"Dominican Republic",
|
106
|
+
"Ecuador",
|
107
|
+
"Egypt",
|
108
|
+
"El Salvador",
|
109
|
+
"Equatorial Guinea",
|
110
|
+
"Eritrea",
|
111
|
+
"Estonia",
|
112
|
+
"Eswatini",
|
113
|
+
"Ethiopia",
|
114
|
+
"Falkland Islands (Malvinas)",
|
115
|
+
"Faroe Islands",
|
116
|
+
"Fiji",
|
117
|
+
"Finland",
|
118
|
+
"France",
|
119
|
+
"French Guiana",
|
120
|
+
"French Polynesia",
|
121
|
+
"French Southern Territories",
|
122
|
+
"Gabon",
|
123
|
+
"Gambia",
|
124
|
+
"Georgia",
|
125
|
+
"Germany",
|
126
|
+
"Ghana",
|
127
|
+
"Gibraltar",
|
128
|
+
"Greece",
|
129
|
+
"Greenland",
|
130
|
+
"Grenada",
|
131
|
+
"Guadeloupe",
|
132
|
+
"Guam",
|
133
|
+
"Guatemala",
|
134
|
+
"Guernsey",
|
135
|
+
"Guinea",
|
136
|
+
"Guinea-Bissau",
|
137
|
+
"Guyana",
|
138
|
+
"Haiti",
|
139
|
+
"Heard Island and McDonald Islands",
|
140
|
+
"Holy See (Vatican City State)",
|
141
|
+
"Honduras",
|
142
|
+
"Hong Kong",
|
143
|
+
"Hungary",
|
144
|
+
"Iceland",
|
145
|
+
"India",
|
146
|
+
"Indonesia",
|
147
|
+
"Iran, Islamic Republic of",
|
148
|
+
"Iraq",
|
149
|
+
"Ireland",
|
150
|
+
"Isle of Man",
|
151
|
+
"Israel",
|
152
|
+
"Italy",
|
153
|
+
"Jamaica",
|
154
|
+
"Japan",
|
155
|
+
"Jersey",
|
156
|
+
"Jordan",
|
157
|
+
"Kazakhstan",
|
158
|
+
"Kenya",
|
159
|
+
"Kiribati",
|
160
|
+
"Korea, Democratic People's Republic of",
|
161
|
+
"Korea, Republic of",
|
162
|
+
"Kuwait",
|
163
|
+
"Kyrgyzstan",
|
164
|
+
"Lao People's Democratic Republic",
|
165
|
+
"Latvia",
|
166
|
+
"Lebanon",
|
167
|
+
"Lesotho",
|
168
|
+
"Liberia",
|
169
|
+
"Libya",
|
170
|
+
"Liechtenstein",
|
171
|
+
"Lithuania",
|
172
|
+
"Luxembourg",
|
173
|
+
"Macao",
|
174
|
+
"Republic of North Macedonia",
|
175
|
+
"Madagascar",
|
176
|
+
"Malawi",
|
177
|
+
"Malaysia",
|
178
|
+
"Maldives",
|
179
|
+
"Mali",
|
180
|
+
"Malta",
|
181
|
+
"Marshall Islands",
|
182
|
+
"Martinique",
|
183
|
+
"Mauritania",
|
184
|
+
"Mauritius",
|
185
|
+
"Mayotte",
|
186
|
+
"Mexico",
|
187
|
+
"Micronesia, Federated States of",
|
188
|
+
"Moldova, Republic of",
|
189
|
+
"Monaco",
|
190
|
+
"Mongolia",
|
191
|
+
"Montenegro",
|
192
|
+
"Montserrat",
|
193
|
+
"Morocco",
|
194
|
+
"Mozambique",
|
195
|
+
"Myanmar",
|
196
|
+
"Namibia",
|
197
|
+
"Nauru",
|
198
|
+
"Nepal",
|
199
|
+
"Netherlands",
|
200
|
+
"New Caledonia",
|
201
|
+
"New Zealand",
|
202
|
+
"Nicaragua",
|
203
|
+
"Niger",
|
204
|
+
"Nigeria",
|
205
|
+
"Niue",
|
206
|
+
"Norfolk Island",
|
207
|
+
"Northern Mariana Islands",
|
208
|
+
"Norway",
|
209
|
+
"Oman",
|
210
|
+
"Pakistan",
|
211
|
+
"Palau",
|
212
|
+
"Palestine, State of",
|
213
|
+
"Panama",
|
214
|
+
"Papua New Guinea",
|
215
|
+
"Paraguay",
|
216
|
+
"Peru",
|
217
|
+
"Philippines",
|
218
|
+
"Pitcairn",
|
219
|
+
"Poland",
|
220
|
+
"Portugal",
|
221
|
+
"Puerto Rico",
|
222
|
+
"Qatar",
|
223
|
+
"Reunion",
|
224
|
+
"Romania",
|
225
|
+
"Russian Federation",
|
226
|
+
"Rwanda",
|
227
|
+
"Saint Barthélemy",
|
228
|
+
"Saint Helena, Ascension and Tristan da Cunha",
|
229
|
+
"Saint Kitts and Nevis",
|
230
|
+
"Saint Lucia",
|
231
|
+
"Saint Martin (French Part)",
|
232
|
+
"Saint Pierre and Miquelon",
|
233
|
+
"Saint Vincent and the Grenadines",
|
234
|
+
"Samoa",
|
235
|
+
"San Marino",
|
236
|
+
"Sao Tome and Principe",
|
237
|
+
"Saudi Arabia",
|
238
|
+
"Senegal",
|
239
|
+
"Serbia",
|
240
|
+
"Seychelles",
|
241
|
+
"Sierra Leone",
|
242
|
+
"Singapore",
|
243
|
+
"Sint Maarten (Dutch Part)",
|
244
|
+
"Slovakia",
|
245
|
+
"Slovenia",
|
246
|
+
"Solomon Islands",
|
247
|
+
"Somalia",
|
248
|
+
"South Africa",
|
249
|
+
"South Georgia and the South Sandwich Islands",
|
250
|
+
"South Sudan",
|
251
|
+
"Spain",
|
252
|
+
"Sri Lanka",
|
253
|
+
"Sudan",
|
254
|
+
"Suriname",
|
255
|
+
"Svalbard and Jan Mayen",
|
256
|
+
"Sweden",
|
257
|
+
"Switzerland",
|
258
|
+
"Syrian Arab Republic",
|
259
|
+
"Taiwan",
|
260
|
+
"Tajikistan",
|
261
|
+
"Tanzania, United Republic of",
|
262
|
+
"Thailand",
|
263
|
+
"Timor-Leste",
|
264
|
+
"Togo",
|
265
|
+
"Tokelau",
|
266
|
+
"Tonga",
|
267
|
+
"Trinidad and Tobago",
|
268
|
+
"Tunisia",
|
269
|
+
"Turkey",
|
270
|
+
"Turkmenistan",
|
271
|
+
"Turks and Caicos Islands",
|
272
|
+
"Tuvalu",
|
273
|
+
"Uganda",
|
274
|
+
"Ukraine",
|
275
|
+
"United Arab Emirates",
|
276
|
+
"United Kingdom",
|
277
|
+
"United States",
|
278
|
+
"United States Minor Outlying Islands",
|
279
|
+
"Uruguay",
|
280
|
+
"Uzbekistan",
|
281
|
+
"Vanuatu",
|
282
|
+
"Venezuela",
|
283
|
+
"Viet Nam",
|
284
|
+
"Virgin Islands, British",
|
285
|
+
"Virgin Islands, U.S.",
|
286
|
+
"Wallis and Futuna",
|
287
|
+
"Western Sahara",
|
288
|
+
"Yemen",
|
289
|
+
"Zambia",
|
290
|
+
"Zimbabwe"
|
291
|
+
] unless const_defined?("COUNTRIES")
|
75
292
|
end
|
76
293
|
|
77
|
-
|
294
|
+
module CountrySelectTag
|
78
295
|
def to_country_select_tag(priority_countries, options, html_options)
|
79
296
|
html_options = html_options.stringify_keys
|
80
297
|
add_default_name_and_id(html_options)
|
81
|
-
value = value(object)
|
82
298
|
content_tag("select",
|
299
|
+
|
83
300
|
add_options(
|
84
301
|
country_options_for_select(value, priority_countries),
|
85
302
|
options, value
|
@@ -88,6 +305,20 @@ module ActionView
|
|
88
305
|
end
|
89
306
|
end
|
90
307
|
|
308
|
+
# For Rails 4.x / 5.x
|
309
|
+
if Rails.version.to_i >= 4
|
310
|
+
module Tags
|
311
|
+
class CountrySelect < Base
|
312
|
+
include CountrySelectTag
|
313
|
+
end
|
314
|
+
end
|
315
|
+
else
|
316
|
+
# For Rails 3.x
|
317
|
+
class InstanceTag
|
318
|
+
include CountrySelectTag
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
91
322
|
class FormBuilder
|
92
323
|
def country_select(method, priority_countries = nil, options = {}, html_options = {})
|
93
324
|
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country-select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Koziarski
|
@@ -10,8 +9,7 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2012-03-02 00:00:00.000000000
|
14
|
-
default_executable:
|
12
|
+
date: 2012-03-02 00:00:00.000000000 Z
|
15
13
|
dependencies: []
|
16
14
|
description: Provides a form helper to insert a country select box using the ISO 3166
|
17
15
|
country list
|
@@ -20,32 +18,30 @@ executables: []
|
|
20
18
|
extensions: []
|
21
19
|
extra_rdoc_files: []
|
22
20
|
files:
|
23
|
-
- lib/country-select.rb
|
24
|
-
- README.md
|
25
21
|
- MIT-LICENSE
|
26
|
-
|
22
|
+
- README.md
|
23
|
+
- lib/country-select.rb
|
27
24
|
homepage: http://github.com/jamesds/country-select
|
28
25
|
licenses: []
|
26
|
+
metadata: {}
|
29
27
|
post_install_message:
|
30
28
|
rdoc_options: []
|
31
29
|
require_paths:
|
32
30
|
- lib
|
33
31
|
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
32
|
requirements:
|
36
|
-
- -
|
33
|
+
- - ">="
|
37
34
|
- !ruby/object:Gem::Version
|
38
35
|
version: '0'
|
39
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
37
|
requirements:
|
42
|
-
- -
|
38
|
+
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: '0'
|
45
41
|
requirements: []
|
46
42
|
rubyforge_project:
|
47
|
-
rubygems_version:
|
43
|
+
rubygems_version: 2.5.1
|
48
44
|
signing_key:
|
49
|
-
specification_version:
|
45
|
+
specification_version: 4
|
50
46
|
summary: Country select box
|
51
47
|
test_files: []
|