ipgeobase 0.1.0 → 0.1.1

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: a5fd94751a091e9f684b217975349e98e6708aeb
4
- data.tar.gz: 92fd18fe2d5cb2c7765e981cb079c998b020aff0
3
+ metadata.gz: 8ce8d5c88631b03539a5a393e8a7e920526c67a7
4
+ data.tar.gz: 0e951f4cff52429b16210d23c4bae4318f56ecff
5
5
  SHA512:
6
- metadata.gz: 4e49790ef3ecb36d23c3adbf0fcd08e8ed6af2e48d9120a8b721fe5b4b350a3139b1f15c539d6c81f50b837d92b77e21c013ddb871dc7287a2fd8a8ba44cdbde
7
- data.tar.gz: d3f5a30da27fbbf270204ea9f83dede310690e5ac530ff58958af94de0ee2bcc7884128b10195aa8f4ef066707b8c6df602e02980bc480be4c70706f0e8660a3
6
+ metadata.gz: bf188c0a6b6545e9fe0990e03f65bde6b068c29503c53e4bdf2f711b37bcca01bbe5ae559bf8e1518910cb9ac2b4f93f5b110779df9cffddc0ca4591e792c1d0
7
+ data.tar.gz: 085295caa836a49556318b96abd36de81ab5513c2b7197ccd974fef10fa3082546025efd0e10299db580a55eccee938a9c6e3855fd2e27aea12e9deaeaf0ad9e
data/README.md CHANGED
@@ -40,3 +40,7 @@ run tests:
40
40
 
41
41
  turn -Itest test/lib
42
42
 
43
+
44
+
45
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mokevnin/ipgeobase/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
46
+
data/lib/ipgeobase.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'uri'
2
- require 'net/http'
2
+ require 'open-uri'
3
3
 
4
4
  module Ipgeobase
5
5
  URL = 'http://ipgeobase.ru:7020/geo'
@@ -8,7 +8,7 @@ module Ipgeobase
8
8
  def self.lookup(ip)
9
9
  uri = URI.parse(URL)
10
10
  uri.query = URI.encode_www_form :ip => ip
11
-
12
- IpMetaData.parse(Net::HTTP.get(uri))
11
+ resp = open(uri).read()
12
+ IpMetaData.parse(resp.to_s)
13
13
  end
14
14
  end
@@ -30,9 +30,9 @@ module Ipgeobase
30
30
 
31
31
  def encode(api_string)
32
32
  if api_string.respond_to?(:encode)
33
- api_string.encode
33
+ api_string.encode("UTF-8")
34
34
  else
35
- Iconv.iconv('windows-1251', 'utf-8', api_string).first
35
+ Iconv.iconv('utf-8', 'windows-1251', api_string).first
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Ipgeobase
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="windows-1251"?>
2
+ <ip-answer>
3
+ <ip value="46.8.114.116">
4
+ <inetnum>46.8.112.0 - 46.8.127.255</inetnum>
5
+ <country>RU</country>
6
+ <city>���������</city>
7
+ <region>����������� �������</region>
8
+ <district>����������� ����������� �����</district>
9
+ <lat>54.321480</lat>
10
+ <lng>48.385651</lng>
11
+ </ip>
12
+ </ip-answer>
@@ -1,3 +1,5 @@
1
+ #encoding: utf-8
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class IpgeobaseTest < TestCase
@@ -5,7 +7,7 @@ class IpgeobaseTest < TestCase
5
7
  @ip = '46.8.114.116'
6
8
  @stub = stub_request(:get, "#{Ipgeobase::URL}?ip=#{@ip}").
7
9
  with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
8
- to_return(:status => 200, :body => load_fixture('response.xml'), :headers => {})
10
+ to_return(:status => 200, :body => load_fixture('response_not_utf.xml'), :headers => {})
9
11
  end
10
12
 
11
13
  def test_lookup_http_query
@@ -19,4 +21,10 @@ class IpgeobaseTest < TestCase
19
21
 
20
22
  assert_equal 54.321480, meta.lat
21
23
  end
24
+
25
+ def test_should_encode_to_utf8
26
+ meta = Ipgeobase.lookup @ip
27
+
28
+ assert_equal "Ульяновск", meta.city
29
+ end
22
30
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipgeobase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mokevnin Kirill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: happymapper
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: iconv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: geo to ip
@@ -45,8 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .coveralls.yml
49
- - .gitignore
48
+ - ".coveralls.yml"
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - README.md
52
52
  - Rakefile
@@ -55,6 +55,7 @@ files:
55
55
  - lib/ipgeobase/ip_meta_data.rb
56
56
  - lib/ipgeobase/version.rb
57
57
  - test/fixtures/response.xml
58
+ - test/fixtures/response_not_utf.xml
58
59
  - test/lib/ipgeobase_test.rb
59
60
  - test/test_helper.rb
60
61
  homepage: ''
@@ -66,21 +67,23 @@ require_paths:
66
67
  - lib
67
68
  required_ruby_version: !ruby/object:Gem::Requirement
68
69
  requirements:
69
- - - '>='
70
+ - - ">="
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
- - - '>='
75
+ - - ">="
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
79
  rubyforge_project: ipgeobase
79
- rubygems_version: 2.0.4
80
+ rubygems_version: 2.2.0
80
81
  signing_key:
81
82
  specification_version: 4
82
83
  summary: geo to ip
83
84
  test_files:
84
85
  - test/fixtures/response.xml
86
+ - test/fixtures/response_not_utf.xml
85
87
  - test/lib/ipgeobase_test.rb
86
88
  - test/test_helper.rb
89
+ has_rdoc: