whois 5.0.1 → 5.0.2

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.rubocop_opinionated.yml +157 -0
  4. data/.rubocop_todo.yml +242 -0
  5. data/.simplecov +2 -0
  6. data/.tool-versions +1 -0
  7. data/CHANGELOG.md +68 -53
  8. data/Gemfile +5 -0
  9. data/LICENSE.txt +1 -1
  10. data/README.md +1 -1
  11. data/Rakefile +12 -17
  12. data/bin/console +1 -0
  13. data/bin/whoisrb +3 -2
  14. data/data/ipv4.json +1 -3
  15. data/data/tld.json +2 -90
  16. data/lib/whois.rb +12 -10
  17. data/lib/whois/client.rb +4 -2
  18. data/lib/whois/errors.rb +4 -2
  19. data/lib/whois/record.rb +3 -1
  20. data/lib/whois/record/part.rb +4 -3
  21. data/lib/whois/server.rb +26 -21
  22. data/lib/whois/server/adapters/afilias.rb +4 -1
  23. data/lib/whois/server/adapters/arin.rb +5 -2
  24. data/lib/whois/server/adapters/arpa.rb +22 -19
  25. data/lib/whois/server/adapters/base.rb +4 -4
  26. data/lib/whois/server/adapters/formatted.rb +4 -2
  27. data/lib/whois/server/adapters/none.rb +3 -1
  28. data/lib/whois/server/adapters/not_implemented.rb +3 -1
  29. data/lib/whois/server/adapters/standard.rb +4 -2
  30. data/lib/whois/server/adapters/verisign.rb +4 -1
  31. data/lib/whois/server/adapters/web.rb +3 -1
  32. data/lib/whois/server/socket_handler.rb +8 -6
  33. data/lib/whois/version.rb +4 -2
  34. data/spec/integration/whois_spec.rb +6 -6
  35. data/spec/spec_helper.rb +4 -2
  36. data/spec/support/helpers/connectivity_helper.rb +2 -0
  37. data/spec/support/helpers/spec_helper.rb +2 -0
  38. data/spec/whois/client_spec.rb +6 -7
  39. data/spec/whois/record/part_spec.rb +4 -4
  40. data/spec/whois/record_spec.rb +9 -7
  41. data/spec/whois/server/adapters/afilias_spec.rb +3 -3
  42. data/spec/whois/server/adapters/arin_spec.rb +7 -8
  43. data/spec/whois/server/adapters/arpa_spec.rb +2 -2
  44. data/spec/whois/server/adapters/base_spec.rb +13 -13
  45. data/spec/whois/server/adapters/formatted_spec.rb +7 -7
  46. data/spec/whois/server/adapters/none_spec.rb +2 -2
  47. data/spec/whois/server/adapters/not_implemented_spec.rb +3 -3
  48. data/spec/whois/server/adapters/standard_spec.rb +5 -5
  49. data/spec/whois/server/adapters/verisign_spec.rb +3 -3
  50. data/spec/whois/server/adapters/web_spec.rb +3 -3
  51. data/spec/whois/server/socket_handler_spec.rb +7 -5
  52. data/spec/whois/server_spec.rb +31 -29
  53. data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
  54. data/spec/whois/whois_spec.rb +3 -3
  55. metadata +11 -8
  56. data/tasks/spec.rake +0 -199
@@ -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.0.2
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: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -67,7 +67,11 @@ files:
67
67
  - ".github/FUNDING.yml"
68
68
  - ".gitignore"
69
69
  - ".rspec"
70
+ - ".rubocop.yml"
71
+ - ".rubocop_opinionated.yml"
72
+ - ".rubocop_todo.yml"
70
73
  - ".simplecov"
74
+ - ".tool-versions"
71
75
  - ".travis.yml"
72
76
  - ".yardopts"
73
77
  - 4.0-Upgrade.md
@@ -118,7 +122,6 @@ files:
118
122
  - spec/support/helpers/connectivity_helper.rb
119
123
  - spec/support/helpers/spec_helper.rb
120
124
  - spec/whois/client_spec.rb
121
- - spec/whois/errors_spec.rb
122
125
  - spec/whois/record/part_spec.rb
123
126
  - spec/whois/record_spec.rb
124
127
  - spec/whois/server/adapters/afilias_spec.rb
@@ -133,8 +136,8 @@ files:
133
136
  - spec/whois/server/adapters/web_spec.rb
134
137
  - spec/whois/server/socket_handler_spec.rb
135
138
  - spec/whois/server_spec.rb
139
+ - spec/whois/web_interface_error_spec.rb
136
140
  - spec/whois/whois_spec.rb
137
- - tasks/spec.rake
138
141
  - utils/compare-whois.rb
139
142
  - utils/deftld.rb
140
143
  - utils/defutils.rb
@@ -146,7 +149,7 @@ homepage: https://whoisrb.org/
146
149
  licenses:
147
150
  - MIT
148
151
  metadata: {}
149
- post_install_message:
152
+ post_install_message:
150
153
  rdoc_options: []
151
154
  require_paths:
152
155
  - lib
@@ -162,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
165
  version: '0'
163
166
  requirements: []
164
167
  rubygems_version: 3.1.2
165
- signing_key:
168
+ signing_key:
166
169
  specification_version: 4
167
170
  summary: An intelligent pure Ruby WHOIS client and parser.
168
171
  test_files:
@@ -181,7 +184,6 @@ test_files:
181
184
  - spec/support/helpers/connectivity_helper.rb
182
185
  - spec/support/helpers/spec_helper.rb
183
186
  - spec/whois/client_spec.rb
184
- - spec/whois/errors_spec.rb
185
187
  - spec/whois/record/part_spec.rb
186
188
  - spec/whois/record_spec.rb
187
189
  - spec/whois/server/adapters/afilias_spec.rb
@@ -196,4 +198,5 @@ test_files:
196
198
  - spec/whois/server/adapters/web_spec.rb
197
199
  - spec/whois/server/socket_handler_spec.rb
198
200
  - spec/whois/server_spec.rb
201
+ - spec/whois/web_interface_error_spec.rb
199
202
  - spec/whois/whois_spec.rb
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