freegeoip-ruby 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 488dc5ae2a0914d69c223bcdc06f6dbf106aee7b
4
- data.tar.gz: f0080c20cd075c8149cdeca54f6a526ff47c16e2
3
+ metadata.gz: 93daca92561a38d16cf83f57a379dbb6f6aa33aa
4
+ data.tar.gz: 6deddb342209117eb791eb26ef698af1f06d59cd
5
5
  SHA512:
6
- metadata.gz: b27b3026805039708c607993e787d7d7b736f538a5d24e6b790ac18834001b574a6c20ef2e66a69958e99f06b74e4c23565e64239dfd8818bfb105d1528e5309
7
- data.tar.gz: 518861bde0a2b4735f52103903bd41827817732f092637335b217e385139a08eb8fc11214d2da10132d65cfe432f2563f6ffc96b92f79c30740ee8fe0bbeb04b
6
+ metadata.gz: 5db2b3c1e93ae72ddaf85471059f44ffa6f25514820c3b299a5a891437a3d9f3ead12768393d24ffc291d409610ee1fb2304aaf005644dcf98b1588521552802
7
+ data.tar.gz: 4cc4eaa998f232bd81b5c9d7b194513afbad5169945f751766f4dd71d9180c46833e0aadcff911518df829c08fd2dd1b1692c4007dd41552c16bb720124db249
data/bin/freegeoip ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "freegeoip"
4
+
5
+
6
+ case ARGV[0]
7
+ when "get"
8
+ remote = ARGV[1]
9
+
10
+ puts "Searching for: #{remote}"
11
+ puts "------------------------"
12
+
13
+ response = Freegeoip.get(remote)
14
+
15
+ puts "IP: #{response.ip}"
16
+ puts "Country code: #{response.country_code}"
17
+ puts "Country name: #{response.country_name}"
18
+ puts "Region code: #{response.region_code}"
19
+ puts "Region name: #{response.region_name}"
20
+ puts "City: #{response.city}"
21
+ puts "ZIP Code: #{response.zip_code}"
22
+ puts "Time zone: #{response.time_zone}"
23
+ puts "Latitude: #{response.latitude}"
24
+ puts "Longitude: #{response.longitude}"
25
+ puts "Metro code: #{response.metro_code}"
26
+ else
27
+ puts "Unknown command, usage: freegeoip get [IP|DOMAIN]"
28
+ end
29
+
@@ -1,11 +1,12 @@
1
1
  module Freegeoip
2
2
  class Response
3
- attr_reader :ip, :country_code, :country_name,
3
+ attr_reader :remote, :ip, :country_code, :country_name,
4
4
  :region_code, :region_name, :city, :zip_code,
5
5
  :time_zone, :latitude, :longitude, :metro_code
6
6
 
7
- def initialize(attrs)
8
- attrs.each do |key, value|
7
+ def initialize(remote, data)
8
+ @remote = remote
9
+ data.each do |key, value|
9
10
  instance_variable_set "@#{key}", value
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module Freegeoip
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/freegeoip.rb CHANGED
@@ -5,6 +5,6 @@ require "freegeoip/response"
5
5
  module Freegeoip
6
6
  def self.get(remote)
7
7
  request = Request.new(remote)
8
- Response.new(request.get)
8
+ Response.new(remote, request.get)
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freegeoip-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Chávez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,6 +68,7 @@ files:
68
68
  - README.md
69
69
  - Rakefile
70
70
  - bin/console
71
+ - bin/freegeoip
71
72
  - bin/setup
72
73
  - freegeoip.gemspec
73
74
  - lib/freegeoip.rb