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.
@@ -22,7 +22,7 @@ See http://github.com/rails/country_select/tree/master/lib/country_select.rb
22
22
 
23
23
  In your Gemfile add:
24
24
 
25
- gem 'localized_country_select', '>= 0.9.5'
25
+ gem 'localized_country_select', '>= 0.9.6'
26
26
 
27
27
  == Rails 2.3
28
28
 
@@ -1,3 +1,3 @@
1
1
  module LocalizedCountrySelect
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
@@ -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==7 && g[4].inner_html =~ /^[A-Z]{2}/
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
- countries << { :code => code.to_sym, :name => name.to_s }
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
- #puts countries.sort{|a,b| a[:code]<=>b[:code]}.inspect
81
+ puts countries.sort{|a,b| a[:code]<=>b[:code]}.inspect
78
82
 
79
83
 
80
84
  # ----- Prepare the output format ------------------------------------------
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.5
4
+ version: 0.9.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: