get_geo 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/README.md +19 -6
- data/bin/get-geo +1 -1
- data/get_geo.gemspec +1 -0
- data/lib/get_geo.rb +6 -0
- data/lib/get_geo/cli.rb +4 -1
- data/lib/get_geo/data_requester.rb +13 -0
- data/lib/get_geo/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72710f5a2bd94baa2a8890a4157c34cea2d0c7a92abd9263e499bdca3dc8601
|
4
|
+
data.tar.gz: 9c44cc92cf1410d52122c4a48ece9ee0ab914865ae25626412e20e2f182a8134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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/
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/eldarik/get_geo.
|
data/bin/get-geo
CHANGED
data/get_geo.gemspec
CHANGED
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
@@ -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
|
data/lib/get_geo/version.rb
CHANGED
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.
|
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
|