whois 6.0.0 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +1 -0
  3. data/.rubocop_todo.yml +11 -87
  4. data/CHANGELOG.md +7 -0
  5. data/bin/whoisrb +3 -3
  6. data/data/tld.json +2 -769
  7. data/lib/whois/client.rb +1 -1
  8. data/lib/whois/record.rb +1 -1
  9. data/lib/whois/server/adapters/arpa.rb +3 -5
  10. data/lib/whois/server/adapters/base.rb +3 -3
  11. data/lib/whois/server/adapters/none.rb +1 -1
  12. data/lib/whois/server/adapters/not_implemented.rb +1 -1
  13. data/lib/whois/server/adapters/web.rb +1 -1
  14. data/lib/whois/server/socket_handler.rb +3 -3
  15. data/lib/whois/server.rb +5 -5
  16. data/lib/whois/version.rb +1 -1
  17. data/lib/whois.rb +18 -18
  18. data/spec/integration/whois_spec.rb +2 -2
  19. data/spec/spec_helper.rb +2 -2
  20. data/spec/whois/client_spec.rb +1 -1
  21. data/spec/whois/record/part_spec.rb +1 -1
  22. data/spec/whois/record_spec.rb +26 -18
  23. data/spec/whois/server/adapters/afilias_spec.rb +1 -1
  24. data/spec/whois/server/adapters/arin_spec.rb +1 -1
  25. data/spec/whois/server/adapters/arpa_spec.rb +2 -2
  26. data/spec/whois/server/adapters/base_spec.rb +17 -12
  27. data/spec/whois/server/adapters/formatted_spec.rb +1 -1
  28. data/spec/whois/server/adapters/none_spec.rb +1 -1
  29. data/spec/whois/server/adapters/not_implemented_spec.rb +2 -2
  30. data/spec/whois/server/adapters/standard_spec.rb +1 -1
  31. data/spec/whois/server/adapters/verisign_spec.rb +1 -1
  32. data/spec/whois/server/adapters/web_spec.rb +1 -1
  33. data/spec/whois/server/socket_handler_spec.rb +2 -2
  34. data/spec/whois/server_spec.rb +51 -51
  35. data/spec/whois/web_interface_error_spec.rb +1 -1
  36. data/spec/whois/whois_spec.rb +1 -1
  37. data/utils/deftld.rb +0 -1
  38. metadata +3 -3
data/lib/whois/client.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'timeout'
12
+ require "timeout"
13
13
 
14
14
 
15
15
  module Whois
data/lib/whois/record.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/record/part'
12
+ require "whois/record/part"
13
13
 
14
14
 
15
15
  module Whois
@@ -35,11 +35,9 @@ module Whois
35
35
  a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
36
36
  [a, b, c, d].map do |token|
37
37
  token = (token || 0).to_i
38
- if token <= 255 && token >= 0
39
- token
40
- else
41
- raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
42
- end
38
+ raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token <= 255 && token >= 0
39
+
40
+ token
43
41
  end.join(".")
44
42
  end
45
43
 
@@ -9,9 +9,9 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/record/part'
13
- require 'whois/record'
14
- require 'whois/server/socket_handler'
12
+ require "whois/record/part"
13
+ require "whois/record"
14
+ require "whois/server/socket_handler"
15
15
 
16
16
 
17
17
  module Whois
@@ -36,7 +36,7 @@ module Whois
36
36
  #
37
37
  # @raise [Whois::NoInterfaceError] For every request.
38
38
  #
39
- def request(string)
39
+ def request(_string)
40
40
  raise NoInterfaceError, "This `#{type}' has no whois server"
41
41
  end
42
42
 
@@ -22,7 +22,7 @@ module Whois
22
22
  #
23
23
  # @raise [Whois::ServerNotImplemented] For every request.
24
24
  #
25
- def request(string)
25
+ def request(_string)
26
26
  raise ServerNotImplemented, "The `#{host}' feature has not been implemented yet."
27
27
  end
28
28
 
@@ -32,7 +32,7 @@ module Whois
32
32
  #
33
33
  # @raise [Whois::WebInterfaceError] For every request.
34
34
  #
35
- def request(string)
35
+ def request(_string)
36
36
  raise WebInterfaceError, options[:url]
37
37
  end
38
38
 
@@ -9,8 +9,8 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'socket'
13
- require 'whois/errors'
12
+ require "socket"
13
+ require "whois/errors"
14
14
 
15
15
 
16
16
  module Whois
@@ -58,7 +58,7 @@ module Whois
58
58
  client.write("#{query}\r\n") # I could use put(foo) and forget the \n
59
59
  client.read # but write/read is more symmetric than puts/read
60
60
  ensure # and I really want to use read instead of gets.
61
- client.close if client # If != client something went wrong.
61
+ client&.close # If != client something went wrong.
62
62
  end
63
63
  end
64
64
 
data/lib/whois/server.rb CHANGED
@@ -9,8 +9,8 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'ipaddr'
13
- require 'json'
12
+ require "ipaddr"
13
+ require "json"
14
14
  require "whois/server/adapters/base"
15
15
  require "whois/server/adapters/arin"
16
16
  require "whois/server/adapters/arpa"
@@ -67,7 +67,7 @@ module Whois
67
67
  # @return [void]
68
68
  def load_definitions
69
69
  clear_definitions
70
- Dir[File.expand_path('../../data/*.json', __dir__)].each { |f| load_json(f) }
70
+ Dir[File.expand_path("../../data/*.json", __dir__)].each { |f| load_json(f) }
71
71
  end
72
72
 
73
73
  # Loads the definitions from a JSON file.
@@ -283,7 +283,7 @@ module Whois
283
283
  # @param string [String]
284
284
  # @raise [Whois::ServerNotSupported]
285
285
  # emails are not supported.
286
- def find_for_email(string)
286
+ def find_for_email(_string)
287
287
  raise ServerNotSupported, "No WHOIS server is known for email objects"
288
288
  end
289
289
 
@@ -363,7 +363,7 @@ module Whois
363
363
  end
364
364
 
365
365
  def matches_email?(string)
366
- string.include?('@')
366
+ string.include?("@")
367
367
  end
368
368
 
369
369
  def matches_asn?(string)
data/lib/whois/version.rb CHANGED
@@ -11,5 +11,5 @@
11
11
 
12
12
  module Whois
13
13
  # The current library version.
14
- VERSION = "6.0.0"
14
+ VERSION = "6.0.1"
15
15
  end
data/lib/whois.rb CHANGED
@@ -9,11 +9,11 @@
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/version'
13
- require 'whois/errors'
14
- require 'whois/client'
15
- require 'whois/server'
16
- require 'whois/record'
12
+ require "whois/version"
13
+ require "whois/errors"
14
+ require "whois/client"
15
+ require "whois/server"
16
+ require "whois/record"
17
17
 
18
18
 
19
19
  module Whois
@@ -74,7 +74,7 @@ module Whois
74
74
  result
75
75
  end
76
76
 
77
- def deprecate(message = nil, callstack = caller)
77
+ def deprecate(message = nil, _callstack = caller)
78
78
  # warn("DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}")
79
79
  warn("DEPRECATION WARNING: #{message}")
80
80
  end
@@ -99,24 +99,24 @@ module Whois
99
99
 
100
100
  def deprecation_caller_message(callstack)
101
101
  file, line, method = extract_callstack(callstack)
102
- if file
103
- if line && method
104
- "(called from #{method} at #{file}:#{line})"
105
- else
106
- "(called from #{file}:#{line})"
107
- end
102
+ return unless file
103
+
104
+ if line && method
105
+ "(called from #{method} at #{file}:#{line})"
106
+ else
107
+ "(called from #{file}:#{line})"
108
108
  end
109
109
  end
110
110
 
111
111
  def extract_callstack(callstack)
112
112
  gem_root = "#{File.expand_path('../..', __dir__)}/"
113
113
  offending_line = callstack.find { |line| !line.start_with?(gem_root) } || callstack.first
114
- if offending_line
115
- if (md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/))
116
- md.captures
117
- else
118
- offending_line
119
- end
114
+ return unless offending_line
115
+
116
+ if (md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/))
117
+ md.captures
118
+ else
119
+ offending_line
120
120
  end
121
121
  end
122
122
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois do
6
6
  let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
@@ -13,7 +13,7 @@ describe Whois do
13
13
  .with("example.it", "whois.nic.it", 43)
14
14
  .and_return(response)
15
15
 
16
- record = Whois.lookup("example.it")
16
+ record = described_class.lookup("example.it")
17
17
 
18
18
  expect(record).to be_a(Whois::Record)
19
19
  # expect(record.available?).to be_truthy
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec'
4
- require 'whois'
3
+ require "rspec"
4
+ require "whois"
5
5
 
6
6
  SPEC_ROOT = File.expand_path(__dir__) unless defined?(SPEC_ROOT)
7
7
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Client do
6
6
  describe "#initialize" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Record::Part do
6
6
  describe "#initialize" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Record do
6
6
  subject { described_class.new(server, parts) }
@@ -65,64 +65,72 @@ describe Whois::Record do
65
65
  one = two = described_class.new(server, parts)
66
66
 
67
67
  expect(one == two).to be_truthy
68
- expect(one.eql?(two)).to be_truthy
68
+ expect(one).to eql(two)
69
69
  end
70
70
 
71
71
  it "returns true when other has same class and has the same parts" do
72
- one, two = described_class.new(server, parts), described_class.new(server, parts)
72
+ one = described_class.new(server, parts)
73
+ two = described_class.new(server, parts)
73
74
 
74
75
  expect(one == two).to be_truthy
75
- expect(one.eql?(two)).to be_truthy
76
+ expect(one).to eql(two)
76
77
  end
77
78
 
78
79
  it "returns true when other has descendant class and has the same parts" do
79
80
  subklass = Class.new(described_class)
80
- one, two = described_class.new(server, parts), subklass.new(server, parts)
81
+ one = described_class.new(server, parts)
82
+ two = subklass.new(server, parts)
81
83
 
82
84
  expect(one == two).to be_truthy
83
- expect(one.eql?(two)).to be_truthy
85
+ expect(one).to eql(two)
84
86
  end
85
87
 
86
88
  it "returns true when other has same class and has equal parts" do
87
- one, two = described_class.new(server, parts), described_class.new(server, parts.dup)
89
+ one = described_class.new(server, parts)
90
+ two = described_class.new(server, parts.dup)
88
91
 
89
92
  expect(one == two).to be_truthy
90
- expect(one.eql?(two)).to be_truthy
93
+ expect(one).to eql(two)
91
94
  end
92
95
 
93
96
  it "returns true when other has same class, different server and the same parts" do
94
- one, two = described_class.new(server, parts), described_class.new(nil, parts)
97
+ one = described_class.new(server, parts)
98
+ two = described_class.new(nil, parts)
95
99
 
96
100
  expect(one == two).to be_truthy
97
- expect(one.eql?(two)).to be_truthy
101
+ expect(one).to eql(two)
98
102
  end
99
103
 
100
104
  it "returns false when other has different class and has the same parts" do
101
- one, two = described_class.new(server, parts), Struct.new(:server, :parts).new(server, parts)
105
+ one = described_class.new(server, parts)
106
+ two = Struct.new(:server, :parts).new(server, parts)
102
107
 
103
108
  expect(one == two).to be_falsey
104
- expect(one.eql?(two)).to be_falsey
109
+ expect(one).not_to eql(two)
105
110
  end
106
111
 
107
112
  it "returns false when other has different parts" do
108
- one, two = described_class.new(server, parts), described_class.new(server, [])
113
+ one = described_class.new(server, parts)
114
+ two = described_class.new(server, [])
109
115
 
110
116
  expect(one == two).to be_falsey
111
- expect(one.eql?(two)).to be_falsey
117
+ expect(one).not_to eql(two)
112
118
  end
113
119
 
114
120
  it "returns false when other is string and has the same content" do
115
- one, two = described_class.new(server, parts), described_class.new(server, parts).to_s
121
+ one = described_class.new(server, parts)
122
+ two = described_class.new(server, parts).to_s
116
123
 
117
124
  expect(one == two).to be_falsey
118
- expect(one.eql?(two)).to be_falsey
125
+ expect(one).not_to eql(two)
119
126
  end
120
127
 
121
128
  it "returns false when other is string and has different content" do
122
- one, two = described_class.new(server, parts), "different"
129
+ one = described_class.new(server, parts)
130
+ two = "different"
123
131
 
124
132
  expect(one == two).to be_falsey
125
- expect(one.eql?(two)).to be_falsey
133
+ expect(one).not_to eql(two)
126
134
  end
127
135
  end
128
136
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Afilias do
6
6
  let(:definition) { [:tld, ".test", "whois.afilias-grs.info", {}] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Arin do
6
6
  let(:definition) { [:ipv4, "0.0.0.0/1", "whois.arin.net"] }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'whois/server/adapters/arin'
3
+ require "spec_helper"
4
+ require "whois/server/adapters/arin"
5
5
 
6
6
  describe Whois::Server::Adapters::Arpa do
7
7
  let(:definition) { [:tld, ".in-addr.arpa", nil, {}] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Base do
6
6
  let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
@@ -36,43 +36,48 @@ describe Whois::Server::Adapters::Base do
36
36
  one = two = described_class.new(*definition)
37
37
 
38
38
  expect(one == two).to be_truthy
39
- expect(one.eql?(two)).to be_truthy
39
+ expect(one).to eql(two)
40
40
  end
41
41
 
42
42
  it "returns true when other has same class and has the same attributes" do
43
- one, two = described_class.new(*definition), described_class.new(*definition)
43
+ one = described_class.new(*definition)
44
+ two = described_class.new(*definition)
44
45
 
45
46
  expect(one == two).to be_truthy
46
- expect(one.eql?(two)).to be_truthy
47
+ expect(one).to eql(two)
47
48
  end
48
49
 
49
50
  it "returns true when other has descendant class and has the same attributes" do
50
51
  subklass = Class.new(described_class)
51
- one, two = described_class.new(*definition), subklass.new(*definition)
52
+ one = described_class.new(*definition)
53
+ two = subklass.new(*definition)
52
54
 
53
55
  expect(one == two).to be_truthy
54
- expect(one.eql?(two)).to be_truthy
56
+ expect(one).to eql(two)
55
57
  end
56
58
 
57
59
  it "returns false when other has different class and has the same attributes" do
58
- one, two = described_class.new(*definition), Struct.new(:type, :allocation, :host, :options).new(*definition)
60
+ one = described_class.new(*definition)
61
+ two = Struct.new(:type, :allocation, :host, :options).new(*definition)
59
62
 
60
63
  expect(one == two).to be_falsey
61
- expect(one.eql?(two)).to be_falsey
64
+ expect(one).not_to eql(two)
62
65
  end
63
66
 
64
67
  it "returns false when other has different attributes" do
65
- one, two = described_class.new(:tld, ".test", "whois.test"), described_class.new(:tld, ".cool", "whois.test")
68
+ one = described_class.new(:tld, ".test", "whois.test")
69
+ two = described_class.new(:tld, ".cool", "whois.test")
66
70
 
67
71
  expect(one == two).to be_falsey
68
- expect(one.eql?(two)).to be_falsey
72
+ expect(one).not_to eql(two)
69
73
  end
70
74
 
71
75
  it "returns false when other has different options" do
72
- one, two = described_class.new(:tld, ".test", "whois.test"), described_class.new(:tld, ".test", "whois.test", { foo: "bar" })
76
+ one = described_class.new(:tld, ".test", "whois.test")
77
+ two = described_class.new(:tld, ".test", "whois.test", { foo: "bar" })
73
78
 
74
79
  expect(one == two).to be_falsey
75
- expect(one.eql?(two)).to be_falsey
80
+ expect(one).not_to eql(two)
76
81
  end
77
82
  end
78
83
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Formatted do
6
6
  let(:definition) { [:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s" }] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::None do
6
6
  describe "#lookup" do
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::NotImplemented do
6
6
  before do
7
- @definition = [:ipv6, "2001:0000::/32", "teredo", { adapter: Whois::Server::Adapters::NotImplemented }]
7
+ @definition = [:ipv6, "2001:0000::/32", "teredo", { adapter: described_class }]
8
8
  end
9
9
 
10
10
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Standard do
6
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Verisign do
6
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Web do
6
6
  before do
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'whois/server/socket_handler'
3
+ require "spec_helper"
4
+ require "whois/server/socket_handler"
5
5
 
6
6
  describe Whois::Server::SocketHandler do
7
7
  describe "#call" do