DataIp 0.0.1
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 +7 -0
- data/lib/DataIp.rb +24 -0
- data/lib/Fregoo.rb +40 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5007f7a679040200973b75e4d606068ffc56bd3
|
4
|
+
data.tar.gz: b5fa541bbb435fc9cfdae639519750ddabe7d341
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6742d9afd2c07da721341a8766cb184a9990352586135f53d04af855b714dfa82313808a23364d9b53f374f42957f30e82417f4e7adc0f9fe2804498148a2dbb
|
7
|
+
data.tar.gz: 76ee064bc354722a2dd76a3b92c17f1dda1a61b1255b120f7dfeeb8926fe696c67e54bfebcbf0d1f28c533c467f5fedd64b440e689c56121dfbe6a8e87763c2f
|
data/lib/DataIp.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class DataIp
|
2
|
+
|
3
|
+
attr_accessor :ip,:country_code,:country_name, :region_code,:region_name, :city,:zip_code, :time_zone,:latitude,:longitude,:metro_code
|
4
|
+
|
5
|
+
def initialize(hash)
|
6
|
+
p hash
|
7
|
+
@ip = hash["ip"]
|
8
|
+
@country_name = hash["country_name"]
|
9
|
+
@country_code = hash["country_code"]
|
10
|
+
@region_code = hash["region_code"]
|
11
|
+
@region_name = hash["region_name"]
|
12
|
+
@city = hash["city"]
|
13
|
+
@zip_code = hash["zip_code"]
|
14
|
+
@time_zone = hash["time_zone"]
|
15
|
+
@latitude = hash["latitude"]
|
16
|
+
@longitude = hash["longitude"]
|
17
|
+
@metro_code = hash["metro_code"]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
data/lib/Fregoo.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require_relative 'DataIp'
|
5
|
+
|
6
|
+
class Fregoo
|
7
|
+
attr_accessor :hash
|
8
|
+
|
9
|
+
def initialize(url)
|
10
|
+
go_url(url)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
private
|
16
|
+
def go_url(url)
|
17
|
+
open('http://freegeoip.net/json/' + url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def open(url)
|
21
|
+
url = Net::HTTP.get(URI.parse(url))
|
22
|
+
parse_url url
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse_url(url)
|
26
|
+
@hash = JSON.parse url
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
fregoo = Fregoo.new('www.github.com')
|
32
|
+
obj = DataIp.new(fregoo.hash)
|
33
|
+
p obj.ip
|
34
|
+
p obj.longitude
|
35
|
+
p obj.time_zone
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DataIp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Omaury Marmolejo
|
8
|
+
- Gabriel Verduzco
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Data
|
15
|
+
email:
|
16
|
+
- vmarmolejo@gmail.com
|
17
|
+
- verduzcogab@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/DataIp.rb
|
23
|
+
- lib/Fregoo.rb
|
24
|
+
homepage: http://rubygems.org/gems/hola
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.6.10
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: This gem can get the data using an API
|
48
|
+
test_files: []
|