localized_country_select 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  */.DS_Store
3
- rdoc
3
+ rdoc
4
+ *.gem
@@ -1,3 +1,3 @@
1
1
  module LocalizedCountrySelect
2
- VERSION = "0.9.9"
2
+ VERSION = '0.9.10'
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'open-uri'
3
3
  require 'active_support/inflector'
4
+ require 'csv'
4
5
 
5
6
  # Rake task for importing country names from Unicode.org's CLDR repository
6
7
  # (http://www.unicode.org/cldr/data/charts/summary/root.html).
@@ -56,9 +57,14 @@ namespace :import do
56
57
 
57
58
  set_parser(ENV['PARSER']) if ENV['PARSER']
58
59
  puts "... parsing the HTML file using #{parser.name.split("::").last}"
59
- countries = parser.parse(html).inject([]) { |arr, (code, attrs)| arr << attrs }
60
+ countries = parser.parse(html).inject([]) { |arr, (_code, attrs)| arr << attrs }
60
61
  countries.sort_by! { |c| c[:code] }
62
+ puts '... fetching correct list of country codes and filtering translations'
63
+ correct_list = CSV.parse(open('https://raw.githubusercontent.com/datasets/un-locode/master/data/country-codes.csv').string)
64
+ country_codes = correct_list.map { |c| c[0] }
65
+ countries.delete_if { |c| !country_codes.member?(c[:code].to_s) }
61
66
  puts "\n\n... imported #{countries.count} countries:"
67
+
62
68
  puts countries.map { |c| "#{c[:code]}: #{c[:name]}" }.join(", ")
63
69
 
64
70
 
@@ -136,7 +142,7 @@ TAIL
136
142
  document.search("//tr").inject({}) do |hash, row|
137
143
  n = row.search("td[@class='n']")
138
144
  g = row.search("td")
139
- if n.inner_html =~ /NamesTerritories/ && g.count >= 6 && g[4].inner_html =~ /^[A-Z]{2}/
145
+ if n.inner_html =~ /Locale Display Names/ && g.count >= 6 && g[4].inner_html =~ /^[A-Z]{2}/
140
146
  code = g[4].inner_text
141
147
  code = code[-code.size, 2].to_sym
142
148
  name = row.search("td[@class='v']:not([@title])").inner_text
@@ -163,7 +169,7 @@ TAIL
163
169
  document.find("//tr").inject({}) do |hash, row|
164
170
  n = row.find("td[@class='n']")
165
171
  g = row.find("td")
166
- if n.map(&:content).join =~ /NamesTerritories/ && g.count >= 6 && g[4].inner_xml =~ /^[A-Z]{2}/
172
+ if n.map(&:content).join =~ /Locale Display Names/ && g.count >= 6 && g[4].inner_xml =~ /^[A-Z]{2}/
167
173
  code = g[4].content
168
174
  code = code[-code.size, 2].to_sym
169
175
  name = row.find("td[@class='v' and not(@title)]").map(&:content).join
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localized_country_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,12 @@ authors:
10
10
  - LIM SAS
11
11
  - Damien MATHIEU
12
12
  - Julien SANCHEZ
13
- - Hervé GAUCHER
14
- - ! 'RainerBlessing '
13
+ - Herv\303\251 GAUCHER
14
+ - RainerBlessing
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2014-07-25 00:00:00.000000000 Z
18
+ date: 2015-03-15 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: actionpack
@@ -49,10 +49,16 @@ dependencies:
49
49
  - - ! '>='
50
50
  - !ruby/object:Gem::Version
51
51
  version: 2.0.0
52
- description: Localized "country_select" helper with Rake task for downloading locales
53
- from Unicode.org's CLDR
52
+ description: ! ' Localized "country_select" helper with Rake task for downloading
53
+ locales from Unicode.org''s CLDR '
54
54
  email:
55
+ -
55
56
  - maciej@litwiniuk.net
57
+ -
58
+ -
59
+ -
60
+ -
61
+ -
56
62
  executables: []
57
63
  extensions: []
58
64
  extra_rdoc_files: []