nslookupot 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0846a02a74eb40953b233d52b2b8f38f12414f8b3bf9c06c7eb2603129100428'
4
- data.tar.gz: ab65aa27f3980d3bad019c6711258111da627298a3a07e63deb781550dda7ed3
3
+ metadata.gz: 4f1acfd1d03342195e100d7ca6ec2bcca4fb4c99e3ff5ea32e12e664a62b4dfa
4
+ data.tar.gz: a70cca81c82b12973117db5618d0acf1c98fee83721e600e57168c5314f2eeee
5
5
  SHA512:
6
- metadata.gz: 4ef75c8b9bd0b4acebec3255714f853a1b777f2e0132d9018dd094b5ff394e063439e68dc9f60621558964e5f73e4a0d2b332978b33078b54c29513f50ca94fd
7
- data.tar.gz: aa3653f20ebd41e739f9d7aa7c24356ad037b6d333aed83da6f8d7c9b33d82f39c50a516229cb547222b3e309bc309543dc51ad21d7d6f05c9c41d84a9fad7b2
6
+ metadata.gz: 7fa8b7688b089d2b637150fc46dfd24e058af0bfc159becf61f0607bd1bc3abe6633179c8a5362fb6a00f49d638d29a020cb39905462993460053170839d50c4
7
+ data.tar.gz: ee8ed63f0c525f16ede0d675d35676b2250a45e8487ac3028f099a8c46ec16da4beb40374db8186f68d31988649d620e6aebb97ff9be32ea1745898fe95f303a
data/.rubocop.yml CHANGED
@@ -16,5 +16,5 @@ Metrics/AbcSize:
16
16
  Metrics/MethodLength:
17
17
  Max: 30
18
18
 
19
- Naming/UncommunicativeMethodParamName:
19
+ Naming/MethodParameterName:
20
20
  MinNameLength: 1
data/.travis.yml CHANGED
@@ -1,9 +1,8 @@
1
- sudo: false
2
-
3
1
  language: ruby
4
2
 
5
3
  rvm:
6
- - 2.6.3
4
+ - 2.6
5
+ - 2.7
7
6
  - ruby-head
8
7
 
9
8
  matrix:
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ group :test do
9
9
  gem 'pry'
10
10
  gem 'pry-byebug'
11
11
  gem 'rspec', '3.8.0'
12
- gem 'rubocop', '0.68.1'
12
+ gem 'rubocop', '0.78.0'
13
13
  end
14
14
 
15
15
  gemspec
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
 
@@ -52,21 +52,21 @@ module Nslookupot
52
52
  begin
53
53
  args = op.parse(argv)
54
54
  rescue OptionParser::InvalidOption => e
55
- puts op.to_s
56
- puts "error: #{e.message}"
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
- puts "error: unknown query type #{type}"
63
+ warn "error: unknown query type #{type}"
64
64
  exit 1
65
65
  end
66
66
 
67
67
  if args.size != 1
68
- puts op.to_s
69
- puts 'error: number of arguments is not 1'
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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nslookupot
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
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.1
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: 2019-07-03 00:00:00.000000000 Z
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.0.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