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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/codeql-analysis.yml +64 -0
- data/.github/workflows/release.yml +16 -0
- data/.github/workflows/tests.yml +29 -0
- data/.rubocop.yml +27 -0
- data/.rubocop_opinionated.yml +135 -0
- data/.rubocop_todo.yml +166 -0
- data/.simplecov +2 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +76 -53
- data/CONTRIBUTING.md +12 -12
- data/Gemfile +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -22
- data/Rakefile +12 -17
- data/bin/console +1 -0
- data/bin/whoisrb +3 -2
- data/data/ipv4.json +1 -3
- data/data/tld.json +2 -99
- data/lib/whois/client.rb +4 -2
- data/lib/whois/errors.rb +4 -2
- data/lib/whois/record/part.rb +5 -4
- data/lib/whois/record.rb +4 -2
- data/lib/whois/server/adapters/afilias.rb +4 -1
- data/lib/whois/server/adapters/arin.rb +7 -4
- data/lib/whois/server/adapters/arpa.rb +20 -19
- data/lib/whois/server/adapters/base.rb +26 -40
- data/lib/whois/server/adapters/formatted.rb +4 -2
- data/lib/whois/server/adapters/none.rb +3 -1
- data/lib/whois/server/adapters/not_implemented.rb +3 -1
- data/lib/whois/server/adapters/standard.rb +4 -2
- data/lib/whois/server/adapters/verisign.rb +4 -1
- data/lib/whois/server/adapters/web.rb +3 -1
- data/lib/whois/server/socket_handler.rb +8 -6
- data/lib/whois/server.rb +41 -47
- data/lib/whois/version.rb +4 -2
- data/lib/whois.rb +13 -11
- data/spec/integration/whois_spec.rb +6 -6
- data/spec/spec_helper.rb +4 -4
- data/spec/support/helpers/connectivity_helper.rb +3 -3
- data/spec/support/helpers/spec_helper.rb +2 -0
- data/spec/whois/client_spec.rb +6 -7
- data/spec/whois/record/part_spec.rb +4 -4
- data/spec/whois/record_spec.rb +9 -7
- data/spec/whois/server/adapters/afilias_spec.rb +4 -4
- data/spec/whois/server/adapters/arin_spec.rb +9 -10
- data/spec/whois/server/adapters/arpa_spec.rb +2 -2
- data/spec/whois/server/adapters/base_spec.rb +13 -13
- data/spec/whois/server/adapters/formatted_spec.rb +8 -8
- data/spec/whois/server/adapters/none_spec.rb +2 -2
- data/spec/whois/server/adapters/not_implemented_spec.rb +4 -4
- data/spec/whois/server/adapters/standard_spec.rb +5 -5
- data/spec/whois/server/adapters/verisign_spec.rb +5 -5
- data/spec/whois/server/adapters/web_spec.rb +4 -4
- data/spec/whois/server/socket_handler_spec.rb +7 -5
- data/spec/whois/server_spec.rb +31 -29
- data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
- data/spec/whois/whois_spec.rb +3 -3
- metadata +13 -39
- data/.travis.yml +0 -18
- data/bin/setup +0 -8
- data/tasks/spec.rake +0 -199
data/.travis.yml
DELETED
data/bin/setup
DELETED
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
|