ipis 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8b5d766ffeeb74812d8d5b892e65a7986c36d07e8df0deaea58539bc9eb2b679
4
+ data.tar.gz: 72523ff66eeb28ea8d41bf3a98d5a0eecf7e3aa34bb524264b0c8bddd196c7f4
5
+ SHA512:
6
+ metadata.gz: f4af34cfc8b17f0d8418ea7426deebb67a8fc5a1ec3ca8761a39a7fecd82b170e21755b71d19e8650e3d327aa55d6100d3e760ea2eef4c4235f6e67442032ca8
7
+ data.tar.gz: 8930dd11d6ba4208d3cb39d14cd543d17722bb9c93ea30ecd849906b8b4287cdb58f3fe7ae0a6e650b247c4cce5b6a80db0fdee10e8fff3c13107b19fa207613
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ipis.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ipis (0.1.0)
5
+ http
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ domain_name (0.5.20180417)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ http (4.0.3)
15
+ addressable (~> 2.3)
16
+ http-cookie (~> 1.0)
17
+ http-form_data (~> 2.0)
18
+ http_parser.rb (~> 0.6.0)
19
+ http-cookie (1.0.3)
20
+ domain_name (~> 0.5)
21
+ http-form_data (2.1.1)
22
+ http_parser.rb (0.6.0)
23
+ public_suffix (3.0.3)
24
+ rake (10.5.0)
25
+ unf (0.1.4)
26
+ unf_ext
27
+ unf_ext (0.0.7.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 2.0)
34
+ ipis!
35
+ rake (~> 10.0)
36
+
37
+ BUNDLED WITH
38
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Josh Brody
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # IPis
2
+
3
+ Because I got sick of going to ip2location.com in my browser.
4
+
5
+ ## Installation
6
+
7
+ Install it:
8
+
9
+ $ gem install ipis
10
+
11
+ ## Usage
12
+
13
+ $ ipis [IPs to query separated by spaces]
14
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/ipis ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ipis'
4
+
5
+ lookup = IPis::Lookup.new(ARGV)
6
+ lookup.run
data/ipis.gemspec ADDED
@@ -0,0 +1,35 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ipis/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ipis"
8
+ spec.version = Ipis::VERSION
9
+ spec.authors = ["Josh Brody"]
10
+ spec.email = ["josh@josh.mn"]
11
+
12
+ spec.summary = "Command line tool for ipinfo.io"
13
+ spec.description = "Command line tool for ipinfo.io"
14
+ spec.homepage = "https://github.com/joshmn/ipis"
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/joshmn/ipis"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.require_paths = ["lib"]
30
+ spec.executables = ["ipis"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_dependency "http"
35
+ end
data/lib/ipis.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'ipis/version'
2
+ require 'http'
3
+ require 'json'
4
+ require 'ipis/queries/ip_api'
5
+ require 'ipis/formatters/base_formatter'
6
+
7
+ module IPis
8
+ class Error < StandardError; end
9
+ class Lookup
10
+ def initialize(args)
11
+ @ips_to_lookup = args.map(&:strip).uniq
12
+ @query_adapter = IPis::Queries::IPApi
13
+ @formatter_adapter = IPis::Formatters::BaseFormatter
14
+ end
15
+
16
+ def run
17
+ @ips_to_lookup.each do |ip|
18
+ puts show(ip)
19
+ puts
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def show(ip)
26
+ query = @query_adapter.new(ip)
27
+ @formatter_adapter.format(query.result)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ module IPis
2
+ module Formatters
3
+ class BaseFormatter
4
+ def self.format(result)
5
+ new(result).format
6
+ end
7
+
8
+ def initialize(result)
9
+ @result = result
10
+ end
11
+
12
+ def format
13
+ parts = []
14
+ @result.each do |k,v|
15
+ parts << "#{bold(k)}: #{v}"
16
+ end
17
+ parts.join("\n")
18
+ end
19
+
20
+ private
21
+
22
+ def bold(text)
23
+ "\033[1m#{text}\033[0m"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ module IPis
2
+ module Queries
3
+ class IPApi
4
+ attr_reader :ip
5
+ def initialize(ip)
6
+ @ip = ip
7
+ end
8
+
9
+ def result
10
+ @result ||= JSON.parse(request.to_s)
11
+ end
12
+
13
+ private
14
+
15
+ def request
16
+ @request ||= HTTP.get("http://ip-api.com/json/#{ip}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Ipis
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ipis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Brody
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Command line tool for ipinfo.io
56
+ email:
57
+ - josh@josh.mn
58
+ executables:
59
+ - ipis
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - bin/ipis
70
+ - ipis.gemspec
71
+ - lib/ipis.rb
72
+ - lib/ipis/formatters/base_formatter.rb
73
+ - lib/ipis/queries/ip_api.rb
74
+ - lib/ipis/version.rb
75
+ homepage: https://github.com/joshmn/ipis
76
+ licenses: []
77
+ metadata:
78
+ homepage_uri: https://github.com/joshmn/ipis
79
+ source_code_uri: https://github.com/joshmn/ipis
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Command line tool for ipinfo.io
100
+ test_files: []