ipcountry 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ipcountry +13 -0
- data/lib/ipcountry.rb +30 -11
- data/lib/ipcountry/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e7cd2da87a4288e825bbd8f34702e518775304
|
4
|
+
data.tar.gz: bfbfe3e58b80a6dd8bcb2c281443b79c06345b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b53ca649dfcee681e392a03b09361736b35807ba112c68751ecdf06a64696cd4eefab817ee8c4d5ffda484c20af545002189b38c1eecfe9a9e3b4cbfeb7c7111
|
7
|
+
data.tar.gz: dd4fa776a7d03b06560d1977523fde0d42985fd067c240592b07b349d1d688d1d4d86d8634c083d6baaa270a32f1c086959600aaab4d26b12eca4aee887f7f24
|
data/bin/ipcountry
ADDED
data/lib/ipcountry.rb
CHANGED
@@ -10,12 +10,7 @@ module Ipcountry
|
|
10
10
|
attr_accessor :result
|
11
11
|
|
12
12
|
def initialize(ip)
|
13
|
-
|
14
|
-
https = Net::HTTP.new(uri.host, uri.port)
|
15
|
-
res = https.start {
|
16
|
-
https.get(uri.request_uri)
|
17
|
-
}
|
18
|
-
|
13
|
+
res = connect(ip)
|
19
14
|
if res.code == '200'
|
20
15
|
@result = JSON.parse(res.body)
|
21
16
|
else
|
@@ -23,20 +18,44 @@ module Ipcountry
|
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
21
|
+
def status
|
22
|
+
@result['status']
|
23
|
+
end
|
24
|
+
|
25
|
+
def message
|
26
|
+
@result['message']
|
27
|
+
end
|
28
|
+
|
26
29
|
def country
|
27
|
-
@result[
|
30
|
+
@result['country']
|
28
31
|
end
|
29
32
|
|
30
|
-
def
|
31
|
-
@result[
|
33
|
+
def countrycode
|
34
|
+
@result['countryCode']
|
32
35
|
end
|
33
36
|
|
34
37
|
def isp
|
35
|
-
@result[
|
38
|
+
@result['isp']
|
36
39
|
end
|
37
40
|
|
38
41
|
def organization
|
39
|
-
@result[
|
42
|
+
@result['org']
|
43
|
+
end
|
44
|
+
|
45
|
+
def query
|
46
|
+
@result['query']
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def connect(ip)
|
52
|
+
uri = URI.parse('http://ip-api.com/json/' + ip.to_s)
|
53
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
54
|
+
http.use_ssl = true if uri.scheme == 'https'
|
55
|
+
res = http.start do |h|
|
56
|
+
h.get(uri.request_uri)
|
57
|
+
end
|
58
|
+
res
|
40
59
|
end
|
41
60
|
end
|
42
61
|
end
|
data/lib/ipcountry/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipcountry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Ohashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -41,7 +41,8 @@ dependencies:
|
|
41
41
|
description: This gem looks up ip address infomation. I use this api. http://ip-api.com/docs/api:json
|
42
42
|
email:
|
43
43
|
- yusuke@junkpiano.me
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- ipcountry
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
@@ -50,6 +51,7 @@ files:
|
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
52
53
|
- Rakefile
|
54
|
+
- bin/ipcountry
|
53
55
|
- ipcountry.gemspec
|
54
56
|
- lib/ipcountry.rb
|
55
57
|
- lib/ipcountry/version.rb
|