localized_country_select 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -62,19 +62,23 @@ namespace :import do
|
|
62
62
|
# ----- Parse the HTML with Hpricot ----------------------------------------
|
63
63
|
puts "... parsing the HTML file"
|
64
64
|
countries = []
|
65
|
+
imported_codes = []
|
65
66
|
doc.search("//tr").each do |row|
|
66
67
|
n = row.search("td[@class='n']")
|
67
68
|
g = row.search("td")
|
68
|
-
if n && n.inner_html =~ /NamesTerritories/ && g.count
|
69
|
+
if n && n.inner_html =~ /NamesTerritories/ && g.count>=7 && g[4].inner_html =~ /^[A-Z]{2}/
|
69
70
|
code = g[4].inner_text
|
70
|
-
code = code[-code.size, 2]
|
71
|
+
code = code[-code.size, 2].to_sym
|
71
72
|
name = row.search("td[@class='v']").inner_text
|
72
|
-
|
73
|
+
unless imported_codes.member?(code)
|
74
|
+
imported_codes << code
|
75
|
+
countries << { :code => code, :name => name.to_s }
|
76
|
+
end
|
73
77
|
print " ... #{code}: #{name}"
|
74
78
|
end
|
75
79
|
end
|
76
80
|
puts "\n\n... imported countries: #{countries.count}"
|
77
|
-
|
81
|
+
puts countries.sort{|a,b| a[:code]<=>b[:code]}.inspect
|
78
82
|
|
79
83
|
|
80
84
|
# ----- Prepare the output format ------------------------------------------
|