geoip_client 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.
@@ -11,7 +11,22 @@ module GeoIPClient
11
11
  end
12
12
 
13
13
  def self.look_up(ip)
14
- json = JSON.parse(Net::HTTP.get(URI.parse("#{@host}/json/#{ip}")))
14
+ raw = Net::HTTP.get(URI.parse("#{@host}/json/#{ip}"))
15
+ if raw == 'null'
16
+ json = {
17
+ country_code: "LO",
18
+ country_code3: "LOC",
19
+ country_name: "Localhost Country",
20
+ region: "Localhost Region",
21
+ city: "Localhost City",
22
+ latitude: 0,
23
+ longitude: 0,
24
+ dma_code: 0,
25
+ area_code: 0
26
+ }
27
+ else
28
+ json = JSON.parse(raw)
29
+ end
15
30
  json.inject({}) do |hash, (key, value)|
16
31
  hash[key.to_sym] = value
17
32
  hash
@@ -1,3 +1,3 @@
1
1
  module GeoIPClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: