where_are_you 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/where_are_you.rb +8 -2
  3. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20c0a75e05b536627926b02983a1b04d5204968b
4
- data.tar.gz: 0a9445e07675d1142563eb929d6f559a1c5d7ea7
3
+ metadata.gz: 458680f742353687283abe8cc40aafe1fe790d1a
4
+ data.tar.gz: f88a634aedfcc1bef0b295c3a7d9b1811907ab08
5
5
  SHA512:
6
- metadata.gz: 28cb6dd0b0d997831412985280d6d052b353b29b22eef3fb48677c196ce42f21c06d70e5f384cc9e7ae7881d62023aaa313f9c71258e73b4f3954111f47c3908
7
- data.tar.gz: 6b301d9dc82eb19a97d470418760213f7120a48ae997a7b7f7a0cd44fd1a4d2d2e0ce3a5eaf95338a9e0a6e33acc5b1848d2a61b010782d9e0c7ec66f80fd837
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' # already included in Rails
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
- end
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.1
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-07-16 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Returns the city, state, or country for the current user using IP-API.com.
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 country for the current user.
44
+ summary: Returns the city, state, country, or language for the current user.
44
45
  test_files: []