countries_and_languages 0.1.4 → 0.1.5
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.lock +2 -3
- data/lib/countries_and_languages.rb +20 -7
- data/lib/countries_and_languages/version.rb +1 -1
- data/spec/countries_and_languages_spec.rb +14 -6
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
countries_and_languages (0.1.
|
4
|
+
countries_and_languages (0.1.5)
|
5
5
|
i18n_data
|
6
6
|
|
7
7
|
GEM
|
@@ -29,8 +29,7 @@ GEM
|
|
29
29
|
erubis (2.7.0)
|
30
30
|
hike (1.2.1)
|
31
31
|
i18n (0.6.0)
|
32
|
-
i18n_data (0.
|
33
|
-
activesupport (>= 2.2)
|
32
|
+
i18n_data (0.3.1)
|
34
33
|
multi_json (1.0.3)
|
35
34
|
rack (1.3.5)
|
36
35
|
rack-cache (1.1)
|
@@ -25,8 +25,9 @@ module CountriesAndLanguages
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def clean_and_sort(data)
|
28
|
-
data = data.to_a
|
29
|
-
data.map!{|code,name|[clean_name(name),code]}
|
28
|
+
data = data.to_a
|
29
|
+
data.map!{|code,name| [clean_name(name), code] }
|
30
|
+
data.sort_by{|code,name| convert_umlaut_to_base(code) }
|
30
31
|
end
|
31
32
|
|
32
33
|
def clean_name(name)
|
@@ -41,11 +42,23 @@ module CountriesAndLanguages
|
|
41
42
|
name
|
42
43
|
end
|
43
44
|
|
45
|
+
CONVERSIONS = [
|
46
|
+
['áä', 'a'],
|
47
|
+
['ÁÄÅ', 'A'],
|
48
|
+
['óö', 'o'],
|
49
|
+
['ÓÖ', 'O'],
|
50
|
+
['í', 'i'],
|
51
|
+
['Í', 'I'],
|
52
|
+
['úü', 'u'],
|
53
|
+
['ÚÜ', 'U'],
|
54
|
+
['é', 'e'],
|
55
|
+
['É', 'E'],
|
56
|
+
['ß', 's'],
|
57
|
+
]
|
58
|
+
|
44
59
|
def convert_umlaut_to_base(input)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
input.gsub(/[#{from}]/, to)
|
49
|
-
end
|
60
|
+
input = input.dup
|
61
|
+
CONVERSIONS.each { |from, to| input.tr!(from, to) }
|
62
|
+
input
|
50
63
|
end
|
51
64
|
end
|
@@ -8,7 +8,10 @@ describe CountriesAndLanguages do
|
|
8
8
|
I18n.locale = :en
|
9
9
|
end
|
10
10
|
|
11
|
-
{
|
11
|
+
{
|
12
|
+
:country => ['Germany','Deutschland'],
|
13
|
+
:language => ['German','Deutsch']
|
14
|
+
}.each do |method,translation|
|
12
15
|
it "translates #{method}" do
|
13
16
|
send(method,'DE').should == translation[0]
|
14
17
|
I18n.locale = :de
|
@@ -20,15 +23,17 @@ describe CountriesAndLanguages do
|
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
23
|
-
describe
|
26
|
+
describe "clean names" do
|
24
27
|
it "removes everything in braces" do
|
25
28
|
country('va').should == 'Holy See'
|
26
29
|
language('IA').should == 'Interlingua'
|
27
30
|
end
|
31
|
+
|
28
32
|
it "removes everything behind comma" do
|
29
33
|
country('IR').should == 'Iran'
|
30
34
|
language('ND').should == 'Ndebele'
|
31
35
|
end
|
36
|
+
|
32
37
|
it "removes everything behind semicolon" do
|
33
38
|
language('nb').should == 'Bokmål'
|
34
39
|
language('ca').should == 'Catalan'
|
@@ -37,25 +42,28 @@ describe CountriesAndLanguages do
|
|
37
42
|
|
38
43
|
it "sorts umlaut-aware" do
|
39
44
|
I18n.locale = :de
|
40
|
-
countries[
|
45
|
+
countries.map(&:first)[0..5].should == ["Afghanistan", "Ägypten", "Åland-Inseln", "Albanien", "Algerien", "Amerikanische Jungferninseln"]
|
41
46
|
end
|
42
47
|
|
43
|
-
describe
|
44
|
-
describe
|
48
|
+
describe "misc fixes" do
|
49
|
+
describe "German" do
|
45
50
|
before {I18n.locale = :de}
|
51
|
+
|
46
52
|
it "removes -Sprache aditions" do
|
47
53
|
language('ZU').should == "Zulu"
|
48
54
|
end
|
55
|
+
|
49
56
|
it "knows Kongo" do
|
50
57
|
country('CD').should == 'Kongo'
|
51
58
|
end
|
59
|
+
|
52
60
|
it "knows Lao" do
|
53
61
|
country('LA').should == 'Lao'
|
54
62
|
end
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
58
|
-
describe
|
66
|
+
describe "#select_tag" do
|
59
67
|
def h
|
60
68
|
ActionController::Base.helpers
|
61
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: countries_and_languages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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-06-
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n_data
|
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
segments:
|
61
61
|
- 0
|
62
|
-
hash:
|
62
|
+
hash: 4563603787577617020
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
segments:
|
70
70
|
- 0
|
71
|
-
hash:
|
71
|
+
hash: 4563603787577617020
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
74
|
rubygems_version: 1.8.24
|