ipaddresslabs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -2
- data/lib/ipaddresslabs.rb +2 -1
- data/lib/ipaddresslabs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edcb446b85012727c94b6bc86719a3c6c74135c8
|
4
|
+
data.tar.gz: ec58f3157b418aae9c31c5f375c15d6e1c9ee377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae683634fd6cebaadc156e626485eae692265d779156e3b8c00f0a6162a42965f89d2336aff285290a48124cd1f6499e8e38395f361f98033e920557f389b065
|
7
|
+
data.tar.gz: 13d0badeb0f336d9edda6063ebe74e3145db4d3505ae63c7d033be1522df0cb84a5d5cf55b207b2aa131ad71a5c3a22f2bf31515ce235d195e462b5236320f71
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Ipaddresslabs
|
4
4
|
|
5
|
-
|
5
|
+
Any available API in the world deserves a wrapper gem right?
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -20,7 +20,51 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
You can call ```locate``` method like this:
|
24
|
+
|
25
|
+
Ipaddresslabs.locate("177.142.170.45")
|
26
|
+
|
27
|
+
And it will return a JSON object like this:
|
28
|
+
|
29
|
+
{
|
30
|
+
"query_status" : {
|
31
|
+
"query_status_code" : "OK",
|
32
|
+
"query_status_description" : "Query successfully performed."
|
33
|
+
},
|
34
|
+
"ip_address" : "177.142.170.45",
|
35
|
+
"geolocation_data" : {
|
36
|
+
"continent_code" : "SA",
|
37
|
+
"continent_name" : "South America",
|
38
|
+
"country_code_iso3166alpha3" : "BRA",
|
39
|
+
"country_code_iso3166alpha2" : "BR",
|
40
|
+
"country_code_iso3166numeric" : "76",
|
41
|
+
"country_code_fips10-4" : "BR",
|
42
|
+
"country_name" : "Brazil",
|
43
|
+
"region_code" : "BR21",
|
44
|
+
"region_name" : "Rio de Janeiro",
|
45
|
+
"city" : "Rio De Janeiro",
|
46
|
+
"postal_code" : "-",
|
47
|
+
"metro_code" : "-",
|
48
|
+
"area_code" : "-",
|
49
|
+
"latitude" : -22.9,
|
50
|
+
"longitude" : -43.2333,
|
51
|
+
"isp" : "Virtua",
|
52
|
+
"organization" : "Virtua"
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
You need to set an environment variable to get this work:
|
57
|
+
|
58
|
+
ENV["IPADDRESSLABS_KEY"] = "your_ipaddresslabs_key"
|
59
|
+
|
60
|
+
Or set in secrets.yml file
|
61
|
+
|
62
|
+
development:
|
63
|
+
ipaddresslabs_key: your_ipaddresslabs_key
|
64
|
+
test:
|
65
|
+
ipaddresslabs_key: your_ipaddresslabs_key
|
66
|
+
production:
|
67
|
+
ipaddresslabs_key: your_ipaddresslabs_key
|
24
68
|
|
25
69
|
## Contributing
|
26
70
|
|
data/lib/ipaddresslabs.rb
CHANGED
@@ -3,7 +3,8 @@ require "httparty"
|
|
3
3
|
|
4
4
|
module Ipaddresslabs
|
5
5
|
def self.locate ip
|
6
|
-
|
6
|
+
key = Rails.application.secrets.ipaddresslabs_key || ENV["IPADDRESSLABS_KEY"]
|
7
|
+
result = HTTParty.get("http://api.ipaddresslabs.com/iplocation/v1.8/locateip?key=#{key}&ip=#{ip}&format=JSON&compact=Y")
|
7
8
|
JSON.parse(result.body)
|
8
9
|
end
|
9
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipaddresslabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nícolas Iensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.4.5
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Gem wrapper for the ipaddresslabs.com API
|