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
@@ -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 do
6
6
  describe ".load_json" do
@@ -45,7 +45,7 @@ describe Whois::Server do
45
45
  describe ".definitions" do
46
46
  it "returns the definitions array for given type" do
47
47
  with_definitions do
48
- Whois::Server.define(Whois::Server::TYPE_TLD, "foo", "whois.foo")
48
+ described_class.define(Whois::Server::TYPE_TLD, "foo", "whois.foo")
49
49
  definition = described_class.definitions(Whois::Server::TYPE_TLD)
50
50
  expect(definition).to be_a(Array)
51
51
  expect(definition).to eq([["foo", "whois.foo", {}]])
@@ -64,14 +64,14 @@ describe Whois::Server do
64
64
  describe ".define" do
65
65
  it "adds a new definition with given arguments" do
66
66
  with_definitions do
67
- Whois::Server.define(Whois::Server::TYPE_TLD, "foo", "whois.foo")
67
+ described_class.define(Whois::Server::TYPE_TLD, "foo", "whois.foo")
68
68
  expect(described_class.definitions(Whois::Server::TYPE_TLD)).to eq([["foo", "whois.foo", {}]])
69
69
  end
70
70
  end
71
71
 
72
72
  it "accepts a hash of options" do
73
73
  with_definitions do
74
- Whois::Server.define(Whois::Server::TYPE_TLD, "foo", "whois.foo", foo: "bar")
74
+ described_class.define(Whois::Server::TYPE_TLD, "foo", "whois.foo", foo: "bar")
75
75
  expect(described_class.definitions(Whois::Server::TYPE_TLD)).to eq([["foo", "whois.foo", { foo: "bar" }]])
76
76
  end
77
77
  end
@@ -79,7 +79,7 @@ describe Whois::Server do
79
79
 
80
80
  describe ".factory" do
81
81
  it "returns an adapter initialized with given arguments" do
82
- server = Whois::Server.factory(:tld, "test", "whois.test")
82
+ server = described_class.factory(:tld, "test", "whois.test")
83
83
  expect(server.type).to eq(:tld)
84
84
  expect(server.allocation).to eq("test")
85
85
  expect(server.host).to eq("whois.test")
@@ -87,7 +87,7 @@ describe Whois::Server do
87
87
  end
88
88
 
89
89
  it "returns a standard adapter by default" do
90
- server = Whois::Server.factory(:tld, "test", "whois.test")
90
+ server = described_class.factory(:tld, "test", "whois.test")
91
91
  expect(server).to be_a(Whois::Server::Adapters::Standard)
92
92
  end
93
93
 
@@ -99,115 +99,115 @@ describe Whois::Server do
99
99
  @args = args
100
100
  end
101
101
  end
102
- server = Whois::Server.factory(:tld, "test", "whois.test", adapter: a)
102
+ server = described_class.factory(:tld, "test", "whois.test", adapter: a)
103
103
  expect(server).to be_a(a)
104
104
  expect(server.args).to eq([:tld, "test", "whois.test", {}])
105
105
  end
106
106
 
107
107
  it "accepts an :adapter option as Symbol or String, load Class and returns an instance of given adapter" do
108
- server = Whois::Server.factory(:tld, "test", "whois.test", adapter: :none)
108
+ server = described_class.factory(:tld, "test", "whois.test", adapter: :none)
109
109
  expect(server).to be_a(Whois::Server::Adapters::None)
110
- server = Whois::Server.factory(:tld, "test", "whois.test", adapter: "none")
110
+ server = described_class.factory(:tld, "test", "whois.test", adapter: "none")
111
111
  expect(server).to be_a(Whois::Server::Adapters::None)
112
112
  end
113
113
 
114
114
  it "deletes the adapter option" do
115
- server = Whois::Server.factory(:tld, "test", "whois.test", adapter: Whois::Server::Adapters::None, foo: "bar")
115
+ server = described_class.factory(:tld, "test", "whois.test", adapter: Whois::Server::Adapters::None, foo: "bar")
116
116
  expect(server.options).to eq({ foo: "bar" })
117
117
  end
118
118
  end
119
119
 
120
120
  describe ".guess" do
121
121
  it "recognizes tld" do
122
- server = Whois::Server.guess(".com")
122
+ server = described_class.guess(".com")
123
123
  expect(server).to be_a(Whois::Server::Adapters::Base)
124
124
  expect(server.type).to eq(Whois::Server::TYPE_TLD)
125
125
  end
126
126
 
127
127
  it "recognizes domain" do
128
- server = Whois::Server.guess("example.com")
128
+ server = described_class.guess("example.com")
129
129
  expect(server).to be_a(Whois::Server::Adapters::Base)
130
130
  expect(server.type).to eq(Whois::Server::TYPE_TLD)
131
131
  end
132
132
 
133
133
  it "recognizes ipv4" do
134
- server = Whois::Server.guess("127.0.0.1")
134
+ server = described_class.guess("127.0.0.1")
135
135
  expect(server).to be_a(Whois::Server::Adapters::Base)
136
136
  expect(server.type).to eq(Whois::Server::TYPE_IPV4)
137
137
  end
138
138
 
139
139
  it "recognizes ipv6" do
140
- server = Whois::Server.guess("2001:0db8:85a3:0000:0000:8a2e:0370:7334")
140
+ server = described_class.guess("2001:0db8:85a3:0000:0000:8a2e:0370:7334")
141
141
  expect(server).to be_a(Whois::Server::Adapters::Base)
142
142
  expect(server.type).to eq(Whois::Server::TYPE_IPV6)
143
143
  end
144
144
 
145
145
  it "recognizes ipv6 when zero groups" do
146
- server = Whois::Server.guess("2002::1")
146
+ server = described_class.guess("2002::1")
147
147
  expect(server).to be_a(Whois::Server::Adapters::Base)
148
148
  expect(server.type).to eq(Whois::Server::TYPE_IPV6)
149
149
  end
150
150
 
151
151
  it "recognizes asn16" do
152
- server = Whois::Server.guess("AS23456")
152
+ server = described_class.guess("AS23456")
153
153
  expect(server).to be_a(Whois::Server::Adapters::Base)
154
154
  expect(server.type).to eq(Whois::Server::TYPE_ASN16)
155
155
  end
156
156
 
157
157
  it "recognizes asn32" do
158
- server = Whois::Server.guess("AS131072")
158
+ server = described_class.guess("AS131072")
159
159
  expect(server).to be_a(Whois::Server::Adapters::Base)
160
160
  expect(server.type).to eq(Whois::Server::TYPE_ASN32)
161
161
  end
162
162
 
163
163
  it "recognizes email" do
164
164
  expect {
165
- Whois::Server.guess("email@example.org")
165
+ described_class.guess("email@example.org")
166
166
  }.to raise_error(Whois::ServerNotSupported, /email/)
167
167
  end
168
168
 
169
169
  it "raises when unrecognized value" do
170
170
  expect {
171
- Whois::Server.guess("invalid")
171
+ described_class.guess("invalid")
172
172
  }.to raise_error(Whois::ServerNotFound)
173
173
  end
174
174
 
175
175
 
176
176
  context "when the input is a tld" do
177
177
  it "returns a IANA adapter" do
178
- expect(Whois::Server.guess(".com")).to eq(Whois::Server.factory(:tld, ".", "whois.iana.org"))
178
+ expect(described_class.guess(".com")).to eq(described_class.factory(:tld, ".", "whois.iana.org"))
179
179
  end
180
180
 
181
181
  it "returns a IANA adapter when the input is an idn" do
182
- expect(Whois::Server.guess(".xn--fiqs8s")).to eq(Whois::Server.factory(:tld, ".", "whois.iana.org"))
182
+ expect(described_class.guess(".xn--fiqs8s")).to eq(described_class.factory(:tld, ".", "whois.iana.org"))
183
183
  end
184
184
  end
185
185
 
186
186
  context "when the input is a domain" do
187
187
  it "lookups definitions and returns the adapter" do
188
188
  with_definitions do
189
- Whois::Server.define(:tld, "test", "whois.test")
190
- expect(Whois::Server.guess("example.test")).to eq(Whois::Server.factory(:tld, "test", "whois.test"))
189
+ described_class.define(:tld, "test", "whois.test")
190
+ expect(described_class.guess("example.test")).to eq(described_class.factory(:tld, "test", "whois.test"))
191
191
  end
192
192
  end
193
193
 
194
194
  it "doesn't consider the dot as a regexp pattern" do
195
195
  with_definitions do
196
- Whois::Server.define(:tld, "no.com", "whois.no.com")
197
- Whois::Server.define(:tld, "com", "whois.com")
198
- expect(Whois::Server.guess("antoniocangiano.com")).to eq(Whois::Server.factory(:tld, "com", "whois.com"))
196
+ described_class.define(:tld, "no.com", "whois.no.com")
197
+ described_class.define(:tld, "com", "whois.com")
198
+ expect(described_class.guess("antoniocangiano.com")).to eq(described_class.factory(:tld, "com", "whois.com"))
199
199
  end
200
200
  end
201
201
 
202
202
  it "returns the closer definition" do
203
203
  with_definitions do
204
- Whois::Server.define(:tld, "com", com = "whois.com")
205
- Whois::Server.define(:tld, "com.foo", comfoo = "whois.com.foo")
206
- Whois::Server.define(:tld, "foo.com", foocom = "whois.foo.com")
204
+ described_class.define(:tld, "com", com = "whois.com")
205
+ described_class.define(:tld, "com.foo", comfoo = "whois.com.foo")
206
+ described_class.define(:tld, "foo.com", foocom = "whois.foo.com")
207
207
 
208
- expect(Whois::Server.guess("example.com").host).to eq(com)
209
- expect(Whois::Server.guess("example.com.foo").host).to eq(comfoo)
210
- expect(Whois::Server.guess("example.foo.com").host).to eq(foocom)
208
+ expect(described_class.guess("example.com").host).to eq(com)
209
+ expect(described_class.guess("example.com.foo").host).to eq(comfoo)
210
+ expect(described_class.guess("example.foo.com").host).to eq(foocom)
211
211
  end
212
212
  end
213
213
  end
@@ -215,16 +215,16 @@ describe Whois::Server do
215
215
  context "when the input is an asn16" do
216
216
  it "lookups definitions and returns the adapter" do
217
217
  with_definitions do
218
- Whois::Server.define(:asn16, "0 65535", "whois.test")
219
- expect(Whois::Server.guess("AS65535")).to eq(Whois::Server.factory(:asn16, "0 65535", "whois.test"))
218
+ described_class.define(:asn16, "0 65535", "whois.test")
219
+ expect(described_class.guess("AS65535")).to eq(described_class.factory(:asn16, "0 65535", "whois.test"))
220
220
  end
221
221
  end
222
222
 
223
223
  it "raises if definition is not found" do
224
224
  with_definitions do
225
- Whois::Server.define(:asn16, "0 60000", "whois.test")
225
+ described_class.define(:asn16, "0 60000", "whois.test")
226
226
  expect {
227
- Whois::Server.guess("AS65535")
227
+ described_class.guess("AS65535")
228
228
  }.to raise_error(Whois::AllocationUnknown)
229
229
  end
230
230
  end
@@ -233,16 +233,16 @@ describe Whois::Server do
233
233
  context "when the input is an asn32" do
234
234
  it "lookups definitions and returns the adapter" do
235
235
  with_definitions do
236
- Whois::Server.define(:asn32, "65536 394239", "whois.test")
237
- expect(Whois::Server.guess("AS65536")).to eq(Whois::Server.factory(:asn32, "65536 394239", "whois.test"))
236
+ described_class.define(:asn32, "65536 394239", "whois.test")
237
+ expect(described_class.guess("AS65536")).to eq(described_class.factory(:asn32, "65536 394239", "whois.test"))
238
238
  end
239
239
  end
240
240
 
241
241
  it "raises if definition is not found" do
242
242
  with_definitions do
243
- Whois::Server.define(:asn32, "65536 131071", "whois.test")
243
+ described_class.define(:asn32, "65536 131071", "whois.test")
244
244
  expect {
245
- Whois::Server.guess("AS200000")
245
+ described_class.guess("AS200000")
246
246
  }.to raise_error(Whois::AllocationUnknown)
247
247
  end
248
248
  end
@@ -251,16 +251,16 @@ describe Whois::Server do
251
251
  context "when the input is a ipv4" do
252
252
  it "lookups definitions and returns the adapter" do
253
253
  with_definitions do
254
- Whois::Server.define(:ipv4, "192.168.1.0/10", "whois.test")
255
- expect(Whois::Server.find_for_ip("192.168.1.1")).to eq(Whois::Server.factory(:ipv4, "192.168.1.0/10", "whois.test"))
254
+ described_class.define(:ipv4, "192.168.1.0/10", "whois.test")
255
+ expect(described_class.find_for_ip("192.168.1.1")).to eq(described_class.factory(:ipv4, "192.168.1.0/10", "whois.test"))
256
256
  end
257
257
  end
258
258
 
259
259
  it "raises if definition is not found" do
260
260
  with_definitions do
261
- Whois::Server.define(:ipv4, "192.168.1.0/10", "whois.test")
261
+ described_class.define(:ipv4, "192.168.1.0/10", "whois.test")
262
262
  expect {
263
- Whois::Server.guess("192.192.0.1")
263
+ described_class.guess("192.192.0.1")
264
264
  }.to raise_error(Whois::AllocationUnknown)
265
265
  end
266
266
  end
@@ -269,31 +269,31 @@ describe Whois::Server do
269
269
  context "when the input is a ipv6" do
270
270
  it "lookups definitions and returns the adapter" do
271
271
  with_definitions do
272
- Whois::Server.define(:ipv6, "2001:0200::/23", "whois.test")
273
- expect(Whois::Server.guess("2001:0200::1")).to eq(Whois::Server.factory(:ipv6, "2001:0200::/23", "whois.test"))
272
+ described_class.define(:ipv6, "2001:0200::/23", "whois.test")
273
+ expect(described_class.guess("2001:0200::1")).to eq(described_class.factory(:ipv6, "2001:0200::/23", "whois.test"))
274
274
  end
275
275
  end
276
276
 
277
277
  it "raises if definition is not found" do
278
278
  with_definitions do
279
- Whois::Server.define(:ipv6, "::1", "whois.test")
279
+ described_class.define(:ipv6, "::1", "whois.test")
280
280
  expect {
281
- Whois::Server.guess("2002:0300::1")
281
+ described_class.guess("2002:0300::1")
282
282
  }.to raise_error(Whois::AllocationUnknown)
283
283
  end
284
284
  end
285
285
 
286
286
  it "recognizes ipv4 compatibility mode" do
287
287
  with_definitions do
288
- Whois::Server.define(:ipv6, "::192.168.1.1", "whois.test")
289
- expect(Whois::Server.guess("::192.168.1.1")).to eq(Whois::Server.factory(:ipv6, "::192.168.1.1", "whois.test"))
288
+ described_class.define(:ipv6, "::192.168.1.1", "whois.test")
289
+ expect(described_class.guess("::192.168.1.1")).to eq(described_class.factory(:ipv6, "::192.168.1.1", "whois.test"))
290
290
  end
291
291
  end
292
292
 
293
293
  it "rescues IPAddr ArgumentError", issue: "weppos/whois#174" do
294
294
  with_definitions do
295
295
  expect {
296
- Whois::Server.guess("f53")
296
+ described_class.guess("f53")
297
297
  }.to raise_error(Whois::AllocationUnknown)
298
298
  end
299
299
  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::WebInterfaceError 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 do
6
6
  describe ".lookup" do
data/utils/deftld.rb CHANGED
@@ -35,7 +35,6 @@ class TldDefs
35
35
  format: :format,
36
36
  url: :url,
37
37
 
38
- group: :_group,
39
38
  note: :_note,
40
39
  type: :_type,
41
40
  }
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: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-05 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.5.11
170
+ rubygems_version: 3.5.22
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: An intelligent pure Ruby WHOIS client and parser.