nslookupot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -3
- data/Gemfile +1 -1
- data/README.md +1 -0
- data/lib/nslookupot/cli.rb +10 -7
- data/lib/nslookupot/version.rb +1 -1
- data/spec/cli_spec.rb +32 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f1acfd1d03342195e100d7ca6ec2bcca4fb4c99e3ff5ea32e12e664a62b4dfa
|
4
|
+
data.tar.gz: a70cca81c82b12973117db5618d0acf1c98fee83721e600e57168c5314f2eeee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa8b7688b089d2b637150fc46dfd24e058af0bfc159becf61f0607bd1bc3abe6633179c8a5362fb6a00f49d638d29a020cb39905462993460053170839d50c4
|
7
|
+
data.tar.gz: ee8ed63f0c525f16ede0d675d35676b2250a45e8487ac3028f099a8c46ec16da4beb40374db8186f68d31988649d620e6aebb97ff9be32ea1745898fe95f303a
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# nslookupot
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/nslookupot.svg)](https://badge.fury.io/rb/nslookupot)
|
3
4
|
[![Build Status](https://travis-ci.org/thekuwayama/nslookupot.svg?branch=master)](https://travis-ci.org/thekuwayama/nslookupot)
|
4
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/5df9157757f5a0bf1623/maintainability)](https://codeclimate.com/github/thekuwayama/nslookupot/maintainability)
|
5
6
|
|
data/lib/nslookupot/cli.rb
CHANGED
@@ -52,21 +52,21 @@ module Nslookupot
|
|
52
52
|
begin
|
53
53
|
args = op.parse(argv)
|
54
54
|
rescue OptionParser::InvalidOption => e
|
55
|
-
|
56
|
-
|
55
|
+
warn op.to_s
|
56
|
+
warn "error: #{e.message}"
|
57
57
|
exit 1
|
58
58
|
end
|
59
59
|
|
60
60
|
begin
|
61
61
|
type = s2typeclass(type)
|
62
62
|
rescue NameError
|
63
|
-
|
63
|
+
warn "error: unknown query type #{type}"
|
64
64
|
exit 1
|
65
65
|
end
|
66
66
|
|
67
67
|
if args.size != 1
|
68
|
-
|
69
|
-
|
68
|
+
warn op.to_s
|
69
|
+
warn 'error: number of arguments is not 1'
|
70
70
|
exit 1
|
71
71
|
end
|
72
72
|
|
@@ -75,13 +75,16 @@ module Nslookupot
|
|
75
75
|
# rubocop: enable Metrics/MethodLength
|
76
76
|
|
77
77
|
def s2typeclass(s)
|
78
|
-
Resolv::DNS::Resource::IN.const_get(s.upcase)
|
78
|
+
rr = Resolv::DNS::Resource::IN.const_get(s.upcase)
|
79
|
+
raise NameError unless rr < Resolv::DNS::Resource
|
80
|
+
|
81
|
+
rr
|
79
82
|
end
|
80
83
|
|
81
84
|
def run
|
82
85
|
opts, name, type = parse_options
|
83
86
|
|
84
|
-
resolver = Nslookupot::Resolver.new(opts)
|
87
|
+
resolver = Nslookupot::Resolver.new(**opts)
|
85
88
|
puts 'Address:'.ljust(16) + opts[:server] + '#' + opts[:port].to_s
|
86
89
|
puts '--'
|
87
90
|
resolver.resolve_resources(name, type).each do |rr|
|
data/lib/nslookupot/version.rb
CHANGED
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Nslookupot::CLI do
|
6
|
+
context 'Resource Record (RR) TYPEs' do
|
7
|
+
let(:cli) do
|
8
|
+
Nslookupot::CLI.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'could return the typeclass object' do
|
12
|
+
expect(cli.s2typeclass('A')).to eq Resolv::DNS::Resource::IN::A
|
13
|
+
expect(cli.s2typeclass('AAAA')).to eq Resolv::DNS::Resource::IN::AAAA
|
14
|
+
expect(cli.s2typeclass('CNAME')).to eq Resolv::DNS::Resource::IN::CNAME
|
15
|
+
expect(cli.s2typeclass('HINFO')).to eq Resolv::DNS::Resource::IN::HINFO
|
16
|
+
expect(cli.s2typeclass('MINFO')).to eq Resolv::DNS::Resource::IN::MINFO
|
17
|
+
expect(cli.s2typeclass('MX')).to eq Resolv::DNS::Resource::IN::MX
|
18
|
+
expect(cli.s2typeclass('NS')).to eq Resolv::DNS::Resource::IN::NS
|
19
|
+
expect(cli.s2typeclass('PTR')).to eq Resolv::DNS::Resource::IN::PTR
|
20
|
+
expect(cli.s2typeclass('SOA')).to eq Resolv::DNS::Resource::IN::SOA
|
21
|
+
expect(cli.s2typeclass('TXT')).to eq Resolv::DNS::Resource::IN::TXT
|
22
|
+
expect(cli.s2typeclass('WKS')).to eq Resolv::DNS::Resource::IN::WKS
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'could raise NameError' do
|
26
|
+
expect { cli.s2typeclass('ANY') }.to raise_error(NameError)
|
27
|
+
expect { cli.s2typeclass('ClassValue') }.to raise_error(NameError)
|
28
|
+
expect { cli.s2typeclass('hoge') }.to raise_error(NameError)
|
29
|
+
expect { cli.s2typeclass('CAA') }.to raise_error(NameError) # not support
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nslookupot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/nslookupot/resolver.rb
|
60
60
|
- lib/nslookupot/version.rb
|
61
61
|
- nslookupot.gemspec
|
62
|
+
- spec/cli_spec.rb
|
62
63
|
- spec/resolver_spec.rb
|
63
64
|
- spec/spec_helper.rb
|
64
65
|
homepage: https://github.com/thekuwayama/nslookupot
|
@@ -80,10 +81,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.1.2
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
87
|
summary: nslookup over TLS
|
87
88
|
test_files:
|
89
|
+
- spec/cli_spec.rb
|
88
90
|
- spec/resolver_spec.rb
|
89
91
|
- spec/spec_helper.rb
|