countries_and_languages 0.1.6 → 0.2.0
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
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
require 'i18n_data'
|
3
3
|
|
4
4
|
module CountriesAndLanguages
|
5
|
-
extend self
|
6
|
-
|
7
5
|
module Helpers
|
8
6
|
def countries
|
9
7
|
@@countries ||= {}
|
@@ -11,7 +9,7 @@ module CountriesAndLanguages
|
|
11
9
|
end
|
12
10
|
|
13
11
|
def country(country_code)
|
14
|
-
countries.rassoc(country_code.to_s.upcase)
|
12
|
+
(countries.rassoc(country_code.to_s.upcase) || [''])[0]
|
15
13
|
end
|
16
14
|
|
17
15
|
def languages
|
@@ -20,17 +18,17 @@ module CountriesAndLanguages
|
|
20
18
|
end
|
21
19
|
|
22
20
|
def language(language_code)
|
23
|
-
languages.rassoc(language_code.to_s.upcase)
|
21
|
+
(languages.rassoc(language_code.to_s.upcase) || [''])[0]
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
def clean_and_sort(data)
|
25
|
+
def self.clean_and_sort(data)
|
28
26
|
data = data.to_a
|
29
27
|
data.map!{|code,name| [clean_name(name), code] }
|
30
|
-
data.sort_by{|code,
|
28
|
+
data.sort_by{|code,_| convert_umlaut_to_base(code) }
|
31
29
|
end
|
32
30
|
|
33
|
-
def clean_name(name)
|
31
|
+
def self.clean_name(name)
|
34
32
|
#General fixes
|
35
33
|
name = name.sub(/\s*[,;(].*/,'')
|
36
34
|
|
@@ -58,7 +56,7 @@ module CountriesAndLanguages
|
|
58
56
|
|
59
57
|
RUBY_18 = RUBY_VERSION < "1.9"
|
60
58
|
|
61
|
-
def convert_umlaut_to_base(input)
|
59
|
+
def self.convert_umlaut_to_base(input)
|
62
60
|
input = input.dup
|
63
61
|
if RUBY_18
|
64
62
|
old = $KCODE
|