country_select_yaml 1.1.3
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.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/MIT-LICENSE +20 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/country_select.gemspec +22 -0
- data/lib/country_select.rb +108 -0
- data/lib/country_select/countries.yml +474 -0
- data/lib/country_select/version.rb +3 -0
- data/spec/country_select_spec.rb +50 -0
- data/spec/spec_helper.rb +17 -0
- metadata +62 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Michael Koziarski
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Country_Select
|
|
2
|
+
|
|
3
|
+
[](https://codeclimate.com/github/waldyr/country_select.png)
|
|
4
|
+
|
|
5
|
+
Provides a simple helper to get an HTML select list of countries. The list of countries comes
|
|
6
|
+
from the ISO 3166 standard. While it is a relatively neutral source of country names, it may
|
|
7
|
+
still offend some users.
|
|
8
|
+
|
|
9
|
+
Users are strongly advised to evaluate the suitability of this list given their user base.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install as a gem using
|
|
14
|
+
|
|
15
|
+
gem install country_select_yaml
|
|
16
|
+
|
|
17
|
+
Or put the following in your Gemfile
|
|
18
|
+
|
|
19
|
+
gem 'country_select_yaml'
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
Simple use supplying model and attribute as parameters:
|
|
24
|
+
|
|
25
|
+
country_select("user", "country_name")
|
|
26
|
+
|
|
27
|
+
Supplying priority countries to be placed at the top of the list:
|
|
28
|
+
|
|
29
|
+
country_select("user", "country_name", [ "United Kingdom", "France", "Germany" ])
|
|
30
|
+
|
|
31
|
+
Specifying which country to be selected:
|
|
32
|
+
United Kingdom will be selected.
|
|
33
|
+
|
|
34
|
+
country_select("user", "country_name", [ "+United Kingdom+", "France", "Germany" ])
|
|
35
|
+
|
|
36
|
+
Specifying which language to be selected (US by default):
|
|
37
|
+
|
|
38
|
+
country_select("user", "country_name", nil, :lang => "br")
|
|
39
|
+
|
|
40
|
+
Copyright (c) 2013 Waldyr Araújo, released under the MIT license
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "country_select/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "country_select_yaml"
|
|
7
|
+
s.version = CountrySelect::VERSION
|
|
8
|
+
s.authors = ["Stefan Penner", "Waldyr Araújo"]
|
|
9
|
+
s.email = ["stefan.penner@gmail.com", "waldyr.ar@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/waldyr/country_select"
|
|
11
|
+
s.summary = %q{Country Select Plugin}
|
|
12
|
+
s.description = %q{Provides a simple helper to get an HTML select list of countries by a YAML file. The list of countries comes from the ISO 3166 standard. While it is a relatively neutral source of country names, it will still offend some users.}
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
# specify any dependencies here; for example:
|
|
20
|
+
# s.add_development_dependency "rspec"
|
|
21
|
+
# s.add_runtime_dependency "rest-client"
|
|
22
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# CountrySelect
|
|
2
|
+
#
|
|
3
|
+
# Adds #country_select method to
|
|
4
|
+
# ActionView::FormBuilder
|
|
5
|
+
#
|
|
6
|
+
require 'country_select/version'
|
|
7
|
+
require 'yaml'
|
|
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
|
+
# Supply a country name as +selected+ to
|
|
37
|
+
# have it marked as the selected option tag.
|
|
38
|
+
#
|
|
39
|
+
# You can also supply an array of countries as
|
|
40
|
+
# +priority_countries+ so that they will be
|
|
41
|
+
# listed above the rest of the (long) list.
|
|
42
|
+
#
|
|
43
|
+
# NOTE: Only the option tags are returned, you
|
|
44
|
+
# have to wrap this call in a regular HTML
|
|
45
|
+
# select tag.
|
|
46
|
+
#
|
|
47
|
+
def country_options_for_select(selected = nil, priority_countries = nil, lang = nil)
|
|
48
|
+
country_options = "".html_safe
|
|
49
|
+
|
|
50
|
+
if priority_countries
|
|
51
|
+
country_options += options_for_select(priority_countries, selected)
|
|
52
|
+
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n".html_safe
|
|
53
|
+
#
|
|
54
|
+
# prevents selected from being included
|
|
55
|
+
# twice in the HTML which causes
|
|
56
|
+
# some browsers to select the second
|
|
57
|
+
# selected option (not priority)
|
|
58
|
+
# which makes it harder to select an
|
|
59
|
+
# alternative priority country
|
|
60
|
+
#
|
|
61
|
+
selected = nil if priority_countries.include?(selected)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
return country_options + options_for_select(COUNTRIES[lang || "us"], selected)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# All the countries included in the country_options output.
|
|
68
|
+
path_to_yaml = File.dirname(__FILE__) + "/country_select/countries.yml"
|
|
69
|
+
COUNTRIES = YAML.load_file(path_to_yaml) unless const_defined?("COUNTRIES")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
module ToCountrySelectTag
|
|
73
|
+
def to_country_select_tag(priority_countries, options, html_options)
|
|
74
|
+
html_options = html_options.stringify_keys
|
|
75
|
+
add_default_name_and_id(html_options)
|
|
76
|
+
value = value(object)
|
|
77
|
+
content_tag("select",
|
|
78
|
+
add_options(
|
|
79
|
+
country_options_for_select(value, priority_countries, options[:lang]),
|
|
80
|
+
options, value
|
|
81
|
+
), html_options
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if defined?(ActionView::Helpers::InstanceTag) &&
|
|
87
|
+
ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
|
88
|
+
class InstanceTag
|
|
89
|
+
include ToCountrySelectTag
|
|
90
|
+
end
|
|
91
|
+
else
|
|
92
|
+
class CountrySelect < Tags::Base
|
|
93
|
+
include ToCountrySelectTag
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class FormBuilder
|
|
98
|
+
def country_select(method, priority_countries = nil,
|
|
99
|
+
options = {},
|
|
100
|
+
html_options = {})
|
|
101
|
+
|
|
102
|
+
@template.country_select(@object_name, method, priority_countries,
|
|
103
|
+
options.merge(:object => @object),
|
|
104
|
+
html_options)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
us:
|
|
3
|
+
["Afghanistan",
|
|
4
|
+
"Aland Islands",
|
|
5
|
+
"Albania",
|
|
6
|
+
"Algeria",
|
|
7
|
+
"American Samoa",
|
|
8
|
+
"Andorra",
|
|
9
|
+
"Angola",
|
|
10
|
+
"Anguilla",
|
|
11
|
+
"Antarctica",
|
|
12
|
+
"Antigua And Barbuda",
|
|
13
|
+
"Argentina",
|
|
14
|
+
"Armenia",
|
|
15
|
+
"Aruba",
|
|
16
|
+
"Australia",
|
|
17
|
+
"Austria",
|
|
18
|
+
"Azerbaijan",
|
|
19
|
+
"Bahamas",
|
|
20
|
+
"Bahrain",
|
|
21
|
+
"Bangladesh",
|
|
22
|
+
"Barbados",
|
|
23
|
+
"Belarus",
|
|
24
|
+
"Belgium",
|
|
25
|
+
"Belize",
|
|
26
|
+
"Benin",
|
|
27
|
+
"Bermuda",
|
|
28
|
+
"Bhutan",
|
|
29
|
+
"Bolivia",
|
|
30
|
+
"Bosnia and Herzegovina",
|
|
31
|
+
"Botswana",
|
|
32
|
+
"Bouvet Island",
|
|
33
|
+
"Brazil",
|
|
34
|
+
"British Indian Ocean Territory",
|
|
35
|
+
"Brunei Darussalam",
|
|
36
|
+
"Bulgaria",
|
|
37
|
+
"Burkina Faso",
|
|
38
|
+
"Burundi",
|
|
39
|
+
"Cambodia",
|
|
40
|
+
"Cameroon",
|
|
41
|
+
"Canada",
|
|
42
|
+
"Cape Verde",
|
|
43
|
+
"Cayman Islands",
|
|
44
|
+
"Central African Republic",
|
|
45
|
+
"Chad",
|
|
46
|
+
"Chile",
|
|
47
|
+
"China",
|
|
48
|
+
"Christmas Island",
|
|
49
|
+
"Cocos (Keeling) Islands",
|
|
50
|
+
"Colombia",
|
|
51
|
+
"Comoros",
|
|
52
|
+
"Congo",
|
|
53
|
+
"Congo, the Democratic Republic of the",
|
|
54
|
+
"Cook Islands",
|
|
55
|
+
"Costa Rica",
|
|
56
|
+
"Cote d'Ivoire",
|
|
57
|
+
"Croatia",
|
|
58
|
+
"Cuba",
|
|
59
|
+
"Curacao",
|
|
60
|
+
"Cyprus",
|
|
61
|
+
"Czech Republic",
|
|
62
|
+
"Denmark",
|
|
63
|
+
"Djibouti",
|
|
64
|
+
"Dominica",
|
|
65
|
+
"Dominican Republic",
|
|
66
|
+
"Ecuador",
|
|
67
|
+
"Egypt",
|
|
68
|
+
"El Salvador",
|
|
69
|
+
"Equatorial Guinea",
|
|
70
|
+
"Eritrea",
|
|
71
|
+
"Estonia",
|
|
72
|
+
"Ethiopia",
|
|
73
|
+
"Falkland Islands (Malvinas)",
|
|
74
|
+
"Faroe Islands",
|
|
75
|
+
"Fiji",
|
|
76
|
+
"Finland",
|
|
77
|
+
"France",
|
|
78
|
+
"French Guiana",
|
|
79
|
+
"French Polynesia",
|
|
80
|
+
"French Southern Territories",
|
|
81
|
+
"Gabon",
|
|
82
|
+
"Gambia",
|
|
83
|
+
"Georgia",
|
|
84
|
+
"Germany",
|
|
85
|
+
"Ghana",
|
|
86
|
+
"Gibraltar",
|
|
87
|
+
"Greece",
|
|
88
|
+
"Greenland",
|
|
89
|
+
"Grenada",
|
|
90
|
+
"Guadeloupe",
|
|
91
|
+
"Guam",
|
|
92
|
+
"Guatemala",
|
|
93
|
+
"Guernsey",
|
|
94
|
+
"Guinea",
|
|
95
|
+
"Guinea-Bissau",
|
|
96
|
+
"Guyana",
|
|
97
|
+
"Haiti",
|
|
98
|
+
"Heard and McDonald Islands",
|
|
99
|
+
"Holy See (Vatican City State)",
|
|
100
|
+
"Honduras",
|
|
101
|
+
"Hong Kong",
|
|
102
|
+
"Hungary",
|
|
103
|
+
"Iceland",
|
|
104
|
+
"India",
|
|
105
|
+
"Indonesia",
|
|
106
|
+
"Iran, Islamic Republic of",
|
|
107
|
+
"Iraq",
|
|
108
|
+
"Ireland",
|
|
109
|
+
"Isle of Man",
|
|
110
|
+
"Israel",
|
|
111
|
+
"Italy",
|
|
112
|
+
"Jamaica",
|
|
113
|
+
"Japan",
|
|
114
|
+
"Jersey",
|
|
115
|
+
"Jordan",
|
|
116
|
+
"Kazakhstan",
|
|
117
|
+
"Kenya",
|
|
118
|
+
"Kiribati",
|
|
119
|
+
"Korea. Democratic People's Republic of",
|
|
120
|
+
"Korea, Republic of",
|
|
121
|
+
"Kuwait",
|
|
122
|
+
"Kyrgyzstan",
|
|
123
|
+
"Lao People's Democratic Republic",
|
|
124
|
+
"Latvia",
|
|
125
|
+
"Lebanon",
|
|
126
|
+
"Lesotho",
|
|
127
|
+
"Liberia",
|
|
128
|
+
"Libyan Arab Jamahiriya",
|
|
129
|
+
"Liechtenstein",
|
|
130
|
+
"Lithuania",
|
|
131
|
+
"Luxembourg",
|
|
132
|
+
"Macao",
|
|
133
|
+
"Macedonia, The Former Yugoslav Republic Of",
|
|
134
|
+
"Madagascar",
|
|
135
|
+
"Malawi",
|
|
136
|
+
"Malaysia",
|
|
137
|
+
"Maldives",
|
|
138
|
+
"Mali",
|
|
139
|
+
"Malta",
|
|
140
|
+
"Marshall Islands",
|
|
141
|
+
"Martinique",
|
|
142
|
+
"Mauritania",
|
|
143
|
+
"Mauritius",
|
|
144
|
+
"Mayotte",
|
|
145
|
+
"Mexico",
|
|
146
|
+
"Micronesia, Federated States of",
|
|
147
|
+
"Moldova, Republic of",
|
|
148
|
+
"Monaco",
|
|
149
|
+
"Mongolia",
|
|
150
|
+
"Montenegro",
|
|
151
|
+
"Montserrat",
|
|
152
|
+
"Morocco",
|
|
153
|
+
"Mozambique",
|
|
154
|
+
"Myanmar",
|
|
155
|
+
"Namibia",
|
|
156
|
+
"Nauru",
|
|
157
|
+
"Nepal",
|
|
158
|
+
"Netherlands",
|
|
159
|
+
"New Caledonia",
|
|
160
|
+
"New Zealand",
|
|
161
|
+
"Nicaragua",
|
|
162
|
+
"Niger",
|
|
163
|
+
"Nigeria",
|
|
164
|
+
"Niue",
|
|
165
|
+
"Norfolk Island",
|
|
166
|
+
"Northern Mariana Islands",
|
|
167
|
+
"Norway",
|
|
168
|
+
"Oman",
|
|
169
|
+
"Pakistan",
|
|
170
|
+
"Palau",
|
|
171
|
+
"Palestinian Territory, Occupied",
|
|
172
|
+
"Panama",
|
|
173
|
+
"Papua New Guinea",
|
|
174
|
+
"Paraguay",
|
|
175
|
+
"Peru",
|
|
176
|
+
"Philippines",
|
|
177
|
+
"Pitcairn",
|
|
178
|
+
"Poland",
|
|
179
|
+
"Portugal",
|
|
180
|
+
"Puerto Rico",
|
|
181
|
+
"Qatar",
|
|
182
|
+
"Reunion",
|
|
183
|
+
"Romania",
|
|
184
|
+
"Russian Federation",
|
|
185
|
+
"Rwanda",
|
|
186
|
+
"Saint Barthelemy",
|
|
187
|
+
"Saint Helena",
|
|
188
|
+
"Saint Kitts and Nevis",
|
|
189
|
+
"Saint Lucia",
|
|
190
|
+
"Saint Pierre and Miquelon",
|
|
191
|
+
"Saint Vincent and the Grenadines",
|
|
192
|
+
"Samoa",
|
|
193
|
+
"San Marino",
|
|
194
|
+
"Sao Tome and Principe",
|
|
195
|
+
"Saudi Arabia",
|
|
196
|
+
"Senegal",
|
|
197
|
+
"Serbia",
|
|
198
|
+
"Seychelles",
|
|
199
|
+
"Sierra Leone",
|
|
200
|
+
"Singapore",
|
|
201
|
+
"Sint Maarten",
|
|
202
|
+
"Slovakia",
|
|
203
|
+
"Slovenia",
|
|
204
|
+
"Solomon Islands",
|
|
205
|
+
"Somalia",
|
|
206
|
+
"South Africa",
|
|
207
|
+
"South Georgia and the South Sandwich Islands",
|
|
208
|
+
"Spain",
|
|
209
|
+
"Sri Lanka",
|
|
210
|
+
"Sudan",
|
|
211
|
+
"Suriname",
|
|
212
|
+
"Svalbard and Jan Mayen",
|
|
213
|
+
"Swaziland",
|
|
214
|
+
"Sweden",
|
|
215
|
+
"Switzerland",
|
|
216
|
+
"Syrian Arab Republic",
|
|
217
|
+
"Taiwan",
|
|
218
|
+
"Tajikistan",
|
|
219
|
+
"Tanzania, United Republic of",
|
|
220
|
+
"Thailand",
|
|
221
|
+
"Timor-Leste",
|
|
222
|
+
"Togo",
|
|
223
|
+
"Tokelau",
|
|
224
|
+
"Tonga",
|
|
225
|
+
"Trinidad and Tobago",
|
|
226
|
+
"Tunisia",
|
|
227
|
+
"Turkey",
|
|
228
|
+
"Turkmenistan",
|
|
229
|
+
"Turks and Caicos Islands",
|
|
230
|
+
"Tuvalu",
|
|
231
|
+
"Uganda",
|
|
232
|
+
"Ukraine",
|
|
233
|
+
"United Arab Emirates",
|
|
234
|
+
"United Kingdom",
|
|
235
|
+
"United States",
|
|
236
|
+
"United States Minor Outlying Islands",
|
|
237
|
+
"Uruguay",
|
|
238
|
+
"Uzbekistan",
|
|
239
|
+
"Vanuatu",
|
|
240
|
+
"Venezuela",
|
|
241
|
+
"Viet Nam",
|
|
242
|
+
"Virgin Islands British",
|
|
243
|
+
"Virgin Islands U.S.",
|
|
244
|
+
"Wallis and Futuna",
|
|
245
|
+
"Western Sahara",
|
|
246
|
+
"Yemen",
|
|
247
|
+
"Zambia",
|
|
248
|
+
"Zimbabwe"]
|
|
249
|
+
|
|
250
|
+
br:
|
|
251
|
+
["Afeganistão",
|
|
252
|
+
"África do Sul",
|
|
253
|
+
"Albânia",
|
|
254
|
+
"Alemanha",
|
|
255
|
+
"Andorra",
|
|
256
|
+
"Angola",
|
|
257
|
+
"Antígua e Barbuda",
|
|
258
|
+
"Arábia Saudita",
|
|
259
|
+
"Argélia",
|
|
260
|
+
"Argentina",
|
|
261
|
+
"Arménia",
|
|
262
|
+
"Aruba",
|
|
263
|
+
"Austrália",
|
|
264
|
+
"Áustria",
|
|
265
|
+
"Azerbaijão",
|
|
266
|
+
"Baamas",
|
|
267
|
+
"Bangladeche",
|
|
268
|
+
"Barbados",
|
|
269
|
+
"Barém",
|
|
270
|
+
"Bélgica",
|
|
271
|
+
"Belize",
|
|
272
|
+
"Benim",
|
|
273
|
+
"Bermudas",
|
|
274
|
+
"Bielorrússia",
|
|
275
|
+
"Bolívia",
|
|
276
|
+
"Bósnia e Herzegovina",
|
|
277
|
+
"Botsuana",
|
|
278
|
+
"Brasil",
|
|
279
|
+
"Brunei",
|
|
280
|
+
"Bulgária",
|
|
281
|
+
"Burquina Faso",
|
|
282
|
+
"Burúndi",
|
|
283
|
+
"Butão",
|
|
284
|
+
"Cabo Verde",
|
|
285
|
+
"Camarões",
|
|
286
|
+
"Camboja",
|
|
287
|
+
"Canadá",
|
|
288
|
+
"Catar",
|
|
289
|
+
"Cazaquistão",
|
|
290
|
+
"Chade",
|
|
291
|
+
"Chile",
|
|
292
|
+
"China",
|
|
293
|
+
"Chipre",
|
|
294
|
+
"Colômbia",
|
|
295
|
+
"Comores",
|
|
296
|
+
"Congo-Brazzaville",
|
|
297
|
+
"Congo-Kinshasa",
|
|
298
|
+
"Coreia do Norte",
|
|
299
|
+
"Coreia do Sul",
|
|
300
|
+
"Costa do Marfim",
|
|
301
|
+
"Costa Rica",
|
|
302
|
+
"Croácia",
|
|
303
|
+
"Cuba",
|
|
304
|
+
"Dinamarca",
|
|
305
|
+
"Domínica",
|
|
306
|
+
"Egipto",
|
|
307
|
+
"Emiratos Árabes Unidos",
|
|
308
|
+
"Equador",
|
|
309
|
+
"Eritreia",
|
|
310
|
+
"Eslováquia",
|
|
311
|
+
"Eslovénia",
|
|
312
|
+
"Espanha",
|
|
313
|
+
"Estados Unidos",
|
|
314
|
+
"Estónia",
|
|
315
|
+
"Etiópia",
|
|
316
|
+
"Faeroe Islands",
|
|
317
|
+
"Falkland Islands",
|
|
318
|
+
"Fiji",
|
|
319
|
+
"Filipinas",
|
|
320
|
+
"Finlândia",
|
|
321
|
+
"França",
|
|
322
|
+
"French Guiana",
|
|
323
|
+
"Gabão",
|
|
324
|
+
"Gâmbia",
|
|
325
|
+
"Gana",
|
|
326
|
+
"Geórgia",
|
|
327
|
+
"Gibraltar",
|
|
328
|
+
"Granada",
|
|
329
|
+
"Grécia",
|
|
330
|
+
"Greenland",
|
|
331
|
+
"Guadalupe",
|
|
332
|
+
"Guatemala",
|
|
333
|
+
"Guernsey",
|
|
334
|
+
"Guiana",
|
|
335
|
+
"Guiné",
|
|
336
|
+
"Guiné Equatorial",
|
|
337
|
+
"Guiné-Bissau",
|
|
338
|
+
"Haiti",
|
|
339
|
+
"Honduras",
|
|
340
|
+
"Hong Kong",
|
|
341
|
+
"Hungria",
|
|
342
|
+
"Iémen",
|
|
343
|
+
"Ilha de Man",
|
|
344
|
+
"Ilhas Cayman",
|
|
345
|
+
"Ilhas Marshall",
|
|
346
|
+
"Ilhas Salomão",
|
|
347
|
+
"Ilhas Virgens Britânicas",
|
|
348
|
+
"Índia",
|
|
349
|
+
"Indonésia",
|
|
350
|
+
"Irão",
|
|
351
|
+
"Iraque",
|
|
352
|
+
"Irlanda",
|
|
353
|
+
"Islândia",
|
|
354
|
+
"Israel",
|
|
355
|
+
"Itália",
|
|
356
|
+
"Jamaica",
|
|
357
|
+
"Japão",
|
|
358
|
+
"Jersey",
|
|
359
|
+
"Jibuti",
|
|
360
|
+
"Jordânia",
|
|
361
|
+
"Kosovo",
|
|
362
|
+
"Kuwait",
|
|
363
|
+
"Laos",
|
|
364
|
+
"Lesoto",
|
|
365
|
+
"Letónia",
|
|
366
|
+
"Líbano",
|
|
367
|
+
"Libéria",
|
|
368
|
+
"Líbia",
|
|
369
|
+
"Listenstaine",
|
|
370
|
+
"Lituânia",
|
|
371
|
+
"Luxemburgo",
|
|
372
|
+
"Macau",
|
|
373
|
+
"Macedónia",
|
|
374
|
+
"Madagáscar",
|
|
375
|
+
"Malásia",
|
|
376
|
+
"Malávi",
|
|
377
|
+
"Maldivas",
|
|
378
|
+
"Mali",
|
|
379
|
+
"Malta",
|
|
380
|
+
"Marrocos",
|
|
381
|
+
"Martinica",
|
|
382
|
+
"Maurícia",
|
|
383
|
+
"Mauritânia",
|
|
384
|
+
"Mayotte",
|
|
385
|
+
"México",
|
|
386
|
+
"Micronésia",
|
|
387
|
+
"Moçambique",
|
|
388
|
+
"Moldávia",
|
|
389
|
+
"Mónaco",
|
|
390
|
+
"Mongólia",
|
|
391
|
+
"Montenegro",
|
|
392
|
+
"Myanmar",
|
|
393
|
+
"Namíbia",
|
|
394
|
+
"Nauru",
|
|
395
|
+
"Nepal",
|
|
396
|
+
"New Caledonia",
|
|
397
|
+
"Nicarágua",
|
|
398
|
+
"Níger",
|
|
399
|
+
"Nigéria",
|
|
400
|
+
"Noruega",
|
|
401
|
+
"Nova Zelândia",
|
|
402
|
+
"Omã",
|
|
403
|
+
"Países Baixos",
|
|
404
|
+
"Palau",
|
|
405
|
+
"Panamá",
|
|
406
|
+
"Papua-Nova Guiné",
|
|
407
|
+
"Paquistão",
|
|
408
|
+
"Paraguai",
|
|
409
|
+
"Peru",
|
|
410
|
+
"Polinésia Francesa",
|
|
411
|
+
"Polónia",
|
|
412
|
+
"Porto Rico",
|
|
413
|
+
"Portugal",
|
|
414
|
+
"Quénia",
|
|
415
|
+
"Quirguizistão",
|
|
416
|
+
"Quiribáti",
|
|
417
|
+
"Reino Unido",
|
|
418
|
+
"República Centro-Africana",
|
|
419
|
+
"República Checa",
|
|
420
|
+
"República Dominicana",
|
|
421
|
+
"Reunion",
|
|
422
|
+
"Roménia",
|
|
423
|
+
"Ruanda",
|
|
424
|
+
"Rússia",
|
|
425
|
+
"Saint-Barthélemy",
|
|
426
|
+
"Saint-Pierre e Miquelon",
|
|
427
|
+
"Salvador",
|
|
428
|
+
"Samoa",
|
|
429
|
+
"Santa Lúcia",
|
|
430
|
+
"São Cristóvão e Neves",
|
|
431
|
+
"São Marinho",
|
|
432
|
+
"São Martinho",
|
|
433
|
+
"São Tomé e Príncipe",
|
|
434
|
+
"São Vicente e Granadinas",
|
|
435
|
+
"Seicheles",
|
|
436
|
+
"Senegal",
|
|
437
|
+
"Serra Leoa",
|
|
438
|
+
"Sérvia",
|
|
439
|
+
"Singapura",
|
|
440
|
+
"Síria",
|
|
441
|
+
"Somália",
|
|
442
|
+
"South Sudan",
|
|
443
|
+
"Sri Lanca",
|
|
444
|
+
"Suazilândia",
|
|
445
|
+
"Sudão",
|
|
446
|
+
"Suécia",
|
|
447
|
+
"Suíça",
|
|
448
|
+
"Suriname",
|
|
449
|
+
"Svalbard",
|
|
450
|
+
"Tailândia",
|
|
451
|
+
"Taiwan",
|
|
452
|
+
"Tajiquistão",
|
|
453
|
+
"Tanzânia",
|
|
454
|
+
"Timor Leste",
|
|
455
|
+
"Togo",
|
|
456
|
+
"Tonga",
|
|
457
|
+
"Trindade e Tobago",
|
|
458
|
+
"Tunísia",
|
|
459
|
+
"Turks e Caicos",
|
|
460
|
+
"Turquemenistão",
|
|
461
|
+
"Turquia",
|
|
462
|
+
"Tuvalu",
|
|
463
|
+
"Ucrânia",
|
|
464
|
+
"Uganda",
|
|
465
|
+
"Uruguai",
|
|
466
|
+
"Usbequistão",
|
|
467
|
+
"Vanuatu",
|
|
468
|
+
"Vaticano",
|
|
469
|
+
"Venezuela",
|
|
470
|
+
"Vietname",
|
|
471
|
+
"Wallis e Futuna",
|
|
472
|
+
"Western Sahara",
|
|
473
|
+
"Zâmbia",
|
|
474
|
+
"Zimbabué"]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'country_select'
|
|
3
|
+
|
|
4
|
+
module ActionView
|
|
5
|
+
module Helpers
|
|
6
|
+
describe CountrySelect do
|
|
7
|
+
let!(:walrus) { Walrus.new }
|
|
8
|
+
let!(:template) { ActionView::Base.new }
|
|
9
|
+
|
|
10
|
+
let(:select_tag) do
|
|
11
|
+
"<select id=\"walrus_country_name\" name=\"walrus[country_name]\">"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:builder) { FormBuilder.new(:walrus, walrus, template, {}, Proc.new { }) }
|
|
15
|
+
|
|
16
|
+
describe "#country_select" do
|
|
17
|
+
let(:tag) { builder.country_select(:country_name) }
|
|
18
|
+
|
|
19
|
+
it "creates a select tag" do
|
|
20
|
+
tag.should include(select_tag)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "creates option tags of the countries" do
|
|
24
|
+
COUNTRIES.each do |c|
|
|
25
|
+
c.gsub!(/'/,''')
|
|
26
|
+
tag.should include("<option value=\"#{c}\">#{c}</option>")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "selects the value of country_name" do
|
|
31
|
+
walrus.country_name = 'United States'
|
|
32
|
+
t = builder.country_select(:country_name)
|
|
33
|
+
t.should include("<option value=\"United States\" selected=\"selected\">United States</option>")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "#priority_countries" do
|
|
38
|
+
let(:tag) { builder.country_select(:country_name, ['United States']) }
|
|
39
|
+
|
|
40
|
+
it "puts the countries at the top" do
|
|
41
|
+
tag.should include("#{select_tag}<option value=\"United States")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "inserts a divider" do
|
|
45
|
+
tag.should include(">United States</option><option value=\"\" disabled=\"disabled\">-------------</option>")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
|
4
|
+
# loaded once.
|
|
5
|
+
#
|
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
7
|
+
RSpec.configure do |config|
|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
9
|
+
config.run_all_when_everything_filtered = true
|
|
10
|
+
config.filter_run :focus
|
|
11
|
+
|
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
14
|
+
# the seed, which is printed after each run.
|
|
15
|
+
# --seed 1234
|
|
16
|
+
config.order = 'random'
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: country_select_yaml
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.1.3
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Stefan Penner
|
|
9
|
+
- Waldyr Araújo
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
|
14
|
+
dependencies: []
|
|
15
|
+
description: Provides a simple helper to get an HTML select list of countries by a
|
|
16
|
+
YAML file. The list of countries comes from the ISO 3166 standard. While it is
|
|
17
|
+
a relatively neutral source of country names, it will still offend some users.
|
|
18
|
+
email:
|
|
19
|
+
- stefan.penner@gmail.com
|
|
20
|
+
- waldyr.ar@gmail.com
|
|
21
|
+
executables: []
|
|
22
|
+
extensions: []
|
|
23
|
+
extra_rdoc_files: []
|
|
24
|
+
files:
|
|
25
|
+
- .gitignore
|
|
26
|
+
- .rspec
|
|
27
|
+
- Gemfile
|
|
28
|
+
- MIT-LICENSE
|
|
29
|
+
- README.md
|
|
30
|
+
- Rakefile
|
|
31
|
+
- VERSION
|
|
32
|
+
- country_select.gemspec
|
|
33
|
+
- lib/country_select.rb
|
|
34
|
+
- lib/country_select/countries.yml
|
|
35
|
+
- lib/country_select/version.rb
|
|
36
|
+
- spec/country_select_spec.rb
|
|
37
|
+
- spec/spec_helper.rb
|
|
38
|
+
homepage: https://github.com/waldyr/country_select
|
|
39
|
+
licenses: []
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options: []
|
|
42
|
+
require_paths:
|
|
43
|
+
- lib
|
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
none: false
|
|
46
|
+
requirements:
|
|
47
|
+
- - ! '>='
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
none: false
|
|
52
|
+
requirements:
|
|
53
|
+
- - ! '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubyforge_project:
|
|
58
|
+
rubygems_version: 1.8.24
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 3
|
|
61
|
+
summary: Country Select Plugin
|
|
62
|
+
test_files: []
|