ipcheck 0.1.0 → 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: 8e25628359eb26fb9c8f7e6fc875b5ddf8f8fe2de67d3b69dbe5fdf232ba20e1
4
- data.tar.gz: '08520b2c923eb4485418143c7522c6434bf0d43668d179002cc6fbd308411378'
3
+ metadata.gz: bb4a3a0459354ec4404afed4d5229233bd0b3d9243e1f11aa9445a089e768cc0
4
+ data.tar.gz: a7a8e803cf14fe509233514df0ff6579ef5a742d94eaf36f88864a8d15727a3d
5
5
  SHA512:
6
- metadata.gz: d9fb9f66d4062d4e07e41b45d8bcd35eec1ca8d1e586fc2e0b646d18f99d70e166fca839593b27173eb337df085e4e2e554e43e588a91fc24e9e6393f43af1f1
7
- data.tar.gz: f15b71388873486fef42d41973f6801beb69be3ed6bee44cdc6fab704a995960ae5fc47a0918d92c114a91c41c7ebcb5f865e964a22416c79c24c21d17c2a3d3
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
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ coverage
14
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
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
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ipcheck
4
+ VERSION = '0.1.2'
5
+ 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.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zabrodin
8
8
  autorequire:
9
- bindir: bin
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:
@@ -31,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - ">="
33
47
  - !ruby/object:Gem::Version
34
- version: '3.2'
48
+ version: 3.0.0
35
49
  required_rubygems_version: !ruby/object:Gem::Requirement
36
50
  requirements:
37
51
  - - ">="