ipgeobase 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ce8d5c88631b03539a5a393e8a7e920526c67a7
4
- data.tar.gz: 0e951f4cff52429b16210d23c4bae4318f56ecff
3
+ metadata.gz: 6b0a9873fe55d2b32189a06c9d6ce17d1b4824ae
4
+ data.tar.gz: 950a50e48909a4ab2a191c7ef7b4d3b01dec739e
5
5
  SHA512:
6
- metadata.gz: bf188c0a6b6545e9fe0990e03f65bde6b068c29503c53e4bdf2f711b37bcca01bbe5ae559bf8e1518910cb9ac2b4f93f5b110779df9cffddc0ca4591e792c1d0
7
- data.tar.gz: 085295caa836a49556318b96abd36de81ab5513c2b7197ccd974fef10fa3082546025efd0e10299db580a55eccee938a9c6e3855fd2e27aea12e9deaeaf0ad9e
6
+ metadata.gz: 6179c1222a0bb3536d1f464a367b04dc778ce8faa9b9f4a590c9dd05982cac77bc72bddcfa38f75b2f440b104a943fda052390c478e2510fa88bafa389e28bf7
7
+ data.tar.gz: 39edb192daa62a893cad0a2fd4e0d7c2e2c0ecf3c3825dc0102489e930e7ed2b8a3ed240702b680cf47aacd06ce15ee7f2c5f974df86b05e90d5f7c0d79df175
@@ -28,11 +28,13 @@ module Ipgeobase
28
28
 
29
29
  private
30
30
 
31
- def encode(api_string)
32
- if api_string.respond_to?(:encode)
33
- api_string.encode("UTF-8")
31
+ def encode(entity)
32
+ return nil if entity.nil?
33
+
34
+ if entity.respond_to?(:encode)
35
+ entity.encode("UTF-8")
34
36
  else
35
- Iconv.iconv('utf-8', 'windows-1251', api_string).first
37
+ Iconv.iconv('utf-8', 'windows-1251', entity).first
36
38
  end
37
39
  end
38
40
  end
@@ -1,3 +1,3 @@
1
1
  module Ipgeobase
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class IpMetaDataTest < TestCase
6
+ def test_should_work_with_incorrect_response
7
+ resp = %Q{<?xml version="1.0" encoding="windows-1251"?><ip-answer><ip value="127.0.0.1"><message>Not found</message></ip></ip-answer>}
8
+ meta = Ipgeobase::IpMetaData.parse(resp)
9
+ assert_equal nil, meta.city
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipgeobase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mokevnin Kirill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: happymapper
@@ -56,6 +56,7 @@ files:
56
56
  - lib/ipgeobase/version.rb
57
57
  - test/fixtures/response.xml
58
58
  - test/fixtures/response_not_utf.xml
59
+ - test/lib/ip_meta_data_test.rb
59
60
  - test/lib/ipgeobase_test.rb
60
61
  - test/test_helper.rb
61
62
  homepage: ''
@@ -77,13 +78,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  version: '0'
78
79
  requirements: []
79
80
  rubyforge_project: ipgeobase
80
- rubygems_version: 2.2.0
81
+ rubygems_version: 2.2.2
81
82
  signing_key:
82
83
  specification_version: 4
83
84
  summary: geo to ip
84
85
  test_files:
85
86
  - test/fixtures/response.xml
86
87
  - test/fixtures/response_not_utf.xml
88
+ - test/lib/ip_meta_data_test.rb
87
89
  - test/lib/ipgeobase_test.rb
88
90
  - test/test_helper.rb
89
- has_rdoc: