get_geo 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: '009f2720ec887d929f43f17013636d30004ef71534657b485837c8c7423a373b'
4
- data.tar.gz: 350bd4d6547b3114cdd14ff7a263c9e9e01980a109b43594c803a37f77be71de
3
+ metadata.gz: c72710f5a2bd94baa2a8890a4157c34cea2d0c7a92abd9263e499bdca3dc8601
4
+ data.tar.gz: 9c44cc92cf1410d52122c4a48ece9ee0ab914865ae25626412e20e2f182a8134
5
5
  SHA512:
6
- metadata.gz: 6dd878e1de115dc868014e6b1e4ecc6686c7c5dd996ad60e58492db145cb590b7b2fa8635eca6f95001d2e1ffb3f7133f6b52c179eb5bb5ced95481f58943a75
7
- data.tar.gz: 416d266e0f8ece2de2b51f473b48e9888bde92e121855e9438f224bc8edc6c3c7760ea50cc2a1896b552b419c4ef67c43f074f5b76045070efd8f2e9cb42e7bf
6
+ metadata.gz: 346482133700fd25c31d5da6956c770a92d01c209e9faa9df1a10698c3b472a7efa8cab6c1dc250ff468b8127c57612e52676ecc50ec04dc0441627f4315a53e
7
+ data.tar.gz: d0a5547e490d109ee93500a31a82d3bf761592494621e2db1442b5887b947d6dde497ce4d78ad22998040493f5007a0a8eb5a6efb67e9f804a6ab2fa6f5f295d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- get_geo (0.1.0)
4
+ get_geo (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -17,6 +17,7 @@ GEM
17
17
  builder (3.2.3)
18
18
  childprocess (1.0.1)
19
19
  rake (< 13.0)
20
+ coderay (1.1.2)
20
21
  contracts (0.16.0)
21
22
  cucumber (3.1.2)
22
23
  builder (>= 2.1.2)
@@ -37,8 +38,12 @@ GEM
37
38
  diff-lcs (1.3)
38
39
  ffi (1.10.0)
39
40
  gherkin (5.1.0)
41
+ method_source (0.9.2)
40
42
  multi_json (1.13.1)
41
43
  multi_test (0.1.2)
44
+ pry (0.12.2)
45
+ coderay (~> 1.1.0)
46
+ method_source (~> 0.9.0)
42
47
  rake (10.5.0)
43
48
  rspec (3.8.0)
44
49
  rspec-core (~> 3.8.0)
@@ -63,6 +68,7 @@ DEPENDENCIES
63
68
  bundler (~> 1.17)
64
69
  cucumber
65
70
  get_geo!
71
+ pry
66
72
  rake (~> 10.0)
67
73
  rspec (~> 3.0)
68
74
 
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # GetGeo
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/get_geo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
2
+ With GetGeo you can get information about your IP via [http://ip-api.com](http://ip-api.com).
6
3
 
7
4
  ## Installation
8
5
 
@@ -21,8 +18,24 @@ Or install it yourself as:
21
18
  $ gem install get_geo
22
19
 
23
20
  ## Usage
21
+ ```
22
+ # argument is ip, if it is not passed, result will be for your current ip
23
+ geo_data = GetGeo.get_data('217.66.24.134')
24
+ geo_data.city # => Kazan’
25
+ geo_data.country # => Russia
26
+ ```
27
+
28
+ Gem has cli:
29
+ ```
30
+ $ geo-get 217.66.24.134
31
+ --- GetGeo ---
32
+ city: Kazan’
33
+ country: Russia
34
+ lat: 55.7897
35
+ lon: 49.1571
36
+ query: 217.66.24.134
37
+ ```
24
38
 
25
- TODO: Write usage instructions here
26
39
 
27
40
  ## Development
28
41
 
@@ -32,4 +45,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
45
 
33
46
  ## Contributing
34
47
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/get_geo.
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eldarik/get_geo.
data/bin/get-geo CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+ require "bundler/setup"
3
3
  require 'get_geo/cli'
4
4
 
5
5
  ip = ARGV[0]
data/get_geo.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rspec", "~> 3.0"
28
28
  spec.add_development_dependency "cucumber"
29
29
  spec.add_development_dependency "aruba"
30
+ spec.add_development_dependency "pry"
30
31
  end
data/lib/get_geo.rb CHANGED
@@ -2,8 +2,14 @@ require 'get_geo/version'
2
2
  require 'get_geo/data'
3
3
  require 'get_geo/printer'
4
4
  require 'get_geo/printer/cli'
5
+ require 'get_geo/data_requester'
5
6
 
6
7
  module GetGeo
7
8
  class Error < StandardError; end
8
9
  # Your code goes here...
10
+
11
+ def self.get_data(ip = nil)
12
+ data = ::GetGeo::DataRequester.new.execute(ip)
13
+ ::GetGeo::Data.new(data)
14
+ end
9
15
  end
data/lib/get_geo/cli.rb CHANGED
@@ -1,7 +1,10 @@
1
+ require 'get_geo'
2
+
1
3
  module GetGeo
2
4
  module CLI
3
5
  def self.start(ip)
4
- puts 'City'
6
+ geo_data = ::GetGeo.get_data(ip)
7
+ GetGeo::Printer::CLI.new(geo_data).print
5
8
  end
6
9
  end
7
10
  end
@@ -0,0 +1,13 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+
4
+ class GetGeo::DataRequester
5
+ BASE_URL = 'http://ip-api.com/json'
6
+
7
+ def execute(ip = nil)
8
+ url = BASE_URL
9
+ url = "#{url}/#{ip}" if ip
10
+ response_body = OpenURI.open_uri(url).read
11
+ JSON.parse(response_body).transform_keys(&:to_sym)
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module GetGeo
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eldar Iskhakov
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: GetGeo For workshop OOP
84
98
  email:
85
99
  - iskhakov.eldar95@gmail.com
@@ -104,6 +118,7 @@ files:
104
118
  - lib/get_geo.rb
105
119
  - lib/get_geo/cli.rb
106
120
  - lib/get_geo/data.rb
121
+ - lib/get_geo/data_requester.rb
107
122
  - lib/get_geo/printer.rb
108
123
  - lib/get_geo/printer/cli.rb
109
124
  - lib/get_geo/version.rb