ipaddresslabs 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa362b22076b67768e8a34f82a31575e962d61af
4
- data.tar.gz: 29de1cd294df9e6200ae8ad193b65a0a1f7a0d68
3
+ metadata.gz: edcb446b85012727c94b6bc86719a3c6c74135c8
4
+ data.tar.gz: ec58f3157b418aae9c31c5f375c15d6e1c9ee377
5
5
  SHA512:
6
- metadata.gz: a7671a9aca1fafb2a932d677c7915451c7a58a589e6eb2cada7d783fe96bed19d0041f23f9b1acfbe443e6805e32959db32bb440c676d5fc5bd3a11038753bf4
7
- data.tar.gz: bf130fcfbc73fcae17c50c80257504ab031cd24c6bb076bd651f92f3acd36f1bb38bdd33971ae1a5b36c69e120a41ee1640e59522b63fec2d8665af8722995f7
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
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
- result = HTTParty.get("http://api.ipaddresslabs.com/iplocation/v1.7/locateip?key=#{ENV["IPADDRESSLABS_KEY"]}&ip=#{ip}&format=JSON")
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
@@ -1,3 +1,3 @@
1
1
  module Ipaddresslabs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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: 2014-03-26 00:00:00.000000000 Z
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.2.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