ipcheck 0.1.1 → 1.1.0

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: ab23a1a2feb30858b30bc2fee4aedb743431e2ef68722105b91a2fcef650f999
4
- data.tar.gz: b8a4917f735aee92c27781742e9b9b72d9436be60d9e13c13d979da538f887f8
3
+ metadata.gz: 5d45c3ce454d64a2c69607e152f42be6827729531a8b509f5ac0295588146b68
4
+ data.tar.gz: 862ef643791b14b4fc13c0b37a391fafcfe0eb605dcb9d911267a8bb0ea5f498
5
5
  SHA512:
6
- metadata.gz: f51756748210a991579a2d02b262589be8f1adec376a1ccfef56e11bcd91acd1b9a696016f5484433e540fe2549e943a6da612710bab31121c0d8265776cf7fa
7
- data.tar.gz: e09900c0fb4d7afdc78b4a2a2840f167ac69ab957bc172b6c48aefa0d549463ea15fd03c710b1eea748ea2c32bb20f8fa0afc11ef8f8a3f6586f11eadc413e64
6
+ metadata.gz: 6cef0cbcfe3d9c57743ab0e3ed5698517c22e017708722dbc31ee40badb5cc0a0cb27b73dd8c41ae068a9d8ca0fef1b9ada5185c4e4ad03d003684727a34e098
7
+ data.tar.gz: ea219e042de3e94a32a79ee475637bbf0a23c38712226f406833211e07a94f70dbf8c77ef314d77f1425a1c8c5e8c12521267cdb16f87035d747c4dd8c160820
@@ -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,20 @@
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
18
+
19
+ Metrics/BlockLength:
20
+ AllowedMethods: ['describe', 'context']
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 (1.1.0)
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,45 @@
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
+ my_ip = Ipcheck.my_ip # 169.254.1.2
28
+
29
+ ip_meta = Ipcheck.lookup('8.8.8.8')
30
+ ip_meta.city # Ashburn
31
+ ip_meta.country # United States
32
+ ip_meta.countryCode # US
33
+ ip_meta.lat # 39.03
34
+ ip_meta.lon # -77.5
35
+ ```
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ 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 = '1.1.0'
5
+ end
data/lib/ipcheck.rb ADDED
@@ -0,0 +1,22 @@
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
+
18
+ def self.my_ip
19
+ url = 'https://api64.ipify.org'
20
+ URI.parse(url).read
21
+ end
22
+ 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.1
4
+ version: 1.1.0
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: