country_select 1.0.1 → 1.1.1
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/Gemfile +2 -0
- data/README.md +4 -10
- data/VERSION +1 -0
- data/lib/country_select.rb +17 -2
- data/lib/country_select/version.rb +1 -1
- metadata +9 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Country_Select
|
2
2
|
|
3
3
|
Provides a simple helper to get an HTML select list of countries. The list of countries comes
|
4
4
|
from the ISO 3166 standard. While it is a relatively neutral source of country names, it may
|
@@ -10,11 +10,11 @@ Users are strongly advised to evaluate the suitability of this list given their
|
|
10
10
|
|
11
11
|
Install as a gem using
|
12
12
|
|
13
|
-
gem install
|
13
|
+
gem install country_select
|
14
14
|
|
15
15
|
Or put the following in your Gemfile
|
16
16
|
|
17
|
-
gem '
|
17
|
+
gem 'country_select'
|
18
18
|
|
19
19
|
## Example
|
20
20
|
|
@@ -28,13 +28,7 @@ Supplying priority countries to be placed at the top of the list:
|
|
28
28
|
|
29
29
|
Specifying which country to be selected:
|
30
30
|
United Kingdom will be selected.
|
31
|
-
country_select("user", "country_name", [ "+United Kingdom+", "France", "Germany" ])
|
32
|
-
|
33
|
-
Example in a Rails form:
|
34
|
-
Full list, with New Zealand Australia and United Kingdom prioritized (New Zealand selected
|
35
|
-
by default)
|
36
|
-
<%= country_select(:player, :nationality, [ "+New Zealand+", "Australia", "United Kingdom" ])
|
37
|
-
%>
|
38
31
|
|
32
|
+
country_select("user", "country_name", [ "+United Kingdom+", "France", "Germany" ])
|
39
33
|
|
40
34
|
Copyright (c) 2008 Michael Koziarski, released under the MIT license
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/country_select.rb
CHANGED
@@ -6,7 +6,12 @@ module ActionView
|
|
6
6
|
module FormOptionsHelper
|
7
7
|
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
8
8
|
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
9
|
-
InstanceTag
|
9
|
+
# check if InstanceTag defined and accepts more than zero attributes in new method
|
10
|
+
if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
11
|
+
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
|
12
|
+
else
|
13
|
+
CountrySelect.new(object, method, self, options).to_country_select_tag(priority_countries, options, html_options)
|
14
|
+
end
|
10
15
|
end
|
11
16
|
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
|
12
17
|
# have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
|
@@ -67,7 +72,7 @@ module ActionView
|
|
67
72
|
"Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
|
68
73
|
end
|
69
74
|
|
70
|
-
|
75
|
+
module ToCountrySelectTag
|
71
76
|
def to_country_select_tag(priority_countries, options, html_options)
|
72
77
|
html_options = html_options.stringify_keys
|
73
78
|
add_default_name_and_id(html_options)
|
@@ -81,6 +86,16 @@ module ActionView
|
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
89
|
+
if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
90
|
+
class InstanceTag
|
91
|
+
include ToCountrySelectTag
|
92
|
+
end
|
93
|
+
else
|
94
|
+
class CountrySelect < Tags::Base
|
95
|
+
include ToCountrySelectTag
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
84
99
|
class FormBuilder
|
85
100
|
def country_select(method, priority_countries = nil, options = {}, html_options = {})
|
86
101
|
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides a simple helper to get an HTML select list of countries. The
|
15
15
|
list of countries comes from the ISO 3166 standard. While it is a relatively neutral
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- MIT-LICENSE
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
28
|
+
- VERSION
|
28
29
|
- country_select.gemspec
|
29
30
|
- lib/country_select.rb
|
30
31
|
- lib/country_select/version.rb
|
@@ -40,12 +41,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
41
|
- - ! '>='
|
41
42
|
- !ruby/object:Gem::Version
|
42
43
|
version: '0'
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
hash: -4540347741116960557
|
43
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
48
|
none: false
|
45
49
|
requirements:
|
46
50
|
- - ! '>='
|
47
51
|
- !ruby/object:Gem::Version
|
48
52
|
version: '0'
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
hash: -4540347741116960557
|
49
56
|
requirements: []
|
50
57
|
rubyforge_project: country_select
|
51
58
|
rubygems_version: 1.8.24
|