whois 5.0.1 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +6 -2
  3. data/.github/dependabot.yml +19 -0
  4. data/.github/workflows/codeql-analysis.yml +64 -0
  5. data/.github/workflows/release.yml +16 -0
  6. data/.github/workflows/tests.yml +30 -0
  7. data/.rubocop.yml +27 -0
  8. data/.rubocop_opinionated.yml +135 -0
  9. data/.rubocop_todo.yml +166 -0
  10. data/.simplecov +2 -0
  11. data/.tool-versions +1 -0
  12. data/CHANGELOG.md +86 -54
  13. data/CONTRIBUTING.md +12 -12
  14. data/Gemfile +6 -1
  15. data/LICENSE.txt +1 -1
  16. data/README.md +22 -22
  17. data/Rakefile +12 -17
  18. data/bin/console +1 -0
  19. data/bin/whoisrb +4 -3
  20. data/data/ipv4.json +1 -3
  21. data/data/tld.json +10 -103
  22. data/lib/whois/client.rb +4 -2
  23. data/lib/whois/errors.rb +4 -2
  24. data/lib/whois/record/part.rb +5 -4
  25. data/lib/whois/record.rb +4 -2
  26. data/lib/whois/server/adapters/afilias.rb +4 -1
  27. data/lib/whois/server/adapters/arin.rb +7 -4
  28. data/lib/whois/server/adapters/arpa.rb +20 -19
  29. data/lib/whois/server/adapters/base.rb +26 -40
  30. data/lib/whois/server/adapters/formatted.rb +4 -2
  31. data/lib/whois/server/adapters/none.rb +3 -1
  32. data/lib/whois/server/adapters/not_implemented.rb +3 -1
  33. data/lib/whois/server/adapters/standard.rb +4 -2
  34. data/lib/whois/server/adapters/verisign.rb +4 -1
  35. data/lib/whois/server/adapters/web.rb +3 -1
  36. data/lib/whois/server/socket_handler.rb +8 -6
  37. data/lib/whois/server.rb +41 -47
  38. data/lib/whois/version.rb +4 -2
  39. data/lib/whois.rb +15 -13
  40. data/spec/integration/whois_spec.rb +7 -7
  41. data/spec/spec_helper.rb +4 -4
  42. data/spec/support/helpers/connectivity_helper.rb +3 -3
  43. data/spec/support/helpers/spec_helper.rb +2 -0
  44. data/spec/whois/client_spec.rb +8 -9
  45. data/spec/whois/record/part_spec.rb +4 -4
  46. data/spec/whois/record_spec.rb +11 -9
  47. data/spec/whois/server/adapters/afilias_spec.rb +4 -4
  48. data/spec/whois/server/adapters/arin_spec.rb +9 -10
  49. data/spec/whois/server/adapters/arpa_spec.rb +2 -2
  50. data/spec/whois/server/adapters/base_spec.rb +13 -13
  51. data/spec/whois/server/adapters/formatted_spec.rb +8 -8
  52. data/spec/whois/server/adapters/none_spec.rb +2 -2
  53. data/spec/whois/server/adapters/not_implemented_spec.rb +4 -4
  54. data/spec/whois/server/adapters/standard_spec.rb +5 -5
  55. data/spec/whois/server/adapters/verisign_spec.rb +5 -5
  56. data/spec/whois/server/adapters/web_spec.rb +4 -4
  57. data/spec/whois/server/socket_handler_spec.rb +7 -5
  58. data/spec/whois/server_spec.rb +31 -29
  59. data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
  60. data/spec/whois/whois_spec.rb +3 -3
  61. data/whois.gemspec +10 -10
  62. metadata +16 -11
  63. data/.travis.yml +0 -18
  64. data/bin/setup +0 -8
  65. data/tasks/spec.rake +0 -199
@@ -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
data/whois.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'whois/version'
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "whois/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'whois'
6
+ s.name = "whois"
7
7
  s.version = Whois::VERSION
8
- s.authors = ['Simone Carletti']
9
- s.email = ['weppos@weppos.net']
10
- s.homepage = 'https://whoisrb.org/'
11
- s.summary = 'An intelligent pure Ruby WHOIS client and parser.'
12
- s.description = 'Whois is an intelligent WHOIS client and parser written in pure Ruby. It can query registry data for IPv4, IPv6 and top level domains, and parse the responses into easy-to-use Ruby objects via the whois-parser library.'
13
- s.license = 'MIT'
8
+ s.authors = ["Simone Carletti"]
9
+ s.email = ["weppos@weppos.net"]
10
+ s.homepage = "https://whoisrb.org/"
11
+ s.summary = "An intelligent pure Ruby WHOIS client and parser."
12
+ s.description = "Whois is an intelligent WHOIS client and parser written in pure Ruby. It can query registry data for IPv4, IPv6 and top level domains, and parse the responses into easy-to-use Ruby objects via the whois-parser library."
13
+ s.license = "MIT"
14
14
 
15
- s.required_ruby_version = '>= 2.4'
15
+ s.required_ruby_version = ">= 2.4"
16
16
 
17
17
  s.require_paths = %w( lib )
18
18
  s.executables =%w( whoisrb )
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2023-11-08 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
@@ -146,7 +151,7 @@ homepage: https://whoisrb.org/
146
151
  licenses:
147
152
  - MIT
148
153
  metadata: {}
149
- post_install_message:
154
+ post_install_message:
150
155
  rdoc_options: []
151
156
  require_paths:
152
157
  - lib
@@ -161,8 +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
165
- signing_key:
169
+ rubygems_version: 3.4.21
170
+ signing_key:
166
171
  specification_version: 4
167
172
  summary: An intelligent pure Ruby WHOIS client and parser.
168
173
  test_files:
@@ -181,7 +186,6 @@ test_files:
181
186
  - spec/support/helpers/connectivity_helper.rb
182
187
  - spec/support/helpers/spec_helper.rb
183
188
  - spec/whois/client_spec.rb
184
- - spec/whois/errors_spec.rb
185
189
  - spec/whois/record/part_spec.rb
186
190
  - spec/whois/record_spec.rb
187
191
  - spec/whois/server/adapters/afilias_spec.rb
@@ -196,4 +200,5 @@ test_files:
196
200
  - spec/whois/server/adapters/web_spec.rb
197
201
  - spec/whois/server/socket_handler_spec.rb
198
202
  - spec/whois/server_spec.rb
203
+ - spec/whois/web_interface_error_spec.rb
199
204
  - spec/whois/whois_spec.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - "2.4"
5
- - "2.5"
6
- - "2.6"
7
- - "2.7"
8
- - ruby-head
9
-
10
- cache:
11
- - bundler
12
-
13
- matrix:
14
- allow_failures:
15
- - rvm: ruby-head
16
-
17
- before_install:
18
- - gem install bundler
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/tasks/spec.rake DELETED
@@ -1,199 +0,0 @@
1
- require 'fileutils'
2
-
3
- namespace :spec do
4
-
5
- ROOT_DIR = File.expand_path("../../", __FILE__)
6
- TARGET_DIR = File.join(ROOT_DIR, %w( spec whois record parser responses ))
7
-
8
- SOURCE_DIR = File.join(ROOT_DIR, %w( spec fixtures responses ))
9
- SOURCE_PARTS = SOURCE_DIR.split("/")
10
-
11
-
12
- TPL_DESCRIBE = <<-RUBY.chomp!
13
- # encoding: utf-8
14
-
15
- # This file is autogenerated. Do not edit it manually.
16
- # If you want change the content of this file, edit
17
- #
18
- # %{sfile}
19
- #
20
- # and regenerate the tests with the following rake task
21
- #
22
- # $ rake spec:generate
23
- #
24
-
25
- require 'spec_helper'
26
- require 'whois/record/parser/%{khost}.rb'
27
-
28
- describe %{described_class}, "%{descr}" do
29
-
30
- subject do
31
- file = fixture("responses", "%{fixture}")
32
- part = Whois::Record::Part.new(body: File.read(file))
33
- described_class.new(part)
34
- end
35
-
36
- %{contexts}
37
- end
38
- RUBY
39
-
40
- TPL_CONTEXT = <<-RUBY.chomp!
41
- describe "#%{descr}" do
42
- it do
43
- %{examples}
44
- end
45
- end
46
- RUBY
47
-
48
- TPL_MATCH = <<-RUBY.chomp!
49
- expect(subject.%{attribute}).to %{match}
50
- RUBY
51
-
52
- TPL_MATCH_SIZE = <<-RUBY.chomp!
53
- expect(subject.%{attribute}.size).to eq(%{size})
54
- RUBY
55
-
56
- TPL_MATCH_RAISE = <<-RUBY.chomp!
57
- expect { subject.%{attribute} }.to %{match}
58
- RUBY
59
-
60
- def relativize(path)
61
- path.gsub(ROOT_DIR, "")
62
- end
63
-
64
-
65
- task :generate => :generate_parsers
66
-
67
- task :generate_parsers do
68
- Dir["#{SOURCE_DIR}/**/*.expected"].each do |source_path|
69
-
70
- # Generate the filename and described_class name from the test file.
71
- parts = (source_path.split("/") - SOURCE_PARTS)
72
- khost = parts.first
73
- kfile = parts.last
74
- described_class = Whois::Record::Parser.parser_klass(khost)
75
-
76
- target_path = File.join(TARGET_DIR, *parts).gsub(".expected", "_spec.rb")
77
-
78
- # Extract the tests from the test file
79
- # and generates a Hash.
80
- #
81
- # {
82
- # "domain" => [
83
- # ["%s", "== \"google.biz\""]
84
- # ],
85
- # "created_on" => [
86
- # ["%s", "be_a(Time)"],
87
- # ["%s", "== Time.parse(\"2002-03-27 00:01:00 UTC\")"]
88
- # ]
89
- # }
90
- #
91
- tests = {}
92
- match = nil
93
- lines = File.open(source_path, "r:UTF-8")
94
- lines.each do |line|
95
- line.chomp!
96
- case line
97
- when ""
98
- # skip empty line
99
- when /^\s*$/, /^\s*\/\//
100
- # skip comment line
101
- when /^#([^\s]+)/
102
- tests[match = $1] = []
103
- when /^\s+(.+?) (.+)/
104
- tests[match] << _parse_assertion($1, $2)
105
- else
106
- raise "Invalid Line `#{line}' in `#{source_path}'"
107
- end
108
- end
109
-
110
- # Generate the RSpec content and
111
- # write one file for every test.
112
- contexts = tests.map do |attr, specs|
113
- matches = specs.map do |method, condition|
114
- attribute = method % attr
115
- case condition
116
- when /raise_error/
117
- TPL_MATCH_RAISE % { attribute: attribute, match: condition }
118
- when /^%SIZE\{(\d+)\}$/
119
- TPL_MATCH_SIZE % { attribute: attribute, size: $1 }
120
- else
121
- TPL_MATCH % { attribute: attribute, match: condition }
122
- end
123
- end.join("\n")
124
- TPL_CONTEXT % { descr: attr, examples: matches }
125
- end.join("\n")
126
-
127
- describe = <<-RUBY
128
- #{TPL_DESCRIBE % {
129
- :described_class => described_class,
130
- :khost => khost,
131
- :descr => kfile,
132
- :sfile => relativize(source_path),
133
- :fixture => parts.join("/").gsub(".expected", ".txt"),
134
- :contexts => contexts
135
- }}
136
- RUBY
137
-
138
- print "Generating #{relativize(target_path)}... "
139
- File.dirname(target_path).tap { |d| File.exists?(d) || FileUtils.mkdir_p(d) }
140
- File.open(target_path, "w+") { |f| f.write(describe) }
141
- print "done!\n"
142
- end
143
-
144
- end
145
-
146
-
147
- def _parse_assertion(method, condition)
148
- m = method
149
- c = condition.strip
150
-
151
- case
152
-
153
- # %s %CLASS{time} -> %s be_a(time)
154
- when c =~ /^%CLASS\{(.+)\}$/
155
- c = "be_a(#{_build_condition_typeof($1)})"
156
-
157
- # %s %TIME{...} -> %s Time.parse(...)
158
- when c =~ /^%TIME\{(.+)\}$/
159
- c = "eq(Time.parse(\"#{$1}\"))"
160
-
161
- # %s %ERROR{...} -> %s raise_error(...)
162
- when c =~ /^%ERROR\{(.+)\}$/
163
- c = "raise_error(Whois::#{$1})"
164
-
165
- # %s =~ "foo"
166
- when c =~ /^%MATCH\{(.+)\}$/
167
- c = "match(/#{$1}/)"
168
-
169
- # %s == "foo"
170
- when c =~ /^== (.+)$/
171
- c = "eq(#{$1})"
172
-
173
- end
174
-
175
- [m, c]
176
- end
177
-
178
- def _build_condition_typeof(described_class)
179
- case described_class
180
- when "array" then "Array"
181
- when "time" then "Time"
182
- when "contact" then "Whois::Record::Contact"
183
- when "registrar" then "Whois::Record::Registrar"
184
- when "nameserver" then "Whois::Record::Nameserver"
185
- else
186
- raise "Unknown class `#{described_class}'"
187
- end
188
- end
189
-
190
- def _build_condition_typecast(described_class, value)
191
- case described_class
192
- when "time"
193
- %Q{Time.parse("#{value}")}
194
- else
195
- raise "Unknown class `#{described_class}'"
196
- end
197
- end
198
-
199
- end