whois 5.0.1 → 5.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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +8 -0
  3. data/.github/workflows/codeql-analysis.yml +64 -0
  4. data/.github/workflows/release.yml +16 -0
  5. data/.github/workflows/tests.yml +29 -0
  6. data/.rubocop.yml +27 -0
  7. data/.rubocop_opinionated.yml +135 -0
  8. data/.rubocop_todo.yml +166 -0
  9. data/.simplecov +2 -0
  10. data/.tool-versions +1 -0
  11. data/CHANGELOG.md +76 -53
  12. data/CONTRIBUTING.md +12 -12
  13. data/Gemfile +5 -0
  14. data/LICENSE.txt +1 -1
  15. data/README.md +22 -22
  16. data/Rakefile +12 -17
  17. data/bin/console +1 -0
  18. data/bin/whoisrb +3 -2
  19. data/data/ipv4.json +1 -3
  20. data/data/tld.json +2 -99
  21. data/lib/whois/client.rb +4 -2
  22. data/lib/whois/errors.rb +4 -2
  23. data/lib/whois/record/part.rb +5 -4
  24. data/lib/whois/record.rb +4 -2
  25. data/lib/whois/server/adapters/afilias.rb +4 -1
  26. data/lib/whois/server/adapters/arin.rb +7 -4
  27. data/lib/whois/server/adapters/arpa.rb +20 -19
  28. data/lib/whois/server/adapters/base.rb +26 -40
  29. data/lib/whois/server/adapters/formatted.rb +4 -2
  30. data/lib/whois/server/adapters/none.rb +3 -1
  31. data/lib/whois/server/adapters/not_implemented.rb +3 -1
  32. data/lib/whois/server/adapters/standard.rb +4 -2
  33. data/lib/whois/server/adapters/verisign.rb +4 -1
  34. data/lib/whois/server/adapters/web.rb +3 -1
  35. data/lib/whois/server/socket_handler.rb +8 -6
  36. data/lib/whois/server.rb +41 -47
  37. data/lib/whois/version.rb +4 -2
  38. data/lib/whois.rb +13 -11
  39. data/spec/integration/whois_spec.rb +6 -6
  40. data/spec/spec_helper.rb +4 -4
  41. data/spec/support/helpers/connectivity_helper.rb +3 -3
  42. data/spec/support/helpers/spec_helper.rb +2 -0
  43. data/spec/whois/client_spec.rb +6 -7
  44. data/spec/whois/record/part_spec.rb +4 -4
  45. data/spec/whois/record_spec.rb +9 -7
  46. data/spec/whois/server/adapters/afilias_spec.rb +4 -4
  47. data/spec/whois/server/adapters/arin_spec.rb +9 -10
  48. data/spec/whois/server/adapters/arpa_spec.rb +2 -2
  49. data/spec/whois/server/adapters/base_spec.rb +13 -13
  50. data/spec/whois/server/adapters/formatted_spec.rb +8 -8
  51. data/spec/whois/server/adapters/none_spec.rb +2 -2
  52. data/spec/whois/server/adapters/not_implemented_spec.rb +4 -4
  53. data/spec/whois/server/adapters/standard_spec.rb +5 -5
  54. data/spec/whois/server/adapters/verisign_spec.rb +5 -5
  55. data/spec/whois/server/adapters/web_spec.rb +4 -4
  56. data/spec/whois/server/socket_handler_spec.rb +7 -5
  57. data/spec/whois/server_spec.rb +31 -29
  58. data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
  59. data/spec/whois/whois_spec.rb +3 -3
  60. metadata +13 -39
  61. data/.travis.yml +0 -18
  62. data/bin/setup +0 -8
  63. data/tasks/spec.rake +0 -199
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Arin do
4
-
5
6
  let(:definition) { [:ipv4, "0.0.0.0/1", "whois.arin.net"] }
6
7
  let(:server) { described_class.new(*definition) }
7
8
 
@@ -22,7 +23,7 @@ describe Whois::Server::Adapters::Arin do
22
23
  it "follows whois:// referrals" do
23
24
  referral = File.read(fixture("referrals/arin_referral_whois.txt"))
24
25
  response = "Whois Response"
25
- expected = referral + "\n" + response
26
+ expected = "#{referral}\n#{response}"
26
27
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
27
28
  expect(server.query_handler).to receive(:call).with("0.0.0.0", "whois.ripe.net", 43).and_return(response)
28
29
 
@@ -30,13 +31,13 @@ describe Whois::Server::Adapters::Arin do
30
31
  expect(record.to_s).to eq(expected)
31
32
  expect(record.parts.size).to eq(2)
32
33
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
33
- Whois::Record::Part.new(body: response, host: "whois.ripe.net")])
34
+ Whois::Record::Part.new(body: response, host: "whois.ripe.net"),])
34
35
  end
35
36
 
36
37
  it "follows rwhois:// referrals" do
37
38
  referral = File.read(fixture("referrals/arin_referral_rwhois.txt"))
38
39
  response = "Whois Response"
39
- expected = referral + "\n" + response
40
+ expected = "#{referral}\n#{response}"
40
41
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
41
42
  expect(server.query_handler).to receive(:call).with("0.0.0.0", "rwhois.servernap.net", 4321).and_return(response)
42
43
 
@@ -44,14 +45,14 @@ describe Whois::Server::Adapters::Arin do
44
45
  expect(record.to_s).to eq(expected)
45
46
  expect(record.parts.size).to eq(2)
46
47
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
47
- Whois::Record::Part.new(body: response, host: "rwhois.servernap.net")])
48
+ Whois::Record::Part.new(body: response, host: "rwhois.servernap.net"),])
48
49
  end
49
50
 
50
51
  it "ignores referral if options[:referral] is false" do
51
52
  referral = File.read(fixture("referrals/arin_referral_whois.txt"))
52
53
  server.options[:referral] = false
53
54
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
54
- expect(server.query_handler).to receive(:call).with("0.0.0.0", "whois.ripe.net", 43).never
55
+ expect(server.query_handler).not_to receive(:call).with("0.0.0.0", "whois.ripe.net", 43)
55
56
 
56
57
  record = server.lookup("0.0.0.0")
57
58
  expect(record.parts.size).to eq(1)
@@ -60,7 +61,7 @@ describe Whois::Server::Adapters::Arin do
60
61
  it "ignores referral (gracefully) if missing" do
61
62
  referral = File.read(fixture("referrals/arin_referral_missing.txt"))
62
63
  expect(server.query_handler).to receive(:call).with("n + 0.0.0.0", "whois.arin.net", 43).and_return(referral)
63
- expect(server.query_handler).to receive(:call).never
64
+ expect(server.query_handler).not_to receive(:call)
64
65
 
65
66
  record = server.lookup("0.0.0.0")
66
67
  expect(record.parts.size).to eq(1)
@@ -75,10 +76,8 @@ describe Whois::Server::Adapters::Arin do
75
76
  record = server.lookup("0.0.0.0")
76
77
  expect(record.parts.size).to eq(2)
77
78
  expect(record.parts).to eq([Whois::Record::Part.new(body: referral, host: "whois.arin.net"),
78
- Whois::Record::Part.new(body: response, host: "whois.apnic.net")])
79
+ Whois::Record::Part.new(body: response, host: "whois.apnic.net"),])
79
80
  end
80
81
  end
81
-
82
82
  end
83
-
84
83
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'whois/server/adapters/arin'
3
5
 
4
6
  describe Whois::Server::Adapters::Arpa do
5
-
6
7
  let(:definition) { [:tld, ".in-addr.arpa", nil, {}] }
7
8
 
8
9
  describe "#lookup" do
@@ -16,5 +17,4 @@ describe Whois::Server::Adapters::Arpa do
16
17
  expect(record.parts).to eq([Whois::Record::Part.new(body: response, host: "whois.arin.net")])
17
18
  end
18
19
  end
19
-
20
20
  end
@@ -1,19 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Base do
4
-
5
- let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
6
+ let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
6
7
 
7
8
 
8
9
  describe "#initialize" do
9
10
  it "requires type, allocation, and host parameters" do
10
11
  expect { described_class.new(:tld) }.to raise_error(ArgumentError)
11
12
  expect { described_class.new(:tld, ".test") }.to raise_error(ArgumentError)
12
- expect { described_class.new(:tld, ".test", "whois.test") }.to_not raise_error
13
+ expect { described_class.new(:tld, ".test", "whois.test") }.not_to raise_error
13
14
  end
14
15
 
15
16
  it "accepts an options parameter" do
16
- expect { described_class.new(:tld, ".test", "whois.test", { foo: "bar" }) }.to_not raise_error
17
+ expect { described_class.new(:tld, ".test", "whois.test", { foo: "bar" }) }.not_to raise_error
17
18
  end
18
19
 
19
20
  it "sets instance variables from arguments" do
@@ -78,22 +79,22 @@ describe Whois::Server::Adapters::Base do
78
79
 
79
80
  describe "#configure" do
80
81
  it "merges settings with current options" do
81
- a = described_class.new(:tld, ".test", "whois.test", { :hello => "world" })
82
+ a = described_class.new(:tld, ".test", "whois.test", { hello: "world" })
82
83
  a.configure(foo: "bar")
83
- expect(a.options).to eq({ :hello => "world", foo: "bar" })
84
+ expect(a.options).to eq({ hello: "world", foo: "bar" })
84
85
  end
85
86
 
86
87
  it "gives higher priority to settings argument" do
87
88
  a = described_class.new(:tld, ".test", "whois.test", { foo: "bar" })
88
89
  expect(a.options).to eq({ foo: "bar" })
89
- a.configure(:foo => "baz")
90
- expect(a.options).to eq({ :foo => "baz" })
90
+ a.configure(foo: "baz")
91
+ expect(a.options).to eq({ foo: "baz" })
91
92
  end
92
93
 
93
94
  it "overrides @host if :host option exists" do
94
- a = described_class.new(:tld, ".test", "whois.test", { :hello => "world" })
95
+ a = described_class.new(:tld, ".test", "whois.test", { hello: "world" })
95
96
  a.configure(foo: "bar", host: "whois.example.com")
96
- expect(a.options).to eq({ :hello => "world", foo: "bar", host: "whois.example.com" })
97
+ expect(a.options).to eq({ hello: "world", foo: "bar", host: "whois.example.com" })
97
98
  expect(a.host).to eq("whois.example.com")
98
99
  end
99
100
  end
@@ -127,7 +128,7 @@ describe Whois::Server::Adapters::Base do
127
128
  end
128
129
 
129
130
  context "with :bind_host and :bind_port options" do
130
- let(:server) { described_class.new(:tld, ".test", "whois.test", { :bind_host => "192.168.1.1", :bind_port => 3000 }) }
131
+ let(:server) { described_class.new(:tld, ".test", "whois.test", { bind_host: "192.168.1.1", bind_port: 3000 }) }
131
132
 
132
133
  it "binds the WHOIS query to given host and port" do
133
134
  expect(described_class.query_handler).to receive(:call).with("example.test", "whois.test", 43, "192.168.1.1", 3000)
@@ -137,7 +138,7 @@ describe Whois::Server::Adapters::Base do
137
138
  end
138
139
 
139
140
  context "with :bind_port and without :bind_host options" do
140
- let(:server) { described_class.new(:tld, ".test", "whois.test", { :bind_port => 3000 }) }
141
+ let(:server) { described_class.new(:tld, ".test", "whois.test", { bind_port: 3000 }) }
141
142
 
142
143
  it "binds the WHOIS query to given port and defaults host" do
143
144
  expect(described_class.query_handler).to receive(:call).with("example.test", "whois.test", 43, described_class::DEFAULT_BIND_HOST, 3000)
@@ -146,5 +147,4 @@ describe Whois::Server::Adapters::Base do
146
147
  end
147
148
  end
148
149
  end
149
-
150
150
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Formatted do
4
-
5
- let(:definition) { [:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" }] }
6
+ let(:definition) { [:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s" }] }
6
7
 
7
8
 
8
9
  describe "#lookup" do
@@ -19,8 +20,8 @@ describe Whois::Server::Adapters::Formatted do
19
20
 
20
21
  context "without format option" do
21
22
  it "raises an error" do
22
- server = described_class.new(*[:tld, ".de", "whois.denic.de", {}])
23
- expect(server.query_handler).to receive(:call).never
23
+ server = described_class.new(:tld, ".de", "whois.denic.de", {})
24
+ expect(server.query_handler).not_to receive(:call)
24
25
 
25
26
  expect {
26
27
  server.lookup("domain.de")
@@ -31,7 +32,7 @@ describe Whois::Server::Adapters::Formatted do
31
32
  context "with port option" do
32
33
  it "sends the request to given port" do
33
34
  response = "Whois Response"
34
- server = described_class.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s", :port => 20 })
35
+ server = described_class.new(:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s", port: 20 })
35
36
  expect(server.query_handler).to receive(:call).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 20).and_return(response)
36
37
 
37
38
  server.lookup("domain.de")
@@ -41,13 +42,12 @@ describe Whois::Server::Adapters::Formatted do
41
42
  context "with bind option" do
42
43
  it "binds the request to given host and port" do
43
44
  response = "Whois Response"
44
- server = described_class.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" })
45
- server.configure(:bind_host => "192.168.1.1", :bind_port => 3000)
45
+ server = described_class.new(:tld, ".de", "whois.denic.de", { format: "-T dn,ace -C US-ASCII %s" })
46
+ server.configure(bind_host: "192.168.1.1", bind_port: 3000)
46
47
  expect(server.query_handler).to receive(:call).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 43, "192.168.1.1", 3000).and_return(response)
47
48
 
48
49
  server.lookup("domain.de")
49
50
  end
50
51
  end
51
52
  end
52
-
53
53
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::None do
4
-
5
6
  describe "#lookup" do
6
7
  it "raises Whois::NoInterfaceError" do
7
8
  expect {
@@ -19,5 +20,4 @@ describe Whois::Server::Adapters::None do
19
20
  }.to raise_error(Whois::NoInterfaceError, /ipv4/)
20
21
  end
21
22
  end
22
-
23
23
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::NotImplemented do
4
-
5
- before(:each) do
6
- @definition = [:ipv6, "2001:0000::/32", "teredo", { :adapter => Whois::Server::Adapters::NotImplemented }]
6
+ before do
7
+ @definition = [:ipv6, "2001:0000::/32", "teredo", { adapter: Whois::Server::Adapters::NotImplemented }]
7
8
  end
8
9
 
9
10
 
@@ -20,5 +21,4 @@ describe Whois::Server::Adapters::NotImplemented do
20
21
  }.to raise_error(Whois::ServerNotImplemented, /teredo/)
21
22
  end
22
23
  end
23
-
24
24
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Standard do
4
-
5
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
6
7
 
7
8
 
@@ -20,7 +21,7 @@ describe Whois::Server::Adapters::Standard do
20
21
  context "with port option" do
21
22
  it "sends the request to given port" do
22
23
  response = "Whois Response"
23
- server = described_class.new(:tld, ".test", "whois.test", { :port => 20 })
24
+ server = described_class.new(:tld, ".test", "whois.test", { port: 20 })
24
25
  expect(server.query_handler).to receive(:call).with("domain.test", "whois.test", 20).and_return(response)
25
26
 
26
27
  server.lookup("domain.test")
@@ -30,13 +31,12 @@ describe Whois::Server::Adapters::Standard do
30
31
  context "with bind option" do
31
32
  it "binds the request to given host and port" do
32
33
  response = "Whois Response"
33
- server = described_class.new(:tld, ".test", "whois.test", { :port => 20 })
34
- server.configure(:bind_host => "192.168.1.100", :bind_port => 3000)
34
+ server = described_class.new(:tld, ".test", "whois.test", { port: 20 })
35
+ server.configure(bind_host: "192.168.1.100", bind_port: 3000)
35
36
  expect(server.query_handler).to receive(:call).with("domain.test", "whois.test", 20, "192.168.1.100", 3000).and_return(response)
36
37
 
37
38
  server.lookup("domain.test")
38
39
  end
39
40
  end
40
41
  end
41
-
42
42
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Verisign do
4
-
5
6
  let(:definition) { [:tld, ".test", "whois.test", {}] }
6
7
  let(:server) { described_class.new(*definition) }
7
8
 
@@ -24,7 +25,7 @@ describe Whois::Server::Adapters::Verisign do
24
25
  it "follows all referrals" do
25
26
  referral = File.read(fixture("referrals/crsnic.com.txt"))
26
27
  response = "Match for example.test."
27
- expected = referral + "\n" + response
28
+ expected = "#{referral}\n#{response}"
28
29
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
29
30
  expect(server.query_handler).to receive(:call).with("example.test", "whois.markmonitor.com", 43).and_return(response)
30
31
 
@@ -38,7 +39,7 @@ describe Whois::Server::Adapters::Verisign do
38
39
  referral = File.read(fixture("referrals/crsnic.com.txt"))
39
40
  server.options[:referral] = false
40
41
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
41
- expect(server.query_handler).to receive(:call).never
42
+ expect(server.query_handler).not_to receive(:call)
42
43
 
43
44
  record = server.lookup("example.test")
44
45
  expect(record.parts.size).to eq(1)
@@ -49,12 +50,11 @@ describe Whois::Server::Adapters::Verisign do
49
50
  it "ignores referral (gracefully) if missing" do
50
51
  referral = File.read(fixture("referrals/crsnic.com_referral_missing.txt"))
51
52
  expect(server.query_handler).to receive(:call).with("=example.test", "whois.test", 43).and_return(referral)
52
- expect(server.query_handler).to receive(:call).never
53
+ expect(server.query_handler).not_to receive(:call)
53
54
 
54
55
  record = server.lookup("example.test")
55
56
  expect(record.parts.size).to eq(1)
56
57
  end
57
58
  end
58
59
  end
59
-
60
60
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server::Adapters::Web do
4
-
5
- before(:each) do
6
- @definition = [:tld, ".test", nil, { :url => "http://whois.test" }]
6
+ before do
7
+ @definition = [:tld, ".test", nil, { url: "http://whois.test" }]
7
8
  end
8
9
 
9
10
 
@@ -20,5 +21,4 @@ describe Whois::Server::Adapters::Web do
20
21
  }.to raise_error(Whois::WebInterfaceError, /whois\.test/)
21
22
  end
22
23
  end
23
-
24
24
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'whois/server/socket_handler'
3
5
 
4
6
  describe Whois::Server::SocketHandler do
5
-
6
7
  describe "#call" do
7
- [ Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError ].each do |error|
8
+ [Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError].each do |error|
8
9
  it "re-raises #{error} as Whois::ConnectionError" do
9
10
  expect(subject).to receive(:execute).and_raise(error)
10
11
  expect {
@@ -13,15 +14,16 @@ describe Whois::Server::SocketHandler do
13
14
  end
14
15
 
15
16
  it "executes a socket connection for given args" do
16
- socket = double("Handler")
17
+ socket = instance_double(TCPSocket)
17
18
  expect(socket).to receive(:write).with("example.test\r\n")
18
19
  expect(socket).to receive(:read)
19
20
  expect(socket).to receive(:close)
20
21
 
21
- expect(TCPSocket).to receive(:new).with("whois.test", 43).and_return(socket)
22
+ expect(TCPSocket).to receive(:new)
23
+ .with("whois.test", 43)
24
+ .and_return(socket)
22
25
  subject.call("example.test", "whois.test", 43)
23
26
  end
24
27
  end
25
28
  end
26
-
27
29
  end
@@ -1,41 +1,43 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::Server do
4
6
  describe ".load_json" do
5
7
  it "loads a definition from a JSON file" do
6
- expect(File).to receive(:read).with("tld.json").and_return(<<-JSON)
7
- {
8
- "ae.org": {
9
- "host": "whois.centralnic.com"
10
- },
11
- "ar.com": {
12
- "host": "whois.centralnic.com"
13
- }
14
- }
8
+ expect(File).to receive(:read).with("tld.json").and_return(<<~JSON)
9
+ {
10
+ "ae.org": {
11
+ "host": "whois.centralnic.com"
12
+ },
13
+ "ar.com": {
14
+ "host": "whois.centralnic.com"
15
+ }
16
+ }
15
17
  JSON
16
18
  with_definitions do
17
19
  described_class.load_json("tld.json")
18
20
  expect(described_class.definitions(:tld)).to eq([
19
- ["ae.org", "whois.centralnic.com", {}],
20
- ["ar.com", "whois.centralnic.com", {}],
21
- ])
21
+ ["ae.org", "whois.centralnic.com", {}],
22
+ ["ar.com", "whois.centralnic.com", {}],
23
+ ])
22
24
  end
23
25
  end
24
26
 
25
27
  it "convert option keys to Symbol" do
26
- expect(File).to receive(:read).with("tld.json").and_return(<<-JSON)
27
- {
28
- "com": {
29
- "host": "whois.crsnic.net",
30
- "adapter": "verisign"
31
- }
32
- }
28
+ expect(File).to receive(:read).with("tld.json").and_return(<<~JSON)
29
+ {
30
+ "com": {
31
+ "host": "whois.crsnic.net",
32
+ "adapter": "verisign"
33
+ }
34
+ }
33
35
  JSON
34
36
  with_definitions do
35
37
  described_class.load_json("tld.json")
36
38
  expect(described_class.definitions(:tld)).to eq([
37
- ["com", "whois.crsnic.net", adapter: "verisign"],
38
- ])
39
+ ["com", "whois.crsnic.net", { adapter: "verisign" }],
40
+ ])
39
41
  end
40
42
  end
41
43
  end
@@ -70,7 +72,7 @@ describe Whois::Server do
70
72
  it "accepts a hash of options" do
71
73
  with_definitions do
72
74
  Whois::Server.define(Whois::Server::TYPE_TLD, "foo", "whois.foo", foo: "bar")
73
- expect(described_class.definitions(Whois::Server::TYPE_TLD)).to eq([["foo", "whois.foo", { :foo => "bar" }]])
75
+ expect(described_class.definitions(Whois::Server::TYPE_TLD)).to eq([["foo", "whois.foo", { foo: "bar" }]])
74
76
  end
75
77
  end
76
78
  end
@@ -81,7 +83,7 @@ describe Whois::Server do
81
83
  expect(server.type).to eq(:tld)
82
84
  expect(server.allocation).to eq("test")
83
85
  expect(server.host).to eq("whois.test")
84
- expect(server.options).to eq(Hash.new)
86
+ expect(server.options).to eq({})
85
87
  end
86
88
 
87
89
  it "returns a standard adapter by default" do
@@ -92,25 +94,26 @@ describe Whois::Server do
92
94
  it "accepts an :adapter option as Class and returns an instance of given adapter" do
93
95
  a = Class.new do
94
96
  attr_reader :args
97
+
95
98
  def initialize(*args)
96
99
  @args = args
97
100
  end
98
101
  end
99
- server = Whois::Server.factory(:tld, "test", "whois.test", :adapter => a)
102
+ server = Whois::Server.factory(:tld, "test", "whois.test", adapter: a)
100
103
  expect(server).to be_a(a)
101
104
  expect(server.args).to eq([:tld, "test", "whois.test", {}])
102
105
  end
103
106
 
104
107
  it "accepts an :adapter option as Symbol or String, load Class and returns an instance of given adapter" do
105
- server = Whois::Server.factory(:tld, "test", "whois.test", :adapter => :none)
108
+ server = Whois::Server.factory(:tld, "test", "whois.test", adapter: :none)
106
109
  expect(server).to be_a(Whois::Server::Adapters::None)
107
- server = Whois::Server.factory(:tld, "test", "whois.test", :adapter => "none")
110
+ server = Whois::Server.factory(:tld, "test", "whois.test", adapter: "none")
108
111
  expect(server).to be_a(Whois::Server::Adapters::None)
109
112
  end
110
113
 
111
114
  it "deletes the adapter option" do
112
- server = Whois::Server.factory(:tld, "test", "whois.test", :adapter => Whois::Server::Adapters::None, :foo => "bar")
113
- expect(server.options).to eq({ :foo => "bar" })
115
+ server = Whois::Server.factory(:tld, "test", "whois.test", adapter: Whois::Server::Adapters::None, foo: "bar")
116
+ expect(server.options).to eq({ foo: "bar" })
114
117
  end
115
118
  end
116
119
 
@@ -296,5 +299,4 @@ describe Whois::Server do
296
299
  end
297
300
  end
298
301
  end
299
-
300
302
  end
@@ -1,16 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois::WebInterfaceError do
4
-
5
6
  describe "#initialize" do
6
7
  it "sets the URL" do
7
8
  expect(described_class.new("http://example.com").url).to eq("http://example.com")
8
9
  end
9
10
 
10
11
  it "requires the URL argument" do
11
- expect {
12
+ expect do
12
13
  described_class.new
13
- }.to raise_error(ArgumentError)
14
+ end.to raise_error(ArgumentError)
14
15
  end
15
16
  end
16
17
 
@@ -19,5 +20,4 @@ describe Whois::WebInterfaceError do
19
20
  expect(described_class.new("http://example.com").message).to match(%r{http://example.com})
20
21
  end
21
22
  end
22
-
23
23
  end
@@ -1,15 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Whois do
4
-
5
6
  describe ".lookup" do
6
7
  it "delegates the lookup to a new client" do
7
- client = double()
8
+ client = double
8
9
  expect(client).to receive(:lookup).with("example.com").and_return(:result)
9
10
  expect(Whois::Client).to receive(:new).and_return(client)
10
11
 
11
12
  expect(described_class.lookup("example.com")).to eq(:result)
12
13
  end
13
14
  end
14
-
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whois
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -65,10 +65,17 @@ extra_rdoc_files:
65
65
  - ".yardopts"
66
66
  files:
67
67
  - ".github/FUNDING.yml"
68
+ - ".github/dependabot.yml"
69
+ - ".github/workflows/codeql-analysis.yml"
70
+ - ".github/workflows/release.yml"
71
+ - ".github/workflows/tests.yml"
68
72
  - ".gitignore"
69
73
  - ".rspec"
74
+ - ".rubocop.yml"
75
+ - ".rubocop_opinionated.yml"
76
+ - ".rubocop_todo.yml"
70
77
  - ".simplecov"
71
- - ".travis.yml"
78
+ - ".tool-versions"
72
79
  - ".yardopts"
73
80
  - 4.0-Upgrade.md
74
81
  - CHANGELOG.md
@@ -78,7 +85,6 @@ files:
78
85
  - README.md
79
86
  - Rakefile
80
87
  - bin/console
81
- - bin/setup
82
88
  - bin/whoisrb
83
89
  - data/asn16.json
84
90
  - data/asn32.json
@@ -118,7 +124,6 @@ files:
118
124
  - spec/support/helpers/connectivity_helper.rb
119
125
  - spec/support/helpers/spec_helper.rb
120
126
  - spec/whois/client_spec.rb
121
- - spec/whois/errors_spec.rb
122
127
  - spec/whois/record/part_spec.rb
123
128
  - spec/whois/record_spec.rb
124
129
  - spec/whois/server/adapters/afilias_spec.rb
@@ -133,8 +138,8 @@ files:
133
138
  - spec/whois/server/adapters/web_spec.rb
134
139
  - spec/whois/server/socket_handler_spec.rb
135
140
  - spec/whois/server_spec.rb
141
+ - spec/whois/web_interface_error_spec.rb
136
142
  - spec/whois/whois_spec.rb
137
- - tasks/spec.rake
138
143
  - utils/compare-whois.rb
139
144
  - utils/deftld.rb
140
145
  - utils/defutils.rb
@@ -161,39 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
166
  - !ruby/object:Gem::Version
162
167
  version: '0'
163
168
  requirements: []
164
- rubygems_version: 3.1.2
169
+ rubygems_version: 3.3.7
165
170
  signing_key:
166
171
  specification_version: 4
167
172
  summary: An intelligent pure Ruby WHOIS client and parser.
168
- test_files:
169
- - spec/fixtures/referrals/afilias.bz.txt
170
- - spec/fixtures/referrals/arin_referral_apnic.txt
171
- - spec/fixtures/referrals/arin_referral_missing.txt
172
- - spec/fixtures/referrals/arin_referral_ripe.txt
173
- - spec/fixtures/referrals/arin_referral_rwhois.txt
174
- - spec/fixtures/referrals/arin_referral_servernap.txt
175
- - spec/fixtures/referrals/arin_referral_whois.txt
176
- - spec/fixtures/referrals/crsnic.com.txt
177
- - spec/fixtures/referrals/crsnic.com_referral.txt
178
- - spec/fixtures/referrals/crsnic.com_referral_missing.txt
179
- - spec/integration/whois_spec.rb
180
- - spec/spec_helper.rb
181
- - spec/support/helpers/connectivity_helper.rb
182
- - spec/support/helpers/spec_helper.rb
183
- - spec/whois/client_spec.rb
184
- - spec/whois/errors_spec.rb
185
- - spec/whois/record/part_spec.rb
186
- - spec/whois/record_spec.rb
187
- - spec/whois/server/adapters/afilias_spec.rb
188
- - spec/whois/server/adapters/arin_spec.rb
189
- - spec/whois/server/adapters/arpa_spec.rb
190
- - spec/whois/server/adapters/base_spec.rb
191
- - spec/whois/server/adapters/formatted_spec.rb
192
- - spec/whois/server/adapters/none_spec.rb
193
- - spec/whois/server/adapters/not_implemented_spec.rb
194
- - spec/whois/server/adapters/standard_spec.rb
195
- - spec/whois/server/adapters/verisign_spec.rb
196
- - spec/whois/server/adapters/web_spec.rb
197
- - spec/whois/server/socket_handler_spec.rb
198
- - spec/whois/server_spec.rb
199
- - spec/whois/whois_spec.rb
173
+ test_files: []