where_are_you 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/lib/where_are_you.rb +8 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 458680f742353687283abe8cc40aafe1fe790d1a
|
4
|
+
data.tar.gz: f88a634aedfcc1bef0b295c3a7d9b1811907ab08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1f3c9a9f36e4be9de7905c176be38f0f71a59f45c303b7d44734139a03534faabf2c0443b0421d9dc3b2dd01937116c693308fff09174022183efa48a5a5962
|
7
|
+
data.tar.gz: b2d28906864f4037378865de9861acca2a879dd5747bc48d2c19ba098ace8bf69b97ec6cc727eaef8d2933287f5456f9e52290e46e6c3b846f55371b51aca6f9
|
data/lib/where_are_you.rb
CHANGED
@@ -3,11 +3,13 @@ class Object
|
|
3
3
|
def where_are_you(ip, format = 'city', global = false)
|
4
4
|
|
5
5
|
require 'net/http'
|
6
|
-
require 'json'
|
6
|
+
require 'json'
|
7
|
+
require 'yaml'
|
7
8
|
|
8
9
|
uri = URI.parse("http://ip-api.com/json/#{ip}")
|
9
10
|
response = Net::HTTP.get_response(uri)
|
10
11
|
result = JSON(response.body)
|
12
|
+
data = YAML::load_file(File.dirname(__FILE__) + '/data.yml')
|
11
13
|
|
12
14
|
if result['status'] != 'success'
|
13
15
|
|
@@ -33,7 +35,11 @@ class Object
|
|
33
35
|
|
34
36
|
return result['country']
|
35
37
|
|
36
|
-
|
38
|
+
elsif format == 'language'
|
39
|
+
|
40
|
+
formatted_country = result['country'].downcase.gsub(' ','_').gsub(',','_')
|
41
|
+
return data[formatted_country]
|
37
42
|
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_are_you
|
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
|
- Stelios Constantinides
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Returns the city, state, or
|
13
|
+
description: Returns the city, state, country, or language for the current user using
|
14
|
+
IP-API.com.
|
14
15
|
email: sconstantinides@gmail.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
@@ -40,5 +41,5 @@ rubyforge_project:
|
|
40
41
|
rubygems_version: 2.2.2
|
41
42
|
signing_key:
|
42
43
|
specification_version: 4
|
43
|
-
summary: Returns the city, state, or
|
44
|
+
summary: Returns the city, state, country, or language for the current user.
|
44
45
|
test_files: []
|