rails_country_select 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +1 -0
- data/lib/country_definitions.rb +1010 -0
- data/lib/rails_country_select.rb +33 -0
- data/lib/rails_country_select/version.rb +3 -0
- data/rails_country_select.gemspec +23 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjExMDQ1MTZhYTRiODJhNjljZWRjNTVjYzA1MDE2ODlkNTRjNjFmOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDljOGRjMjM3M2MwODRkZmM4NWM0MzY3MGY0NWYwOGFiMzFhYjdlNQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTNjY2FhODVmYjIzNjMzMzdlN2JhZGM3MGFmOWUwZGE0NTU2MWJiYTI2MjM5
|
10
|
+
YjlhOGI4NGY0OTFlMjZjZGMyYzA1YjkwYzVjMzdmZGZmYTdhMGNiNWEwZDM5
|
11
|
+
YWYwOTcwOTM5NDViNmM4NTY5NGI5ZmI3ZTIxNTk2N2ZjODdjN2Y=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzEyZTExMGEyNmUwNjAwYWQ5NWY0M2EyMTBjZjc2MmM0N2Y1OGQ2ZjRmNzVj
|
14
|
+
ZGQ0MWJlMmFkNWQyYzI0MDk1Njk0YjYxMjM3Y2JiOTIwZWRkNzk3NmQ1NTRi
|
15
|
+
OTYzYWRiOTBmMzE0ODY5ZmJhMmM4ZDhlMTkzM2I3YzkyZTg0YmE=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ruben Espinosa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# RailsCountrySelect
|
2
|
+
This project is based on Rails 2 plugin created by LukeCarrier [rails-country-select](https://github.com/rderoldan1/rails-country-select/blob/master/lib/country_definitions.rb)
|
3
|
+
Select tag in order to choose a country in your forms, provides 4 options.
|
4
|
+
1. Country Name.
|
5
|
+
2. Cod
|
6
|
+
3. ISO cod 2 chars ('CO', 'AF', 'AX', 'AL')
|
7
|
+
4. ISO cod 3 chars ('COL', 'AFG', 'ALA', ALB')
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'rails_country_select'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rails_country_select
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Basic
|
26
|
+
value : country cod number
|
27
|
+
text : country name
|
28
|
+
```ruby
|
29
|
+
<%= form_for @user do |f| %>
|
30
|
+
<%= f.country_select :country %>
|
31
|
+
<% end %>
|
32
|
+
```
|
33
|
+
|
34
|
+
HTML generated
|
35
|
+
```html
|
36
|
+
<select id="cliente_nacionalidad" name="user[country]">
|
37
|
+
<option value="4">Afghanistan</option>
|
38
|
+
<option value="248">Albania</option>
|
39
|
+
<option value="8">Ã
land Islands</option>
|
40
|
+
<option value="12">Algeria</option>
|
41
|
+
``
|
42
|
+
|
43
|
+
### Advanced
|
44
|
+
values, keys : [:names, :nums, :alpha2s, :alpha3s]
|
45
|
+
selected : set default value
|
46
|
+
prompt : message
|
47
|
+
```ruby
|
48
|
+
<%= form_for @user do |f| %>
|
49
|
+
<%= f.country_select :country, {:keys => :names, :values => :alpha2s, :selected => "CO"}, :prompt => "Choose a country"
|
50
|
+
<% end %>
|
51
|
+
```
|
52
|
+
|
53
|
+
HTML generated
|
54
|
+
```html
|
55
|
+
<select id="cliente_nacionalidad" name="user[country]" prompt="Choose a country" value="CO">
|
56
|
+
<option value="AF">Afghanistan</option>
|
57
|
+
<option value="AL">Albania</option>
|
58
|
+
<option value="AX">Ã
land Islands</option>
|
59
|
+
<option value="DZ">Algeria</option>
|
60
|
+
``
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,1010 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
COUNTRY_NAMES = [
|
4
|
+
'Afghanistan',
|
5
|
+
'Aland Islands',
|
6
|
+
'Albania',
|
7
|
+
'Algeria',
|
8
|
+
'American Samoa',
|
9
|
+
'Andorra',
|
10
|
+
'Angola',
|
11
|
+
'Anguilla',
|
12
|
+
'Antarctica',
|
13
|
+
'Antigua and Barbuda',
|
14
|
+
'Argentina',
|
15
|
+
'Armenia',
|
16
|
+
'Aruba',
|
17
|
+
'Australia',
|
18
|
+
'Austria',
|
19
|
+
'Azerbaijan',
|
20
|
+
'Bahamas',
|
21
|
+
'Bahrain',
|
22
|
+
'Bangladesh',
|
23
|
+
'Barbados',
|
24
|
+
'Belarus',
|
25
|
+
'Belgium',
|
26
|
+
'Belize',
|
27
|
+
'Benin',
|
28
|
+
'Bermuda',
|
29
|
+
'Bhutan',
|
30
|
+
'Bolivia, Plurinational State of',
|
31
|
+
'Bonaire, Sint Eustatius and Saba',
|
32
|
+
'Bosnia and Herzegovina',
|
33
|
+
'Botswana',
|
34
|
+
'Bouvet Island',
|
35
|
+
'Brazil',
|
36
|
+
'British Indian Ocean Territory',
|
37
|
+
'Brunei Darussalam',
|
38
|
+
'Bulgaria',
|
39
|
+
'Burkina Faso',
|
40
|
+
'Burundi',
|
41
|
+
'Cambodia',
|
42
|
+
'Cameroon',
|
43
|
+
'Canada',
|
44
|
+
'Cape Verde',
|
45
|
+
'Cayman Islands',
|
46
|
+
'Central African Republic',
|
47
|
+
'Chad',
|
48
|
+
'Chile',
|
49
|
+
'China',
|
50
|
+
'Christmas Island',
|
51
|
+
'Cocos (Keeling) Islands',
|
52
|
+
'Colombia',
|
53
|
+
'Comoros',
|
54
|
+
'Congo',
|
55
|
+
'Congo, the Democratic Republic of the',
|
56
|
+
'Cook Islands',
|
57
|
+
'Costa Rica',
|
58
|
+
'Côte d\'Ivoire',
|
59
|
+
'Croatia',
|
60
|
+
'Cuba',
|
61
|
+
'Curaçao',
|
62
|
+
'Cyprus',
|
63
|
+
'Czech Republic',
|
64
|
+
'Denmark',
|
65
|
+
'Djibouti',
|
66
|
+
'Dominica',
|
67
|
+
'Dominican Republic',
|
68
|
+
'Ecuador',
|
69
|
+
'Egypt',
|
70
|
+
'El Salvador',
|
71
|
+
'Equatorial Guinea',
|
72
|
+
'Eritrea',
|
73
|
+
'Estonia',
|
74
|
+
'Ethiopia',
|
75
|
+
'Falkland Islands (Malvinas)',
|
76
|
+
'Faroe Islands',
|
77
|
+
'Fiji',
|
78
|
+
'Finland',
|
79
|
+
'France',
|
80
|
+
'French Guiana',
|
81
|
+
'French Polynesia',
|
82
|
+
'French Southern Territories',
|
83
|
+
'Gabon',
|
84
|
+
'Gambia',
|
85
|
+
'Georgia',
|
86
|
+
'Germany',
|
87
|
+
'Ghana',
|
88
|
+
'Gibraltar',
|
89
|
+
'Greece',
|
90
|
+
'Greenland',
|
91
|
+
'Grenada',
|
92
|
+
'Guadeloupe',
|
93
|
+
'Guam',
|
94
|
+
'Guatemala',
|
95
|
+
'Guernsey',
|
96
|
+
'Guinea',
|
97
|
+
'Guinea-Bissau',
|
98
|
+
'Guyana',
|
99
|
+
'Haiti',
|
100
|
+
'Heard Island and McDonald Islands',
|
101
|
+
'Holy See (Vatican City State)',
|
102
|
+
'Honduras',
|
103
|
+
'Hong Kong',
|
104
|
+
'Hungary',
|
105
|
+
'Iceland',
|
106
|
+
'India',
|
107
|
+
'Indonesia',
|
108
|
+
'Iran, Islamic Republic of',
|
109
|
+
'Iraq',
|
110
|
+
'Ireland',
|
111
|
+
'Isle of Man',
|
112
|
+
'Israel',
|
113
|
+
'Italy',
|
114
|
+
'Jamaica',
|
115
|
+
'Japan',
|
116
|
+
'Jersey',
|
117
|
+
'Jordan',
|
118
|
+
'Kazakhstan',
|
119
|
+
'Kenya',
|
120
|
+
'Kiribati',
|
121
|
+
'Korea, Democratic People\'s Republic of',
|
122
|
+
'Korea, Republic of',
|
123
|
+
'Kuwait',
|
124
|
+
'Kyrgyzstan',
|
125
|
+
'Lao People\'s Democratic Republic',
|
126
|
+
'Latvia',
|
127
|
+
'Lebanon',
|
128
|
+
'Lesotho',
|
129
|
+
'Liberia',
|
130
|
+
'Libyan Arab Jamahiriya',
|
131
|
+
'Liechtenstein',
|
132
|
+
'Lithuania',
|
133
|
+
'Luxembourg',
|
134
|
+
'Macao',
|
135
|
+
'Macedonia, the former Yugoslav Republic of',
|
136
|
+
'Madagascar',
|
137
|
+
'Malawi',
|
138
|
+
'Malaysia',
|
139
|
+
'Maldives',
|
140
|
+
'Mali',
|
141
|
+
'Malta',
|
142
|
+
'Marshall Islands',
|
143
|
+
'Martinique',
|
144
|
+
'Mauritania',
|
145
|
+
'Mauritius',
|
146
|
+
'Mayotte',
|
147
|
+
'Mexico',
|
148
|
+
'Micronesia, Federated States of',
|
149
|
+
'Moldova, Republic of',
|
150
|
+
'Monaco',
|
151
|
+
'Mongolia',
|
152
|
+
'Montenegro',
|
153
|
+
'Montserrat',
|
154
|
+
'Morocco',
|
155
|
+
'Mozambique',
|
156
|
+
'Myanmar',
|
157
|
+
'Namibia',
|
158
|
+
'Nauru',
|
159
|
+
'Nepal',
|
160
|
+
'Netherlands',
|
161
|
+
'New Caledonia',
|
162
|
+
'New Zealand',
|
163
|
+
'Nicaragua',
|
164
|
+
'Niger',
|
165
|
+
'Nigeria',
|
166
|
+
'Niue',
|
167
|
+
'Norfolk Island',
|
168
|
+
'Northern Mariana Islands',
|
169
|
+
'Norway',
|
170
|
+
'Oman',
|
171
|
+
'Pakistan',
|
172
|
+
'Palau',
|
173
|
+
'Palestinian Territory, Occupied',
|
174
|
+
'Panama',
|
175
|
+
'Papua New Guinea',
|
176
|
+
'Paraguay',
|
177
|
+
'Peru',
|
178
|
+
'Philippines',
|
179
|
+
'Pitcairn',
|
180
|
+
'Poland',
|
181
|
+
'Portugal',
|
182
|
+
'Puerto Rico',
|
183
|
+
'Qatar',
|
184
|
+
'Réunion',
|
185
|
+
'Romania',
|
186
|
+
'Russian Federation',
|
187
|
+
'Rwanda',
|
188
|
+
'Saint Barthélemy',
|
189
|
+
'Saint Helena, Ascension and Tristan da Cunha',
|
190
|
+
'Saint Kitts and Nevis',
|
191
|
+
'Saint Lucia',
|
192
|
+
'Saint Martin (French part)',
|
193
|
+
'Saint Pierre and Miquelon',
|
194
|
+
'Saint Vincent and the Grenadines',
|
195
|
+
'Samoa',
|
196
|
+
'San Marino',
|
197
|
+
'Sao Tome and Principe',
|
198
|
+
'Saudi Arabia',
|
199
|
+
'Senegal',
|
200
|
+
'Serbia',
|
201
|
+
'Seychelles',
|
202
|
+
'Sierra Leone',
|
203
|
+
'Singapore',
|
204
|
+
'Sint Maarten (Dutch part)',
|
205
|
+
'Slovakia',
|
206
|
+
'Slovenia',
|
207
|
+
'Solomon Islands',
|
208
|
+
'Somalia',
|
209
|
+
'South Africa',
|
210
|
+
'South Georgia and the South Sandwich Islands',
|
211
|
+
'South Sudan',
|
212
|
+
'Spain',
|
213
|
+
'Sri Lanka',
|
214
|
+
'Sudan',
|
215
|
+
'Suriname',
|
216
|
+
'Svalbard and Jan Mayen',
|
217
|
+
'Swaziland',
|
218
|
+
'Sweden',
|
219
|
+
'Switzerland',
|
220
|
+
'Syrian Arab Republic',
|
221
|
+
'Taiwan, Province of China',
|
222
|
+
'Tajikistan',
|
223
|
+
'Tanzania, United Republic of',
|
224
|
+
'Thailand',
|
225
|
+
'Timor-Leste',
|
226
|
+
'Togo',
|
227
|
+
'Tokelau',
|
228
|
+
'Tonga',
|
229
|
+
'Trinidad and Tobago',
|
230
|
+
'Tunisia',
|
231
|
+
'Turkey',
|
232
|
+
'Turkmenistan',
|
233
|
+
'Turks and Caicos Islands',
|
234
|
+
'Tuvalu',
|
235
|
+
'Uganda',
|
236
|
+
'Ukraine',
|
237
|
+
'United Arab Emirates',
|
238
|
+
'United Kingdom',
|
239
|
+
'United States',
|
240
|
+
'United States Minor Outlying Islands',
|
241
|
+
'Uruguay',
|
242
|
+
'Uzbekistan',
|
243
|
+
'Vanuatu',
|
244
|
+
'Venezuela, Bolivarian Republic of',
|
245
|
+
'Viet Nam',
|
246
|
+
'Virgin Islands, British',
|
247
|
+
'Virgin Islands, U.S.',
|
248
|
+
'Wallis and Futuna',
|
249
|
+
'Western Sahara',
|
250
|
+
'Yemen',
|
251
|
+
'Zambia',
|
252
|
+
'Zimbabwe',
|
253
|
+
]
|
254
|
+
|
255
|
+
COUNTRY_ALPHA2S = [
|
256
|
+
'AF',
|
257
|
+
'AX',
|
258
|
+
'AL',
|
259
|
+
'DZ',
|
260
|
+
'AS',
|
261
|
+
'AD',
|
262
|
+
'AO',
|
263
|
+
'AI',
|
264
|
+
'AQ',
|
265
|
+
'AG',
|
266
|
+
'AR',
|
267
|
+
'AM',
|
268
|
+
'AW',
|
269
|
+
'AU',
|
270
|
+
'AT',
|
271
|
+
'AZ',
|
272
|
+
'BS',
|
273
|
+
'BH',
|
274
|
+
'BD',
|
275
|
+
'BB',
|
276
|
+
'BY',
|
277
|
+
'BE',
|
278
|
+
'BZ',
|
279
|
+
'BJ',
|
280
|
+
'BM',
|
281
|
+
'BT',
|
282
|
+
'BO',
|
283
|
+
'BQ',
|
284
|
+
'BA',
|
285
|
+
'BW',
|
286
|
+
'BV',
|
287
|
+
'BR',
|
288
|
+
'IO',
|
289
|
+
'BN',
|
290
|
+
'BG',
|
291
|
+
'BF',
|
292
|
+
'BI',
|
293
|
+
'KH',
|
294
|
+
'CM',
|
295
|
+
'CA',
|
296
|
+
'CV',
|
297
|
+
'KY',
|
298
|
+
'CF',
|
299
|
+
'TD',
|
300
|
+
'CL',
|
301
|
+
'CN',
|
302
|
+
'CX',
|
303
|
+
'CC',
|
304
|
+
'CO',
|
305
|
+
'KM',
|
306
|
+
'CG',
|
307
|
+
'CD',
|
308
|
+
'CK',
|
309
|
+
'CR',
|
310
|
+
'CI',
|
311
|
+
'HR',
|
312
|
+
'CU',
|
313
|
+
'CW',
|
314
|
+
'CY',
|
315
|
+
'CZ',
|
316
|
+
'DK',
|
317
|
+
'DJ',
|
318
|
+
'DM',
|
319
|
+
'DO',
|
320
|
+
'EC',
|
321
|
+
'EG',
|
322
|
+
'SV',
|
323
|
+
'GQ',
|
324
|
+
'ER',
|
325
|
+
'EE',
|
326
|
+
'ET',
|
327
|
+
'FK',
|
328
|
+
'FO',
|
329
|
+
'FJ',
|
330
|
+
'FI',
|
331
|
+
'FR',
|
332
|
+
'GF',
|
333
|
+
'PF',
|
334
|
+
'TF',
|
335
|
+
'GA',
|
336
|
+
'GM',
|
337
|
+
'GE',
|
338
|
+
'DE',
|
339
|
+
'GH',
|
340
|
+
'GI',
|
341
|
+
'GR',
|
342
|
+
'GL',
|
343
|
+
'GD',
|
344
|
+
'GP',
|
345
|
+
'GU',
|
346
|
+
'GT',
|
347
|
+
'GG',
|
348
|
+
'GN',
|
349
|
+
'GW',
|
350
|
+
'GY',
|
351
|
+
'HT',
|
352
|
+
'HM',
|
353
|
+
'VA',
|
354
|
+
'HN',
|
355
|
+
'HK',
|
356
|
+
'HU',
|
357
|
+
'IS',
|
358
|
+
'IN',
|
359
|
+
'ID',
|
360
|
+
'IR',
|
361
|
+
'IQ',
|
362
|
+
'IE',
|
363
|
+
'IM',
|
364
|
+
'IL',
|
365
|
+
'IT',
|
366
|
+
'JM',
|
367
|
+
'JP',
|
368
|
+
'JE',
|
369
|
+
'JO',
|
370
|
+
'KZ',
|
371
|
+
'KE',
|
372
|
+
'KI',
|
373
|
+
'KP',
|
374
|
+
'KR',
|
375
|
+
'KW',
|
376
|
+
'KG',
|
377
|
+
'LA',
|
378
|
+
'LV',
|
379
|
+
'LB',
|
380
|
+
'LS',
|
381
|
+
'LR',
|
382
|
+
'LY',
|
383
|
+
'LI',
|
384
|
+
'LT',
|
385
|
+
'LU',
|
386
|
+
'MO',
|
387
|
+
'MK',
|
388
|
+
'MG',
|
389
|
+
'MW',
|
390
|
+
'MY',
|
391
|
+
'MV',
|
392
|
+
'ML',
|
393
|
+
'MT',
|
394
|
+
'MH',
|
395
|
+
'MQ',
|
396
|
+
'MR',
|
397
|
+
'MU',
|
398
|
+
'YT',
|
399
|
+
'MX',
|
400
|
+
'FM',
|
401
|
+
'MD',
|
402
|
+
'MC',
|
403
|
+
'MN',
|
404
|
+
'ME',
|
405
|
+
'MS',
|
406
|
+
'MA',
|
407
|
+
'MZ',
|
408
|
+
'MM',
|
409
|
+
'NA',
|
410
|
+
'NR',
|
411
|
+
'NP',
|
412
|
+
'NL',
|
413
|
+
'NC',
|
414
|
+
'NZ',
|
415
|
+
'NI',
|
416
|
+
'NE',
|
417
|
+
'NG',
|
418
|
+
'NU',
|
419
|
+
'NF',
|
420
|
+
'MP',
|
421
|
+
'NO',
|
422
|
+
'OM',
|
423
|
+
'PK',
|
424
|
+
'PW',
|
425
|
+
'PS',
|
426
|
+
'PA',
|
427
|
+
'PG',
|
428
|
+
'PY',
|
429
|
+
'PE',
|
430
|
+
'PH',
|
431
|
+
'PN',
|
432
|
+
'PL',
|
433
|
+
'PT',
|
434
|
+
'PR',
|
435
|
+
'QA',
|
436
|
+
'RE',
|
437
|
+
'RO',
|
438
|
+
'RU',
|
439
|
+
'RW',
|
440
|
+
'BL',
|
441
|
+
'SH',
|
442
|
+
'KN',
|
443
|
+
'LC',
|
444
|
+
'MF',
|
445
|
+
'PM',
|
446
|
+
'VC',
|
447
|
+
'WS',
|
448
|
+
'SM',
|
449
|
+
'ST',
|
450
|
+
'SA',
|
451
|
+
'SN',
|
452
|
+
'RS',
|
453
|
+
'SC',
|
454
|
+
'SL',
|
455
|
+
'SG',
|
456
|
+
'SX',
|
457
|
+
'SK',
|
458
|
+
'SI',
|
459
|
+
'SB',
|
460
|
+
'SO',
|
461
|
+
'ZA',
|
462
|
+
'GS',
|
463
|
+
'SS',
|
464
|
+
'ES',
|
465
|
+
'LK',
|
466
|
+
'SD',
|
467
|
+
'SR',
|
468
|
+
'SJ',
|
469
|
+
'SZ',
|
470
|
+
'SE',
|
471
|
+
'CH',
|
472
|
+
'SY',
|
473
|
+
'TW',
|
474
|
+
'TJ',
|
475
|
+
'TZ',
|
476
|
+
'TH',
|
477
|
+
'TL',
|
478
|
+
'TG',
|
479
|
+
'TK',
|
480
|
+
'TO',
|
481
|
+
'TT',
|
482
|
+
'TN',
|
483
|
+
'TR',
|
484
|
+
'TM',
|
485
|
+
'TC',
|
486
|
+
'TV',
|
487
|
+
'UG',
|
488
|
+
'UA',
|
489
|
+
'AE',
|
490
|
+
'GB',
|
491
|
+
'US',
|
492
|
+
'UM',
|
493
|
+
'UY',
|
494
|
+
'UZ',
|
495
|
+
'VU',
|
496
|
+
'VE',
|
497
|
+
'VN',
|
498
|
+
'VG',
|
499
|
+
'VI',
|
500
|
+
'WF',
|
501
|
+
'EH',
|
502
|
+
'YE',
|
503
|
+
'ZM',
|
504
|
+
'ZW',
|
505
|
+
]
|
506
|
+
|
507
|
+
COUNTRY_ALPHA3S = [
|
508
|
+
'AFG',
|
509
|
+
'ALA',
|
510
|
+
'ALB',
|
511
|
+
'DZA',
|
512
|
+
'ASM',
|
513
|
+
'AND',
|
514
|
+
'AGO',
|
515
|
+
'AIA',
|
516
|
+
'ATA',
|
517
|
+
'ATG',
|
518
|
+
'ARG',
|
519
|
+
'ARM',
|
520
|
+
'ABW',
|
521
|
+
'AUS',
|
522
|
+
'AUT',
|
523
|
+
'AZE',
|
524
|
+
'BHS',
|
525
|
+
'BHR',
|
526
|
+
'BGD',
|
527
|
+
'BRB',
|
528
|
+
'BLR',
|
529
|
+
'BEL',
|
530
|
+
'BLZ',
|
531
|
+
'BEN',
|
532
|
+
'BMU',
|
533
|
+
'BTN',
|
534
|
+
'BOL',
|
535
|
+
'BES',
|
536
|
+
'BIH',
|
537
|
+
'BWA',
|
538
|
+
'BVT',
|
539
|
+
'BRA',
|
540
|
+
'IOT',
|
541
|
+
'BRN',
|
542
|
+
'BGR',
|
543
|
+
'BFA',
|
544
|
+
'BDI',
|
545
|
+
'KHM',
|
546
|
+
'CMR',
|
547
|
+
'CAN',
|
548
|
+
'CPV',
|
549
|
+
'CYM',
|
550
|
+
'CAF',
|
551
|
+
'TCD',
|
552
|
+
'CHL',
|
553
|
+
'CHN',
|
554
|
+
'CXR',
|
555
|
+
'CCK',
|
556
|
+
'COL',
|
557
|
+
'COM',
|
558
|
+
'COG',
|
559
|
+
'COD',
|
560
|
+
'COK',
|
561
|
+
'CRI',
|
562
|
+
'CIV',
|
563
|
+
'HRV',
|
564
|
+
'CUB',
|
565
|
+
'CUW',
|
566
|
+
'CYP',
|
567
|
+
'CZE',
|
568
|
+
'DNK',
|
569
|
+
'DJI',
|
570
|
+
'DMA',
|
571
|
+
'DOM',
|
572
|
+
'ECU',
|
573
|
+
'EGY',
|
574
|
+
'SLV',
|
575
|
+
'GNQ',
|
576
|
+
'ERI',
|
577
|
+
'EST',
|
578
|
+
'ETH',
|
579
|
+
'FLK',
|
580
|
+
'FRO',
|
581
|
+
'FJI',
|
582
|
+
'FIN',
|
583
|
+
'FRA',
|
584
|
+
'GUF',
|
585
|
+
'PYF',
|
586
|
+
'ATF',
|
587
|
+
'GAB',
|
588
|
+
'GMB',
|
589
|
+
'GEO',
|
590
|
+
'DEU',
|
591
|
+
'GHA',
|
592
|
+
'GIB',
|
593
|
+
'GRC',
|
594
|
+
'GRL',
|
595
|
+
'GRD',
|
596
|
+
'GLP',
|
597
|
+
'GUM',
|
598
|
+
'GTM',
|
599
|
+
'GGY',
|
600
|
+
'GIN',
|
601
|
+
'GNB',
|
602
|
+
'GUY',
|
603
|
+
'HTI',
|
604
|
+
'HMD',
|
605
|
+
'VAT',
|
606
|
+
'HND',
|
607
|
+
'HKG',
|
608
|
+
'HUN',
|
609
|
+
'ISL',
|
610
|
+
'IND',
|
611
|
+
'IDN',
|
612
|
+
'IRN',
|
613
|
+
'IRQ',
|
614
|
+
'IRL',
|
615
|
+
'IMN',
|
616
|
+
'ISR',
|
617
|
+
'ITA',
|
618
|
+
'JAM',
|
619
|
+
'JPN',
|
620
|
+
'JEY',
|
621
|
+
'JOR',
|
622
|
+
'KAZ',
|
623
|
+
'KEN',
|
624
|
+
'KIR',
|
625
|
+
'PRK',
|
626
|
+
'KOR',
|
627
|
+
'KWT',
|
628
|
+
'KGZ',
|
629
|
+
'LAO',
|
630
|
+
'LVA',
|
631
|
+
'LBN',
|
632
|
+
'LSO',
|
633
|
+
'LBR',
|
634
|
+
'LBY',
|
635
|
+
'LIE',
|
636
|
+
'LTU',
|
637
|
+
'LUX',
|
638
|
+
'MAC',
|
639
|
+
'MKD',
|
640
|
+
'MDG',
|
641
|
+
'MWI',
|
642
|
+
'MYS',
|
643
|
+
'MDV',
|
644
|
+
'MLI',
|
645
|
+
'MLT',
|
646
|
+
'MHL',
|
647
|
+
'MTQ',
|
648
|
+
'MRT',
|
649
|
+
'MUS',
|
650
|
+
'MYT',
|
651
|
+
'MEX',
|
652
|
+
'FSM',
|
653
|
+
'MDA',
|
654
|
+
'MCO',
|
655
|
+
'MNG',
|
656
|
+
'MNE',
|
657
|
+
'MSR',
|
658
|
+
'MAR',
|
659
|
+
'MOZ',
|
660
|
+
'MMR',
|
661
|
+
'NAM',
|
662
|
+
'NRU',
|
663
|
+
'NPL',
|
664
|
+
'NLD',
|
665
|
+
'NCL',
|
666
|
+
'NZL',
|
667
|
+
'NIC',
|
668
|
+
'NER',
|
669
|
+
'NGA',
|
670
|
+
'NIU',
|
671
|
+
'NFK',
|
672
|
+
'MNP',
|
673
|
+
'NOR',
|
674
|
+
'OMN',
|
675
|
+
'PAK',
|
676
|
+
'PLW',
|
677
|
+
'PSE',
|
678
|
+
'PAN',
|
679
|
+
'PNG',
|
680
|
+
'PRY',
|
681
|
+
'PER',
|
682
|
+
'PHL',
|
683
|
+
'PCN',
|
684
|
+
'POL',
|
685
|
+
'PRT',
|
686
|
+
'PRI',
|
687
|
+
'QAT',
|
688
|
+
'REU',
|
689
|
+
'ROU',
|
690
|
+
'RUS',
|
691
|
+
'RWA',
|
692
|
+
'BLM',
|
693
|
+
'SHN',
|
694
|
+
'KNA',
|
695
|
+
'LCA',
|
696
|
+
'MAF',
|
697
|
+
'SPM',
|
698
|
+
'VCT',
|
699
|
+
'WSM',
|
700
|
+
'SMR',
|
701
|
+
'STP',
|
702
|
+
'SAU',
|
703
|
+
'SEN',
|
704
|
+
'SRB',
|
705
|
+
'SYC',
|
706
|
+
'SLE',
|
707
|
+
'SGP',
|
708
|
+
'SXM',
|
709
|
+
'SVK',
|
710
|
+
'SVN',
|
711
|
+
'SLB',
|
712
|
+
'SOM',
|
713
|
+
'ZAF',
|
714
|
+
'SGS',
|
715
|
+
'SSD',
|
716
|
+
'ESP',
|
717
|
+
'LKA',
|
718
|
+
'SDN',
|
719
|
+
'SUR',
|
720
|
+
'SJM',
|
721
|
+
'SWZ',
|
722
|
+
'SWE',
|
723
|
+
'CHE',
|
724
|
+
'SYR',
|
725
|
+
'TWN',
|
726
|
+
'TJK',
|
727
|
+
'TZA',
|
728
|
+
'THA',
|
729
|
+
'TLS',
|
730
|
+
'TGO',
|
731
|
+
'TKL',
|
732
|
+
'TON',
|
733
|
+
'TTO',
|
734
|
+
'TUN',
|
735
|
+
'TUR',
|
736
|
+
'TKM',
|
737
|
+
'TCA',
|
738
|
+
'TUV',
|
739
|
+
'UGA',
|
740
|
+
'UKR',
|
741
|
+
'ARE',
|
742
|
+
'GBR',
|
743
|
+
'USA',
|
744
|
+
'UMI',
|
745
|
+
'URY',
|
746
|
+
'UZB',
|
747
|
+
'VUT',
|
748
|
+
'VEN',
|
749
|
+
'VNM',
|
750
|
+
'VGB',
|
751
|
+
'VIR',
|
752
|
+
'WLF',
|
753
|
+
'ESH',
|
754
|
+
'YEM',
|
755
|
+
'ZMB',
|
756
|
+
'ZWE',
|
757
|
+
]
|
758
|
+
|
759
|
+
COUNTRY_NUMS = [
|
760
|
+
4,
|
761
|
+
248,
|
762
|
+
8,
|
763
|
+
12,
|
764
|
+
16,
|
765
|
+
20,
|
766
|
+
24,
|
767
|
+
660,
|
768
|
+
10,
|
769
|
+
28,
|
770
|
+
32,
|
771
|
+
51,
|
772
|
+
533,
|
773
|
+
36,
|
774
|
+
40,
|
775
|
+
31,
|
776
|
+
44,
|
777
|
+
48,
|
778
|
+
50,
|
779
|
+
52,
|
780
|
+
112,
|
781
|
+
56,
|
782
|
+
84,
|
783
|
+
204,
|
784
|
+
60,
|
785
|
+
64,
|
786
|
+
68,
|
787
|
+
535,
|
788
|
+
70,
|
789
|
+
72,
|
790
|
+
74,
|
791
|
+
76,
|
792
|
+
86,
|
793
|
+
96,
|
794
|
+
100,
|
795
|
+
854,
|
796
|
+
108,
|
797
|
+
116,
|
798
|
+
120,
|
799
|
+
124,
|
800
|
+
132,
|
801
|
+
136,
|
802
|
+
140,
|
803
|
+
148,
|
804
|
+
152,
|
805
|
+
156,
|
806
|
+
162,
|
807
|
+
166,
|
808
|
+
170,
|
809
|
+
174,
|
810
|
+
178,
|
811
|
+
180,
|
812
|
+
184,
|
813
|
+
188,
|
814
|
+
384,
|
815
|
+
191,
|
816
|
+
192,
|
817
|
+
531,
|
818
|
+
196,
|
819
|
+
203,
|
820
|
+
208,
|
821
|
+
262,
|
822
|
+
212,
|
823
|
+
214,
|
824
|
+
218,
|
825
|
+
818,
|
826
|
+
222,
|
827
|
+
226,
|
828
|
+
232,
|
829
|
+
233,
|
830
|
+
231,
|
831
|
+
238,
|
832
|
+
234,
|
833
|
+
242,
|
834
|
+
246,
|
835
|
+
250,
|
836
|
+
254,
|
837
|
+
258,
|
838
|
+
260,
|
839
|
+
266,
|
840
|
+
270,
|
841
|
+
268,
|
842
|
+
276,
|
843
|
+
288,
|
844
|
+
292,
|
845
|
+
300,
|
846
|
+
304,
|
847
|
+
308,
|
848
|
+
312,
|
849
|
+
316,
|
850
|
+
320,
|
851
|
+
831,
|
852
|
+
324,
|
853
|
+
624,
|
854
|
+
328,
|
855
|
+
332,
|
856
|
+
334,
|
857
|
+
336,
|
858
|
+
340,
|
859
|
+
344,
|
860
|
+
348,
|
861
|
+
352,
|
862
|
+
356,
|
863
|
+
360,
|
864
|
+
364,
|
865
|
+
368,
|
866
|
+
372,
|
867
|
+
833,
|
868
|
+
376,
|
869
|
+
380,
|
870
|
+
388,
|
871
|
+
392,
|
872
|
+
832,
|
873
|
+
400,
|
874
|
+
398,
|
875
|
+
404,
|
876
|
+
296,
|
877
|
+
408,
|
878
|
+
410,
|
879
|
+
414,
|
880
|
+
417,
|
881
|
+
418,
|
882
|
+
428,
|
883
|
+
422,
|
884
|
+
426,
|
885
|
+
430,
|
886
|
+
434,
|
887
|
+
438,
|
888
|
+
440,
|
889
|
+
442,
|
890
|
+
446,
|
891
|
+
807,
|
892
|
+
450,
|
893
|
+
454,
|
894
|
+
458,
|
895
|
+
462,
|
896
|
+
466,
|
897
|
+
470,
|
898
|
+
584,
|
899
|
+
474,
|
900
|
+
478,
|
901
|
+
480,
|
902
|
+
175,
|
903
|
+
484,
|
904
|
+
583,
|
905
|
+
498,
|
906
|
+
492,
|
907
|
+
496,
|
908
|
+
499,
|
909
|
+
500,
|
910
|
+
504,
|
911
|
+
508,
|
912
|
+
104,
|
913
|
+
516,
|
914
|
+
520,
|
915
|
+
524,
|
916
|
+
528,
|
917
|
+
540,
|
918
|
+
554,
|
919
|
+
558,
|
920
|
+
562,
|
921
|
+
566,
|
922
|
+
570,
|
923
|
+
574,
|
924
|
+
580,
|
925
|
+
578,
|
926
|
+
512,
|
927
|
+
586,
|
928
|
+
585,
|
929
|
+
275,
|
930
|
+
591,
|
931
|
+
598,
|
932
|
+
600,
|
933
|
+
604,
|
934
|
+
608,
|
935
|
+
612,
|
936
|
+
616,
|
937
|
+
620,
|
938
|
+
630,
|
939
|
+
634,
|
940
|
+
638,
|
941
|
+
642,
|
942
|
+
643,
|
943
|
+
646,
|
944
|
+
652,
|
945
|
+
654,
|
946
|
+
659,
|
947
|
+
662,
|
948
|
+
663,
|
949
|
+
666,
|
950
|
+
670,
|
951
|
+
882,
|
952
|
+
674,
|
953
|
+
678,
|
954
|
+
682,
|
955
|
+
686,
|
956
|
+
688,
|
957
|
+
690,
|
958
|
+
694,
|
959
|
+
702,
|
960
|
+
534,
|
961
|
+
703,
|
962
|
+
705,
|
963
|
+
90,
|
964
|
+
706,
|
965
|
+
710,
|
966
|
+
239,
|
967
|
+
728,
|
968
|
+
724,
|
969
|
+
144,
|
970
|
+
729,
|
971
|
+
740,
|
972
|
+
744,
|
973
|
+
748,
|
974
|
+
752,
|
975
|
+
756,
|
976
|
+
760,
|
977
|
+
158,
|
978
|
+
762,
|
979
|
+
834,
|
980
|
+
764,
|
981
|
+
626,
|
982
|
+
768,
|
983
|
+
772,
|
984
|
+
776,
|
985
|
+
780,
|
986
|
+
788,
|
987
|
+
792,
|
988
|
+
795,
|
989
|
+
796,
|
990
|
+
798,
|
991
|
+
800,
|
992
|
+
804,
|
993
|
+
784,
|
994
|
+
826,
|
995
|
+
840,
|
996
|
+
581,
|
997
|
+
858,
|
998
|
+
860,
|
999
|
+
548,
|
1000
|
+
862,
|
1001
|
+
704,
|
1002
|
+
92,
|
1003
|
+
850,
|
1004
|
+
876,
|
1005
|
+
732,
|
1006
|
+
887,
|
1007
|
+
894,
|
1008
|
+
716,
|
1009
|
+
]
|
1010
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "rails_country_select/version"
|
3
|
+
|
4
|
+
require File.expand_path('../country_definitions', __FILE__)
|
5
|
+
if defined?(Rails) && defined?(ActionView)
|
6
|
+
module ActionView
|
7
|
+
module Helpers
|
8
|
+
module FormOptionsHelper
|
9
|
+
def country_select(object, method, options = {}, html_options = {})
|
10
|
+
options[:keys] = :names unless options.has_key?(:keys)
|
11
|
+
options[:values] = :nums unless options.has_key?(:values)
|
12
|
+
|
13
|
+
potential = {
|
14
|
+
:names => COUNTRY_NAMES,
|
15
|
+
:nums => COUNTRY_NUMS,
|
16
|
+
:alpha2s => COUNTRY_ALPHA2S,
|
17
|
+
:alpha3s => COUNTRY_ALPHA3S
|
18
|
+
}
|
19
|
+
|
20
|
+
select_options = potential[options[:keys]].zip(potential[options[:values]])
|
21
|
+
InstanceTag.new(object, method, self, options.delete(:object)).to_select_tag(select_options, options, html_options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class FormBuilder
|
26
|
+
def country_select(method, options = {}, html_options = {})
|
27
|
+
@template.country_select(@object_name, method, options.merge({:object => @object}), html_options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_country_select/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_country_select"
|
8
|
+
spec.version = RailsCountrySelect::VERSION
|
9
|
+
spec.authors = ["Ruben Espinosa"]
|
10
|
+
spec.email = ["rderoldan1@gmail.com"]
|
11
|
+
spec.description = %q{Select tag for countries in rails form, based in LukeCarrier rails 2 plugin }
|
12
|
+
spec.summary = %q{Select tag for countries in rails form}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_country_select
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ruben Espinosa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ! 'Select tag for countries in rails form, based in LukeCarrier rails
|
42
|
+
2 plugin '
|
43
|
+
email:
|
44
|
+
- rderoldan1@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/country_definitions.rb
|
55
|
+
- lib/rails_country_select.rb
|
56
|
+
- lib/rails_country_select/version.rb
|
57
|
+
- rails_country_select.gemspec
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.3
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Select tag for countries in rails form
|
82
|
+
test_files: []
|