country_select_german 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58364926b89bbe0fde784ab5b3509f2829abce7a
4
+ data.tar.gz: ad2b30186960cd9a156a497c97c64903b6f179f3
5
+ SHA512:
6
+ metadata.gz: 764d94352d632bf20b1062f00d8618e33f55ca96e64a8384a0343f00084a6913e9166492532b1bd61c853540a9e3e2730f6ee35bf87f2f69e67fa926f7c7c9d2
7
+ data.tar.gz: 0a76034e0f4102e3ee9a926a78246b113773acfbc88ee4c2a499e051b87438d30c9ff4472cba00d7da8e1a8d670da7dc191a432cf3f196c42ef8a4c1311060c3
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ *.sqlite
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ script: "bundle exec rake appraisal:integration"
3
+ rvm:
4
+ - ruby-head
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - 1.8.7
9
+ - ree
10
+ - jruby-head
11
+ - jruby-19mode
12
+ - jruby-18mode
13
+ - rbx-19mode
14
+ - rbx-18mode
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
data/Appraisals ADDED
@@ -0,0 +1,19 @@
1
+ # appraise 'actionpack2.3' do
2
+ # gem 'actionpack', '~> 2.3.0'
3
+ # end
4
+
5
+ appraise 'actionpack3.0' do
6
+ gem 'actionpack', '~> 3.0.0'
7
+ end
8
+
9
+ appraise 'actionpack3.1' do
10
+ gem 'actionpack', '~> 3.1.0'
11
+ end
12
+
13
+ appraise 'actionpack3.2' do
14
+ gem 'actionpack', '~> 3.2.0'
15
+ end
16
+
17
+ appraise 'actionpack4.0' do
18
+ gem 'actionpack', '~> 4.0.0'
19
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ == 1.2.0 2013-07-06
2
+
3
+ * Country names have been synced with UTF-8 encoding to the list of
4
+ countries on [Wikipedia's page for the ISO-3166 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
5
+ * NOTE: This could be a breaking change with some of the country
6
+ names that have been fixed since the list was last updated.
7
+ * For more information you can checkout all country mappings with
8
+ `::CountrySelect::COUNTRIES`
9
+
10
+ * You can now store your country values using the
11
+ [ISO-3166 Alpha-2 codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
12
+ with the `iso_codes` option. See the README.md for details.
13
+ * This should help alleviate the problem of country names
14
+ in ISO-3166 being changed and/or corrected.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in country_select.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Cevin Eichnau
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,87 @@
1
+ # Rails – Country Select German
2
+ [![Build Status](https://travis-ci.org/stefanpenner/country_select.png?branch=master)](https://travis-ci.org/stefanpenner/country_select)
3
+
4
+ Provides a simple helper to get an HTML select list of countries using the
5
+ [ISO 3166-1 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
6
+
7
+ It is also configurable to use countries'
8
+ [ISO 3166-1 alpha-2 codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
9
+ as values and
10
+ [ISO 3166-1 names](https://en.wikipedia.org/wiki/ISO_3166-1)
11
+ as display strings.
12
+
13
+ While the ISO 3166 standard is a relatively neutral source of country
14
+ names, it may still offend some users. Developers are strongly advised
15
+ to evaluate the suitability of this list given their user base.
16
+
17
+ ## Installation
18
+
19
+ Install as a gem using
20
+
21
+ ```shell
22
+ gem install country_select_german
23
+ ```
24
+ Or put the following in your Gemfile
25
+
26
+ ```ruby
27
+ gem 'country_select_german'
28
+ ```
29
+
30
+ ## Example
31
+
32
+ Simple use supplying model and attribute as parameters:
33
+
34
+ ```ruby
35
+ country_select("user", "country")
36
+ ```
37
+
38
+ Supplying priority countries to be placed at the top of the list:
39
+
40
+ ```ruby
41
+ country_select("user", "country", [ "Great Britain", "France", "Germany" ])
42
+ ```
43
+
44
+ ### Using ISO 3166-1 alpha-2 codes as values
45
+ You can have the `option` tags use ISO 3166-1 alpha-2 codes as values
46
+ and the country names as display strings. For example, the United States
47
+ would appear as `<option value="us">United States</option>`
48
+
49
+ If you're starting a new project, this is the recommended way to store
50
+ your country data since it will be more resistant to country names
51
+ changing.
52
+
53
+ ```ruby
54
+ country_select("user", "country_code", nil, iso_codes: true)
55
+ ```
56
+
57
+ ```ruby
58
+ country_select("user", "country_code", [ "gb", "fr", "de" ], iso_codes: true)
59
+ ```
60
+
61
+ #### Getting the Country from ISO codes
62
+
63
+ ```ruby
64
+ class User < ActiveRecord::Base
65
+
66
+ # Assuming country_select is used with User attribute `country_code`
67
+ def country_name
68
+ ::CountrySelect::COUNTRIES[country_code]
69
+ end
70
+
71
+ end
72
+ ```
73
+
74
+ ## Tests
75
+
76
+ ```shell
77
+ bundle
78
+ bundle exec rspec
79
+ ```
80
+
81
+ ### Running with multiple versions of actionpack
82
+
83
+ ```shell
84
+ bundle exec appraisal
85
+ ```
86
+
87
+ Copyright (c) 2008 Michael Koziarski, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+
5
+ require 'appraisal'
6
+
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task :default => :spec
11
+
12
+ namespace :appraisal do
13
+ desc "Run the given task for a particular integration's appraisals"
14
+ task :integration do
15
+ Appraisal::File.each do |appraisal|
16
+ if RUBY_VERSION < '1.9.3' and appraisal.name == 'actionpack4.0'
17
+ # skip rails 4 for ruby < 1.9.3
18
+ else
19
+ appraisal.install
20
+ Appraisal::Command.from_args(appraisal.gemfile_path).run
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
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_german'
7
+ s.version = CountrySelect::VERSION
8
+ s.authors = ['Cevin Eichnau']
9
+ s.email = ['cevin@eichnau.com']
10
+ s.homepage = 'https://github.com/CevinEichnau/country_select'
11
+ s.summary = %q{Country Select German Gem}
12
+ s.description = %q{Provides a simple helper to get an HTML select list of countries translate in german. 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.rubyforge_project = 'country_select_german'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ['lib']
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency 'rspec'
23
+ if RUBY_VERSION < '1.9.3'
24
+ s.add_development_dependency 'actionpack', '~> 3.2.13'
25
+ else
26
+ s.add_development_dependency 'actionpack'
27
+ end
28
+ s.add_development_dependency 'appraisal'
29
+ s.add_development_dependency 'pry'
30
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 3.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: /Users/scudco/projects/country_select
3
+ specs:
4
+ country_select (1.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ abstract (1.0.0)
10
+ actionpack (3.0.20)
11
+ activemodel (= 3.0.20)
12
+ activesupport (= 3.0.20)
13
+ builder (~> 2.1.2)
14
+ erubis (~> 2.6.6)
15
+ i18n (~> 0.5.0)
16
+ rack (~> 1.2.5)
17
+ rack-mount (~> 0.6.14)
18
+ rack-test (~> 0.5.7)
19
+ tzinfo (~> 0.3.23)
20
+ activemodel (3.0.20)
21
+ activesupport (= 3.0.20)
22
+ builder (~> 2.1.2)
23
+ i18n (~> 0.5.0)
24
+ activesupport (3.0.20)
25
+ appraisal (0.5.2)
26
+ bundler
27
+ rake
28
+ builder (2.1.2)
29
+ coderay (1.0.9)
30
+ diff-lcs (1.2.4)
31
+ erubis (2.6.6)
32
+ abstract (>= 1.0.0)
33
+ i18n (0.5.0)
34
+ method_source (0.8.1)
35
+ pry (0.9.12.2)
36
+ coderay (~> 1.0.5)
37
+ method_source (~> 0.8)
38
+ slop (~> 3.4)
39
+ rack (1.2.8)
40
+ rack-mount (0.6.14)
41
+ rack (>= 1.0.0)
42
+ rack-test (0.5.7)
43
+ rack (>= 1.0)
44
+ rake (10.0.4)
45
+ rspec (2.13.0)
46
+ rspec-core (~> 2.13.0)
47
+ rspec-expectations (~> 2.13.0)
48
+ rspec-mocks (~> 2.13.0)
49
+ rspec-core (2.13.1)
50
+ rspec-expectations (2.13.0)
51
+ diff-lcs (>= 1.1.3, < 2.0)
52
+ rspec-mocks (2.13.1)
53
+ slop (3.4.5)
54
+ tzinfo (0.3.37)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ actionpack (~> 3.0.0)
61
+ appraisal
62
+ country_select!
63
+ pry
64
+ rspec
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 3.1.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: /Users/scudco/projects/country_select
3
+ specs:
4
+ country_select (1.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (3.1.12)
10
+ activemodel (= 3.1.12)
11
+ activesupport (= 3.1.12)
12
+ builder (~> 3.0.0)
13
+ erubis (~> 2.7.0)
14
+ i18n (~> 0.6)
15
+ rack (~> 1.3.6)
16
+ rack-cache (~> 1.2)
17
+ rack-mount (~> 0.8.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.0.4)
20
+ activemodel (3.1.12)
21
+ activesupport (= 3.1.12)
22
+ builder (~> 3.0.0)
23
+ i18n (~> 0.6)
24
+ activesupport (3.1.12)
25
+ multi_json (~> 1.0)
26
+ appraisal (0.5.2)
27
+ bundler
28
+ rake
29
+ builder (3.0.4)
30
+ coderay (1.0.9)
31
+ diff-lcs (1.2.4)
32
+ erubis (2.7.0)
33
+ hike (1.2.2)
34
+ i18n (0.6.4)
35
+ method_source (0.8.1)
36
+ multi_json (1.7.3)
37
+ pry (0.9.12.2)
38
+ coderay (~> 1.0.5)
39
+ method_source (~> 0.8)
40
+ slop (~> 3.4)
41
+ rack (1.3.10)
42
+ rack-cache (1.2)
43
+ rack (>= 0.4)
44
+ rack-mount (0.8.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (0.6.2)
47
+ rack (>= 1.0)
48
+ rake (10.0.4)
49
+ rspec (2.13.0)
50
+ rspec-core (~> 2.13.0)
51
+ rspec-expectations (~> 2.13.0)
52
+ rspec-mocks (~> 2.13.0)
53
+ rspec-core (2.13.1)
54
+ rspec-expectations (2.13.0)
55
+ diff-lcs (>= 1.1.3, < 2.0)
56
+ rspec-mocks (2.13.1)
57
+ slop (3.4.5)
58
+ sprockets (2.0.4)
59
+ hike (~> 1.2)
60
+ rack (~> 1.0)
61
+ tilt (~> 1.1, != 1.3.0)
62
+ tilt (1.4.1)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ actionpack (~> 3.1.0)
69
+ appraisal
70
+ country_select!
71
+ pry
72
+ rspec
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 3.2.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: /Users/scudco/projects/country_select
3
+ specs:
4
+ country_select (1.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (3.2.13)
10
+ activemodel (= 3.2.13)
11
+ activesupport (= 3.2.13)
12
+ builder (~> 3.0.0)
13
+ erubis (~> 2.7.0)
14
+ journey (~> 1.0.4)
15
+ rack (~> 1.4.5)
16
+ rack-cache (~> 1.2)
17
+ rack-test (~> 0.6.1)
18
+ sprockets (~> 2.2.1)
19
+ activemodel (3.2.13)
20
+ activesupport (= 3.2.13)
21
+ builder (~> 3.0.0)
22
+ activesupport (3.2.13)
23
+ i18n (= 0.6.1)
24
+ multi_json (~> 1.0)
25
+ appraisal (0.5.2)
26
+ bundler
27
+ rake
28
+ builder (3.0.4)
29
+ coderay (1.0.9)
30
+ diff-lcs (1.2.4)
31
+ erubis (2.7.0)
32
+ hike (1.2.2)
33
+ i18n (0.6.1)
34
+ journey (1.0.4)
35
+ method_source (0.8.1)
36
+ multi_json (1.7.3)
37
+ pry (0.9.12.2)
38
+ coderay (~> 1.0.5)
39
+ method_source (~> 0.8)
40
+ slop (~> 3.4)
41
+ rack (1.4.5)
42
+ rack-cache (1.2)
43
+ rack (>= 0.4)
44
+ rack-test (0.6.2)
45
+ rack (>= 1.0)
46
+ rake (10.0.4)
47
+ rspec (2.13.0)
48
+ rspec-core (~> 2.13.0)
49
+ rspec-expectations (~> 2.13.0)
50
+ rspec-mocks (~> 2.13.0)
51
+ rspec-core (2.13.1)
52
+ rspec-expectations (2.13.0)
53
+ diff-lcs (>= 1.1.3, < 2.0)
54
+ rspec-mocks (2.13.1)
55
+ slop (3.4.5)
56
+ sprockets (2.2.2)
57
+ hike (~> 1.2)
58
+ multi_json (~> 1.0)
59
+ rack (~> 1.0)
60
+ tilt (~> 1.1, != 1.3.0)
61
+ tilt (1.4.1)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ actionpack (~> 3.2.0)
68
+ appraisal
69
+ country_select!
70
+ pry
71
+ rspec
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 4.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,62 @@
1
+ PATH
2
+ remote: /Users/scudco/projects/country_select
3
+ specs:
4
+ country_select (1.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (4.0.0)
10
+ activesupport (= 4.0.0)
11
+ builder (~> 3.1.0)
12
+ erubis (~> 2.7.0)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ activesupport (4.0.0)
16
+ i18n (~> 0.6, >= 0.6.4)
17
+ minitest (~> 4.2)
18
+ multi_json (~> 1.3)
19
+ thread_safe (~> 0.1)
20
+ tzinfo (~> 0.3.37)
21
+ appraisal (0.5.2)
22
+ bundler
23
+ rake
24
+ atomic (1.1.10)
25
+ builder (3.1.4)
26
+ coderay (1.0.9)
27
+ diff-lcs (1.2.4)
28
+ erubis (2.7.0)
29
+ i18n (0.6.4)
30
+ method_source (0.8.1)
31
+ minitest (4.7.5)
32
+ multi_json (1.7.7)
33
+ pry (0.9.12.2)
34
+ coderay (~> 1.0.5)
35
+ method_source (~> 0.8)
36
+ slop (~> 3.4)
37
+ rack (1.5.2)
38
+ rack-test (0.6.2)
39
+ rack (>= 1.0)
40
+ rake (10.1.0)
41
+ rspec (2.13.0)
42
+ rspec-core (~> 2.13.0)
43
+ rspec-expectations (~> 2.13.0)
44
+ rspec-mocks (~> 2.13.0)
45
+ rspec-core (2.13.1)
46
+ rspec-expectations (2.13.0)
47
+ diff-lcs (>= 1.1.3, < 2.0)
48
+ rspec-mocks (2.13.1)
49
+ slop (3.4.5)
50
+ thread_safe (0.1.0)
51
+ atomic
52
+ tzinfo (0.3.37)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ actionpack (~> 4.0.0)
59
+ appraisal
60
+ country_select!
61
+ pry
62
+ rspec
@@ -0,0 +1,122 @@
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
59
+
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
72
+
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 = {})
115
+
116
+ @template.country_select(@object_name, method, priority_countries,
117
+ options.merge(:object => @object),
118
+ html_options)
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,258 @@
1
+ # encoding: utf-8
2
+ module CountrySelect
3
+ COUNTRIES = {
4
+ "af"=>"Afghanistan",
5
+ "ax"=>"Åland-Iland",
6
+ "al"=>"Albanien",
7
+ "dz"=>"Algerien",
8
+ "as"=>"amerikanische Samoa",
9
+ "ad"=>"Andorra",
10
+ "ao"=>"Angola",
11
+ "ai"=>"Anguilla",
12
+ "aq"=>"Antarktis",
13
+ "ag"=>"Antigua und Barbuda",
14
+ "ar"=>"Argentinien",
15
+ "am"=>"Armenien",
16
+ "aw"=>"Aruba",
17
+ "au"=>"Australien",
18
+ "at"=>"Österreich",
19
+ "az"=>"Aserbaidschan",
20
+ "bs"=>"Bahamas",
21
+ "bh"=>"Bahrain",
22
+ "bd"=>"Bangladesch",
23
+ "bb"=>"Barbados",
24
+ "by"=>"Belarus",
25
+ "be"=>"Belgien",
26
+ "bz"=>"Belize",
27
+ "bj"=>"Benin",
28
+ "bm"=>"Bermuda",
29
+ "bt"=>"Bhutan",
30
+ "bo"=>"Bolivien, multinationaler Staat von",
31
+ "bq"=>"Bonaire, Sint Eustatius und Saba",
32
+ "ba"=>"Bosnien und Herzegowina",
33
+ "bw"=>"Botswana",
34
+ "bv"=>"Bouvet-Insel",
35
+ "br"=>"Brasilien",
36
+ "io"=>"Britisches Territorium im Indischen Ozean",
37
+ "bn"=>"Brunei Darussalam",
38
+ "bg"=>"Bulgarien",
39
+ "bf"=>"Burkina Faso",
40
+ "bi"=>"Burundi",
41
+ "kh"=>"Kambodscha",
42
+ "cm"=>"Kamerun",
43
+ "ca"=>"Kanada",
44
+ "cv"=>"Cape Verde",
45
+ "ky"=>"Cayman Islands",
46
+ "cf"=>"Zentralafrikanische Republik",
47
+ "td"=>"Chad",
48
+ "cl"=>"Chile",
49
+ "cn"=>"China",
50
+ "cx"=>"Weihnachtsinsel",
51
+ "cc"=>"Cocos (Keeling ) Islands",
52
+ "co"=>"Kolumbien",
53
+ "km"=>"Komoren",
54
+ "cg"=>"Kongo",
55
+ "cd"=>"Kongo, die Demokratische Republik",
56
+ "ck"=>"cook Islands",
57
+ "cr"=>"Costa Rica",
58
+ "ci"=>"Côte d' Ivoire",
59
+ "hr"=>"Kroatien",
60
+ "cu"=>"Kuba",
61
+ "cw"=>"Curaçao",
62
+ "cy"=>"Zypern",
63
+ "cz"=>"Tschechische Republik",
64
+ "dk"=>"Dänemark",
65
+ "dj"=>"Djibouti",
66
+ "dm"=>"Dominica",
67
+ "do"=>"Dominikanische Republik",
68
+ "ec"=>"Ecuador",
69
+ "eg"=>"Ägypten",
70
+ "sv"=>"El Salvador",
71
+ "gq"=>"Äquatorial- Guinea",
72
+ "er"=>"Eritrea",
73
+ "ee"=>"Estland",
74
+ "et"=>"Äthiopien",
75
+ "fk"=>"Falklandinseln ( Malvinas )",
76
+ "fo"=>"Färöer-Inseln",
77
+ "fj"=>"Fidschi",
78
+ "fi"=>"Finnland",
79
+ "fr"=>"Frankreich",
80
+ "gf"=>"Französisch-Guayana",
81
+ "pf"=>"Französisch-Polynesien",
82
+ "tf"=>"Französisch Southern Territories",
83
+ "ga"=>"Gabun",
84
+ "gm"=>"Gambia",
85
+ "ge"=>"Georgia",
86
+ "de"=>"Deutschland",
87
+ "gh"=>"Ghana",
88
+ "gi"=>"Gibraltar",
89
+ "gr"=>"Griechenland",
90
+ "gl"=>"Grönland",
91
+ "gd"=>"Grenada",
92
+ "gp"=>"Guadeloupe",
93
+ "gu"=>"Guam",
94
+ "gt"=>"Guatemala",
95
+ "gg"=>"Guernsey",
96
+ "gn"=>"Guinea",
97
+ "gw"=>"Guinea- Bissau",
98
+ "gy"=>"Guyana",
99
+ "ht"=>"Haiti",
100
+ "hm"=>"Heard und McDonald-Inseln",
101
+ "va"=>"Heiliger Stuhl ( Vatikanstadt)",
102
+ "hn"=>"Honduras",
103
+ "hk"=>"Hong Kong",
104
+ "hu"=>"Ungarn",
105
+ "is"=>"Island",
106
+ "in"=>"Indien",
107
+ "id"=>"Indonesien",
108
+ "ir"=>"Iran , Islamic Republic of",
109
+ "iq"=>"Irak",
110
+ "ie"=>"Irland",
111
+ "im"=>"Isle of Man",
112
+ "il"=>"Israel",
113
+ "it"=>"Italien",
114
+ "jm"=>"Jamaica",
115
+ "jp"=>"Japan",
116
+ "je"=>"Jersey",
117
+ "jo"=>"Jordan",
118
+ "kz"=>"Kasachstan",
119
+ "ke"=>"Kenia",
120
+ "ki"=>"Kiribati",
121
+ "kp"=>"Korea , Demokratische Volksrepublik",
122
+ "kr"=>"Korea , Republic of",
123
+ "kw"=>"Kuwait",
124
+ "kg"=>"Kirgisistan",
125
+ "la"=>"Lao Demokratischen Volksrepublik",
126
+ "lv"=>"Lettland",
127
+ "lb"=>"Libanon",
128
+ "ls"=>"Lesotho",
129
+ "lr"=>"Liberia",
130
+ "ly"=>"Libyen",
131
+ "li"=>"Liechtenstein",
132
+ "lt"=>"Litauen",
133
+ "lu"=>"Luxemburg",
134
+ "mo"=>"Macao",
135
+ "mk"=>"Mazedonien, die ehemalige jugoslawische Republik",
136
+ "mg"=>"Madagaskar",
137
+ "mw"=>"Malawi",
138
+ "my"=>"Malaysia",
139
+ "mv"=>"Malediven",
140
+ "ml"=>"Mali",
141
+ "mt"=>"Malta",
142
+ "mh"=>"Marshall Islands",
143
+ "mq"=>"Martinique",
144
+ "mr"=>"Mauretanien",
145
+ "mu"=>"Mauritius",
146
+ "yt"=>"Mayotte",
147
+ "mx"=>"Mexiko",
148
+ "fm"=>"Mikronesien , Föderierte Staaten von",
149
+ "md"=>"Moldova, Republic of",
150
+ "mc"=>"Monaco",
151
+ "mn"=>"Mongolei",
152
+ "me"=>"Montenegro",
153
+ "ms"=>"Montserrat",
154
+ "ma"=>"Marokko",
155
+ "mz"=>"Mosambik",
156
+ "mm"=>"Myanmar",
157
+ "na"=>"Namibia",
158
+ "nr"=>"Nauru",
159
+ "np"=>"Nepal",
160
+ "nl"=>"Niederlande",
161
+ "nc"=>"Neukaledonien",
162
+ "nz"=>"Neuseeland",
163
+ "ni"=>"Nicaragua",
164
+ "ne"=>"Niger",
165
+ "ng"=>"Nigeria",
166
+ "nu"=>"Niue",
167
+ "nf"=>"Norfolk-Insel",
168
+ "mp"=>"Northern Mariana Islands",
169
+ "no"=>"Norwegen",
170
+ "om"=>"Oman",
171
+ "pk"=>"Pakistan",
172
+ "pw"=>"Palau",
173
+ "ps"=>"Palästina , Bundesstaat",
174
+ "pa"=>"Panama",
175
+ "pg"=>"Papua-Neuguinea",
176
+ "py"=>"Paraguay",
177
+ "pe"=>"Peru",
178
+ "ph"=>"Philippinen",
179
+ "pn"=>"Pitcairn",
180
+ "pl"=>"Polen",
181
+ "pt"=>"Portugal",
182
+ "pr"=>"Puerto Rico",
183
+ "qa"=>"Qatar",
184
+ "re"=>"Réunion",
185
+ "ro"=>"Rumänien",
186
+ "ru"=>"Russische Föderation",
187
+ "rw"=>"Ruanda",
188
+ "bl"=>"saint Barthélemy",
189
+ "sh"=>"St. Helena , Ascension und Tristan da Cunha",
190
+ "kn"=>"St. Kitts und Nevis",
191
+ "lc"=>"St. Lucia",
192
+ "mf"=>"St. Martin (Französisch Teil)",
193
+ "pm"=>"Saint-Pierre und Miquelon",
194
+ "vc"=>"St. Vincent und die Grenadinen",
195
+ "ws"=>"Samoa",
196
+ "sm"=>"San Marino",
197
+ "st"=>"Sao Tome und Principe",
198
+ "sa"=>"Saudi-Arabien",
199
+ "sn"=>"Senegal",
200
+ "rs"=>"Serbien",
201
+ "sc"=>"Seychellen",
202
+ "sl"=>"Sierra Leone",
203
+ "sg"=>"Singapur",
204
+ "sx"=>"Sint Maarten ( niederländischen Teil )",
205
+ "sk"=>"Slowakei",
206
+ "si"=>"Slowenien",
207
+ "sb"=>"Solomon Islands",
208
+ "so"=>"Somalia",
209
+ "za"=>"Südafrika",
210
+ "gs"=>"Süd-Georgien und Süd-Sandwich- Inseln",
211
+ "ss"=>"Südsudan",
212
+ "es"=>"Spanien",
213
+ "lk"=>"Sri Lanka",
214
+ "sd"=>"Sudan",
215
+ "sr"=>"Suriname",
216
+ "sj"=>"Spitzbergen und Jan Mayen",
217
+ "sz"=>"Swaziland",
218
+ "se"=>"Schweden",
219
+ "ch"=>"Schweiz",
220
+ "sy"=>"Syrian Arab Republic",
221
+ "tw"=>"Taiwan , Province of China",
222
+ "tj"=>"Tadschikistan",
223
+ "tz"=>"Tansania, Vereinigte Republik",
224
+ "th"=>"Thailand",
225
+ "tl"=>"Timor- Leste",
226
+ "tg"=>"Togo",
227
+ "tk"=>"Tokelau",
228
+ "to"=>"Tonga",
229
+ "tt"=>"Trinidad und Tobago",
230
+ "tn"=>"Tunesien",
231
+ "tr"=>"Türkei",
232
+ "tm"=>"Turkmenistan",
233
+ "tc"=>"Turks-und Caicosinseln",
234
+ "tv"=>"Tuvalu",
235
+ "ug"=>"Uganda",
236
+ "ua"=>"Ukraine",
237
+ "ae"=>"Vereinigte Arabische Emirate",
238
+ "gb"=>"Großbritannien",
239
+ "us"=>"Vereinigte Staaten von Amerika",
240
+ "um"=>"United States Minor Outlying Islands",
241
+ "uy"=>"Uruguay",
242
+ "uz"=>"Usbekistan",
243
+ "vu"=>"Vanuatu",
244
+ "ve"=>"Venezuela, Bolivarischen Republik",
245
+ "vn"=>"Viet Nam",
246
+ "vg"=>"Virgin Islands, British",
247
+ "vi"=>"Virgin Islands, US",
248
+ "wf"=>"Wallis und Futuna",
249
+ "eh"=>"Westsahara",
250
+ "ye"=>"Jemen",
251
+ "zm"=>"Sambia",
252
+ "zw"=>"Simbabwe"
253
+ }
254
+ } unless const_defined?("COUNTRIES")
255
+
256
+ ISO_COUNTRIES_FOR_SELECT = COUNTRIES.invert unless const_defined?("ISO_COUNTRIES_FOR_SELECT")
257
+ COUNTRIES_FOR_SELECT = COUNTRIES.values unless const_defined?("COUNTRIES_FOR_SELECT")
258
+ end
@@ -0,0 +1,3 @@
1
+ module CountrySelect
2
+ VERSION = "1.2.1"
3
+ end
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ require 'action_view'
4
+ require 'country_select'
5
+
6
+ module ActionView
7
+ module Helpers
8
+
9
+ describe CountrySelect do
10
+ include TagHelper
11
+
12
+ class Walrus
13
+ attr_accessor :country_name
14
+ end
15
+
16
+ let(:walrus) { Walrus.new }
17
+
18
+ let!(:template) { ActionView::Base.new }
19
+
20
+ let(:select_tag) do
21
+ "<select id=\"walrus_country_name\" name=\"walrus[country_name]\">"
22
+ end
23
+
24
+ let(:selected_us_option) do
25
+ if defined?(Tags::Base)
26
+ content_tag(:option, 'United States', :selected => :selected, :value => "United States")
27
+ else
28
+ "<option value=\"United States\" selected=\"selected\">United States</option>"
29
+ end
30
+ end
31
+
32
+ let(:selected_iso_us_option) do
33
+ if defined?(Tags::Base)
34
+ content_tag(:option, 'United States', :selected => :selected, :value => 'us')
35
+ else
36
+ "<option value=\"us\" selected=\"selected\">United States</option>"
37
+ end
38
+ end
39
+
40
+ let(:builder) do
41
+ if defined?(Tags::Base)
42
+ FormBuilder.new(:walrus, walrus, template, {})
43
+ else
44
+ FormBuilder.new(:walrus, walrus, template, {}, Proc.new { })
45
+ end
46
+ end
47
+
48
+ context "iso codes disabled" do
49
+ describe "#country_select" do
50
+ let(:tag) { builder.country_select(:country_name) }
51
+
52
+ it "creates a select tag" do
53
+ tag.should include(select_tag)
54
+ end
55
+
56
+ it "creates option tags of the countries" do
57
+ ::CountrySelect::COUNTRIES.each do |code,name|
58
+ tag.should include(content_tag(:option, name, :value => name))
59
+ end
60
+ end
61
+
62
+ it "selects the value of country_name" do
63
+ walrus.country_name = 'United States'
64
+ t = builder.country_select(:country_name)
65
+ t.should include(selected_us_option)
66
+ end
67
+ end
68
+
69
+ describe "#priority_countries" do
70
+ let(:tag) { builder.country_select(:country_name, ['United States']) }
71
+
72
+ it "puts the countries at the top" do
73
+ tag.should include("#{select_tag}<option value=\"United States")
74
+ end
75
+
76
+ it "inserts a divider" do
77
+ tag.should include(">United States</option><option value=\"\" disabled=\"disabled\">-------------</option>")
78
+ end
79
+
80
+ it "does not mark two countries as selected" do
81
+ walrus.country_name = "United States"
82
+ str = <<-EOS.strip
83
+ </option>\n<option value="United States" selected="selected">United States</option>
84
+ EOS
85
+ tag.should_not include(str)
86
+ end
87
+ end
88
+ end
89
+
90
+ context "iso codes enabled" do
91
+ describe "#country_select" do
92
+ let(:tag) { builder.country_select(:country_name, nil, :iso_codes => true) }
93
+
94
+ it "creates a select tag" do
95
+ tag.should include(select_tag)
96
+ end
97
+
98
+ it "creates option tags of the countries" do
99
+ ::CountrySelect::COUNTRIES.each do |code,name|
100
+ tag.should include(content_tag(:option, name, :value => code))
101
+ end
102
+ end
103
+
104
+ it "selects the value of country_name" do
105
+ walrus.country_name = 'us'
106
+ t = builder.country_select(:country_name, nil, :iso_codes => true)
107
+ t.should include(selected_iso_us_option)
108
+ end
109
+ end
110
+
111
+ describe "#priority_countries" do
112
+ let(:tag) { builder.country_select(:country_name, ['us'], :iso_codes => true) }
113
+
114
+ it "puts the countries at the top" do
115
+ tag.should include("#{select_tag}<option value=\"us")
116
+ end
117
+
118
+ it "inserts a divider" do
119
+ tag.should include(">United States</option><option value=\"\" disabled=\"disabled\">-------------</option>")
120
+ end
121
+
122
+ it "does not mark two countries as selected" do
123
+ walrus.country_name = "us"
124
+ str = <<-EOS.strip
125
+ </option>\n<option value="us" selected="selected">United States</option>
126
+ EOS
127
+ tag.should_not include(str)
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,20 @@
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
+
8
+ require 'pry'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: country_select_german
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Cevin Eichnau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionpack
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
+ - !ruby/object:Gem::Dependency
42
+ name: appraisal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides a simple helper to get an HTML select list of countries translate
70
+ in german. The list of countries comes from the ISO 3166 standard. While it is
71
+ a relatively neutral source of country names, it will still offend some users.
72
+ email:
73
+ - cevin@eichnau.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .travis.yml
81
+ - Appraisals
82
+ - CHANGELOG.md
83
+ - Gemfile
84
+ - MIT-LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - country_select.gemspec
88
+ - gemfiles/actionpack3.0.gemfile
89
+ - gemfiles/actionpack3.0.gemfile.lock
90
+ - gemfiles/actionpack3.1.gemfile
91
+ - gemfiles/actionpack3.1.gemfile.lock
92
+ - gemfiles/actionpack3.2.gemfile
93
+ - gemfiles/actionpack3.2.gemfile.lock
94
+ - gemfiles/actionpack4.0.gemfile
95
+ - gemfiles/actionpack4.0.gemfile.lock
96
+ - lib/country_select.rb
97
+ - lib/country_select/countries.rb
98
+ - lib/country_select/version.rb
99
+ - spec/country_select_spec.rb
100
+ - spec/spec_helper.rb
101
+ homepage: https://github.com/CevinEichnau/country_select
102
+ licenses: []
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project: country_select_german
120
+ rubygems_version: 2.1.0
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Country Select German Gem
124
+ test_files:
125
+ - spec/country_select_spec.rb
126
+ - spec/spec_helper.rb