ipcheck 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 +4 -4
- data/.github/workflows/main.yml +27 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +89 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/ipcheck.gemspec +30 -0
- data/lib/ipcheck/metadata.rb +16 -0
- data/lib/ipcheck/version.rb +5 -0
- data/lib/ipcheck.rb +17 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4a3a0459354ec4404afed4d5229233bd0b3d9243e1f11aa9445a089e768cc0
|
4
|
+
data.tar.gz: a7a8e803cf14fe509233514df0ff6579ef5a742d94eaf36f88864a8d15727a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d417b2272b8e91f70bc7494fd3e585fdbdbfa80067e2d46df2e2e2ae530adf21e1fbd1d6d16b32bf20a579f846b938db53d562512fce3650ce2ab7cd883b6c
|
7
|
+
data.tar.gz: c0b9b2bc894db753e51b932b233412de4c0bf97a602c41a3fb6fc8ceb5db17adb50628beeececaf8ca89eb26c2cdac1e696aa6ad0d738ffb802224bf666bb570
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- '3.0.0'
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v4
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Run the default task
|
27
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 3.0.0
|
4
|
+
|
5
|
+
Style/StringLiterals:
|
6
|
+
Enabled: true
|
7
|
+
EnforcedStyle: single_quotes
|
8
|
+
|
9
|
+
Style/StringLiteralsInInterpolation:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: single_quotes
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in ipcheck.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'nokogiri-happymapper', require: 'happymapper'
|
9
|
+
gem 'rake', '~> 13.0'
|
10
|
+
gem 'rubocop', '~> 1.21'
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'rspec', '~> 3.0'
|
14
|
+
gem 'simplecov', require: false
|
15
|
+
gem 'webmock'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ipcheck (0.1.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.8.6)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
11
|
+
ast (2.4.2)
|
12
|
+
bigdecimal (3.1.6)
|
13
|
+
crack (1.0.0)
|
14
|
+
bigdecimal
|
15
|
+
rexml
|
16
|
+
diff-lcs (1.5.1)
|
17
|
+
docile (1.4.0)
|
18
|
+
hashdiff (1.1.0)
|
19
|
+
json (2.7.1)
|
20
|
+
language_server-protocol (3.17.0.3)
|
21
|
+
mini_portile2 (2.8.5)
|
22
|
+
nokogiri (1.16.2)
|
23
|
+
mini_portile2 (~> 2.8.2)
|
24
|
+
racc (~> 1.4)
|
25
|
+
nokogiri-happymapper (0.10.0)
|
26
|
+
nokogiri (~> 1.5)
|
27
|
+
parallel (1.24.0)
|
28
|
+
parser (3.3.0.5)
|
29
|
+
ast (~> 2.4.1)
|
30
|
+
racc
|
31
|
+
public_suffix (5.0.4)
|
32
|
+
racc (1.7.3)
|
33
|
+
rainbow (3.1.1)
|
34
|
+
rake (13.1.0)
|
35
|
+
regexp_parser (2.9.0)
|
36
|
+
rexml (3.2.6)
|
37
|
+
rspec (3.13.0)
|
38
|
+
rspec-core (~> 3.13.0)
|
39
|
+
rspec-expectations (~> 3.13.0)
|
40
|
+
rspec-mocks (~> 3.13.0)
|
41
|
+
rspec-core (3.13.0)
|
42
|
+
rspec-support (~> 3.13.0)
|
43
|
+
rspec-expectations (3.13.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-mocks (3.13.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.13.0)
|
49
|
+
rspec-support (3.13.0)
|
50
|
+
rubocop (1.60.2)
|
51
|
+
json (~> 2.3)
|
52
|
+
language_server-protocol (>= 3.17.0)
|
53
|
+
parallel (~> 1.10)
|
54
|
+
parser (>= 3.3.0.2)
|
55
|
+
rainbow (>= 2.2.2, < 4.0)
|
56
|
+
regexp_parser (>= 1.8, < 3.0)
|
57
|
+
rexml (>= 3.2.5, < 4.0)
|
58
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
59
|
+
ruby-progressbar (~> 1.7)
|
60
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
61
|
+
rubocop-ast (1.30.0)
|
62
|
+
parser (>= 3.2.1.0)
|
63
|
+
ruby-progressbar (1.13.0)
|
64
|
+
simplecov (0.22.0)
|
65
|
+
docile (~> 1.1)
|
66
|
+
simplecov-html (~> 0.11)
|
67
|
+
simplecov_json_formatter (~> 0.1)
|
68
|
+
simplecov-html (0.12.3)
|
69
|
+
simplecov_json_formatter (0.1.4)
|
70
|
+
unicode-display_width (2.5.0)
|
71
|
+
webmock (3.20.0)
|
72
|
+
addressable (>= 2.8.0)
|
73
|
+
crack (>= 0.3.2)
|
74
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
75
|
+
|
76
|
+
PLATFORMS
|
77
|
+
ruby
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
ipcheck!
|
81
|
+
nokogiri-happymapper
|
82
|
+
rake (~> 13.0)
|
83
|
+
rspec (~> 3.0)
|
84
|
+
rubocop (~> 1.21)
|
85
|
+
simplecov
|
86
|
+
webmock
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
2.5.6
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Ipcheck
|
2
|
+
|
3
|
+
![Gem Version](https://img.shields.io/gem/v/ipcheck)
|
4
|
+
[![Ruby](https://github.com/EvanBrightside/ipcheck/actions/workflows/main.yml/badge.svg)](https://github.com/EvanBrightside/ipcheck/actions/workflows/main.yml)
|
5
|
+
|
6
|
+
This gem allows you to obtain information via IP - for example, country, city, coordinates.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'ipcheck'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install ipcheck
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
ip_meta = Ipcheck.lookup('8.8.8.8')
|
28
|
+
ip_meta.city # Ashburn
|
29
|
+
ip_meta.country # United States
|
30
|
+
ip_meta.countryCode # US
|
31
|
+
ip_meta.lat # 39.03
|
32
|
+
ip_meta.lon # -77.5
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/EvanBrightside/ipcheck.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'ipcheck'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require 'irb'
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/ipcheck.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/ipcheck/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'ipcheck'
|
7
|
+
spec.version = Ipcheck::VERSION
|
8
|
+
spec.authors = ['Ivan Zabrodin']
|
9
|
+
spec.email = ['xvanx84@gmail.com']
|
10
|
+
spec.summary = 'Check IP geolocation'
|
11
|
+
spec.description = 'Check IP geolocation with https://ip-api.com'
|
12
|
+
spec.homepage = 'https://github.com/EvanBrightside/ipcheck'
|
13
|
+
spec.required_ruby_version = '>= 3.0.0'
|
14
|
+
|
15
|
+
spec.metadata = {
|
16
|
+
'rubygems_mfa_required' => 'true',
|
17
|
+
'source_code_uri' => 'https://github.com/EvanBrightside/ipcheck',
|
18
|
+
'changelog_uri' => 'https://github.com/EvanBrightside/ipcheck'
|
19
|
+
}
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'happymapper'
|
4
|
+
|
5
|
+
module Ipcheck
|
6
|
+
class Metadata
|
7
|
+
include HappyMapper
|
8
|
+
|
9
|
+
tag 'query'
|
10
|
+
element :city, String, tag: 'city'
|
11
|
+
element :country, String, tag: 'country'
|
12
|
+
element :countryCode, String, tag: 'countryCode'
|
13
|
+
element :lat, Float, tag: 'lat'
|
14
|
+
element :lon, Float, tag: 'lon'
|
15
|
+
end
|
16
|
+
end
|
data/lib/ipcheck.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require_relative 'ipcheck/version'
|
5
|
+
require_relative 'ipcheck/metadata'
|
6
|
+
|
7
|
+
module Ipcheck
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.lookup(ip_address)
|
11
|
+
return raise Error, 'Invalid IP address format' unless ip_address.match?(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
|
12
|
+
|
13
|
+
url = "http://ip-api.com/xml/#{ip_address}"
|
14
|
+
response = URI.parse(url).read
|
15
|
+
Metadata.parse(response)
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipcheck
|
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
|
- Ivan Zabrodin
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
@@ -16,7 +16,21 @@ email:
|
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
|
-
files:
|
19
|
+
files:
|
20
|
+
- ".github/workflows/main.yml"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/console
|
29
|
+
- bin/setup
|
30
|
+
- ipcheck.gemspec
|
31
|
+
- lib/ipcheck.rb
|
32
|
+
- lib/ipcheck/metadata.rb
|
33
|
+
- lib/ipcheck/version.rb
|
20
34
|
homepage: https://github.com/EvanBrightside/ipcheck
|
21
35
|
licenses: []
|
22
36
|
metadata:
|