Pr0d1r2-geokit 1.3.2.8 → 1.3.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/geokit/cached/model.rb +11 -1
  2. metadata +1 -1
@@ -14,12 +14,13 @@ module Geokit
14
14
 
15
15
  def cache!(attributes)
16
16
  self.attributes = attributes
17
+ self.city = convert_to_utf8(self.city)
17
18
  save if new_record? || changed?
18
19
  end
19
20
 
20
21
  def update!
21
22
  if !by_google? && geo.success
22
- self.lat, self.lng, self.provider, self.city = geo.lat, geo.lng, geo.provider, geo.city
23
+ self.lat, self.lng, self.provider, self.city = geo.lat, geo.lng, geo.provider, convert_to_utf8(geo.city)
23
24
  save if changed?
24
25
  end
25
26
  end
@@ -67,6 +68,15 @@ module Geokit
67
68
  !!(lat and lng)
68
69
  end
69
70
 
71
+ def convert_to_utf8(str)
72
+ begin
73
+ Iconv.new('UTF-8', 'UTF-8').iconv(str)
74
+ rescue Iconv::Failure => iconv_exception
75
+ Iconv.new('UTF-8', 'ISO-8859-1').iconv(str)
76
+ iconv_exception.success
77
+ end
78
+ end
79
+
70
80
  end
71
81
  end
72
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Pr0d1r2-geokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2.8
4
+ version: 1.3.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Lewis and Bill Eisenhauer and Pr0d1r2 (Marcin Nowicki)