whois 5.0.0 → 5.1.0

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/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 +79 -50
  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 +55 -53
  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. data/utils/compare-whois.rb +1 -1
  61. data/utils/matrix.rb +1 -1
  62. metadata +13 -39
  63. data/.travis.yml +0 -18
  64. data/bin/setup +0 -8
  65. data/tasks/spec.rake +0 -199
data/bin/whoisrb CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- $:.unshift(File.expand_path("../../lib", __FILE__))
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
4
5
 
5
6
  require 'optparse'
6
7
  require 'whois'
@@ -8,7 +9,7 @@ require 'whois'
8
9
 
9
10
  options = {}
10
11
  OptionParser.new do |opts|
11
- opts.banner = "Whois: an intelligent pure Ruby WHOIS client"
12
+ opts.banner = "Whois: an intelligent pure Ruby WHOIS client"
12
13
  opts.define_head "Usage: whoisrb [options] object"
13
14
  opts.separator ""
14
15
  opts.separator "Examples:"
data/data/ipv4.json CHANGED
@@ -39,9 +39,7 @@
39
39
  "host": "whois.apnic.net"
40
40
  },
41
41
  "43.0.0.0/8": {
42
- "host": "whois.nic.ad.jp",
43
- "adapter": "formatted",
44
- "format": "%s/e"
42
+ "host": "whois.apnic.net"
45
43
  },
46
44
  "46.0.0.0/8": {
47
45
  "host": "whois.ripe.net"
data/data/tld.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_": {
3
3
  "schema": "2",
4
- "updated": "2019-09-19 11:00:00 UTC"
4
+ "updated": "2021-03-02 11:55:00 UTC"
5
5
  },
6
6
  "aaa": {
7
7
  "_type": "newgtld",
@@ -654,11 +654,6 @@
654
654
  "bn": {
655
655
  "host": "whois.bnnic.bn"
656
656
  },
657
- "bnl": {
658
- "_group": "afiliassrs",
659
- "_type": "newgtld",
660
- "host": "whois.nic.bnl"
661
- },
662
657
  "bnpparibas": {
663
658
  "_group": "afiliassrs",
664
659
  "_type": "newgtld",
@@ -927,10 +922,6 @@
927
922
  "_type": "newgtld",
928
923
  "host": "whois.uniregistry.net"
929
924
  },
930
- "cartier": {
931
- "_type": "newgtld",
932
- "adapter": "none"
933
- },
934
925
  "casa": {
935
926
  "_group": "mmregistry",
936
927
  "_type": "newgtld",
@@ -1071,11 +1062,6 @@
1071
1062
  "_type": "newgtld",
1072
1063
  "host": "whois.nic.google"
1073
1064
  },
1074
- "chrysler": {
1075
- "_group": "afiliassrs",
1076
- "_type": "newgtld",
1077
- "host": "whois.afilias-srs.net"
1078
- },
1079
1065
  "church": {
1080
1066
  "_group": "donuts",
1081
1067
  "_type": "newgtld",
@@ -1694,11 +1680,6 @@
1694
1680
  "_type": "newgtld",
1695
1681
  "host": "whois.nic.doctor"
1696
1682
  },
1697
- "dodge": {
1698
- "_group": "afiliassrs",
1699
- "_type": "newgtld",
1700
- "host": "whois.afilias-srs.net"
1701
- },
1702
1683
  "dog": {
1703
1684
  "_group": "donuts",
1704
1685
  "_type": "newgtld",
@@ -1744,10 +1725,6 @@
1744
1725
  "_type": "newgtld",
1745
1726
  "host": "whois.nic.dunlop"
1746
1727
  },
1747
- "duns": {
1748
- "_type": "newgtld",
1749
- "adapter": "none"
1750
- },
1751
1728
  "dupont": {
1752
1729
  "_type": "newgtld",
1753
1730
  "adapter": "none"
@@ -1900,10 +1877,6 @@
1900
1877
  "_type": "newgtld",
1901
1878
  "host": "whois.nic.events"
1902
1879
  },
1903
- "everbank": {
1904
- "_type": "newgtld",
1905
- "host": "whois.nic.everbank"
1906
- },
1907
1880
  "exchange": {
1908
1881
  "_group": "donuts",
1909
1882
  "_type": "newgtld",
@@ -2953,10 +2926,6 @@
2953
2926
  "is": {
2954
2927
  "host": "whois.isnic.is"
2955
2928
  },
2956
- "iselect": {
2957
- "_type": "newgtld",
2958
- "host": "whois.nic.iselect"
2959
- },
2960
2929
  "ismaili": {
2961
2930
  "_group": "afiliassrs",
2962
2931
  "_type": "newgtld",
@@ -3226,10 +3195,6 @@
3226
3195
  "_type": "newgtld",
3227
3196
  "host": "whois.nic.lacaixa"
3228
3197
  },
3229
- "ladbrokes": {
3230
- "_type": "newgtld",
3231
- "host": "whois.nic.ladbrokes"
3232
- },
3233
3198
  "lamborghini": {
3234
3199
  "_group": "afiliassrs",
3235
3200
  "_type": "newgtld",
@@ -3250,10 +3215,6 @@
3250
3215
  "_type": "newgtld",
3251
3216
  "host": "whois.afilias-srs.net"
3252
3217
  },
3253
- "lancome": {
3254
- "_type": "newgtld",
3255
- "host": "whois.nic.lancome"
3256
- },
3257
3218
  "land": {
3258
3219
  "_group": "donuts",
3259
3220
  "_type": "newgtld",
@@ -3343,10 +3304,6 @@
3343
3304
  "li": {
3344
3305
  "host": "whois.nic.li"
3345
3306
  },
3346
- "liaison": {
3347
- "_type": "newgtld",
3348
- "host": "whois.nic.liaison"
3349
- },
3350
3307
  "lidl": {
3351
3308
  "_type": "newgtld",
3352
3309
  "host": "whois.nic.lidl"
@@ -3742,10 +3699,6 @@
3742
3699
  "_type": "newgtld",
3743
3700
  "host": "whois.nic.mobile"
3744
3701
  },
3745
- "mobily": {
3746
- "_type": "newgtld",
3747
- "adapter": "none"
3748
- },
3749
3702
  "moda": {
3750
3703
  "_group": "donuts",
3751
3704
  "_type": "newgtld",
@@ -3783,11 +3736,6 @@
3783
3736
  "_type": "newgtld",
3784
3737
  "adapter": "none"
3785
3738
  },
3786
- "mopar": {
3787
- "_group": "afiliassrs",
3788
- "_type": "newgtld",
3789
- "host": "whois.afilias-srs.net"
3790
- },
3791
3739
  "mormon": {
3792
3740
  "_group": "afiliassrs",
3793
3741
  "_type": "newgtld",
@@ -3821,11 +3769,6 @@
3821
3769
  "_type": "newgtld",
3822
3770
  "host": "whois.nic.movie"
3823
3771
  },
3824
- "movistar": {
3825
- "_group": "knipp",
3826
- "_type": "newgtld",
3827
- "host": "whois-fe.movistar.tango.knipp.de"
3828
- },
3829
3772
  "mp": {
3830
3773
  "adapter": "none"
3831
3774
  },
@@ -4383,10 +4326,6 @@
4383
4326
  "_type": "newgtld",
4384
4327
  "host": "whois.nic.physio"
4385
4328
  },
4386
- "piaget": {
4387
- "_type": "newgtld",
4388
- "adapter": "none"
4389
- },
4390
4329
  "pics": {
4391
4330
  "_group": "uniregistry",
4392
4331
  "_type": "newgtld",
@@ -5280,11 +5219,6 @@
5280
5219
  "_type": "newgtld",
5281
5220
  "host": "whois.afilias-srs.net"
5282
5221
  },
5283
- "srt": {
5284
- "_group": "afiliassrs",
5285
- "_type": "newgtld",
5286
- "host": "whois.afilias-srs.net"
5287
- },
5288
5222
  "ss": {
5289
5223
  "host": "whois.nic.ss"
5290
5224
  },
@@ -5305,10 +5239,6 @@
5305
5239
  "_type": "newgtld",
5306
5240
  "host": "whois.nic.star"
5307
5241
  },
5308
- "starhub": {
5309
- "_type": "newgtld",
5310
- "host": "whois.nic.starhub"
5311
- },
5312
5242
  "statebank": {
5313
5243
  "_group": "afiliassrs",
5314
5244
  "_type": "newgtld",
@@ -5344,7 +5274,7 @@
5344
5274
  },
5345
5275
  "stream": {
5346
5276
  "_type": "newgtld",
5347
- "adapter": "none"
5277
+ "host": "whois.nic.stream"
5348
5278
  },
5349
5279
  "studio": {
5350
5280
  "_group": "donuts",
@@ -5512,11 +5442,6 @@
5512
5442
  "tel": {
5513
5443
  "host": "whois.nic.tel"
5514
5444
  },
5515
- "telefonica": {
5516
- "_group": "knipp",
5517
- "_type": "newgtld",
5518
- "host": "whois-fe.telefonica.tango.knipp.de"
5519
- },
5520
5445
  "temasek": {
5521
5446
  "_group": "afiliassrs",
5522
5447
  "_type": "newgtld",
@@ -5770,11 +5695,6 @@
5770
5695
  "_type": "newgtld",
5771
5696
  "host": "whois.nic.ubs"
5772
5697
  },
5773
- "uconnect": {
5774
- "_group": "afiliassrs",
5775
- "_type": "newgtld",
5776
- "host": "whois.afilias-srs.net"
5777
- },
5778
5698
  "ug": {
5779
5699
  "host": "whois.co.ug"
5780
5700
  },
@@ -5951,10 +5871,6 @@
5951
5871
  "_type": "newgtld",
5952
5872
  "host": "whois.nic.vision"
5953
5873
  },
5954
- "vistaprint": {
5955
- "_type": "newgtld",
5956
- "host": "whois.nic.vistaprint"
5957
- },
5958
5874
  "viva": {
5959
5875
  "_group": "centralnic",
5960
5876
  "_type": "newgtld",
@@ -6034,10 +5950,6 @@
6034
5950
  "_type": "newgtld",
6035
5951
  "host": "whois.nic.wanggou"
6036
5952
  },
6037
- "warman": {
6038
- "_type": "newgtld",
6039
- "host": "whois.nic.warman"
6040
- },
6041
5953
  "watch": {
6042
5954
  "_group": "donuts",
6043
5955
  "_type": "newgtld",
@@ -6398,11 +6310,6 @@
6398
6310
  "_type": "newgtld",
6399
6311
  "host": "whois.nic.xn--efvy88h"
6400
6312
  },
6401
- "xn--estv75g": {
6402
- "_group": "afiliassrs",
6403
- "_type": "newgtld",
6404
- "host": "whois.nic.xn--estv75g"
6405
- },
6406
6313
  "xn--fct429k": {
6407
6314
  "_group": "amazonregistry",
6408
6315
  "_type": "newgtld",
@@ -6577,10 +6484,6 @@
6577
6484
  "adapter": "web",
6578
6485
  "url": "http://idn.jo/whois_a.aspx"
6579
6486
  },
6580
- "xn--mgbb9fbpob": {
6581
- "_type": "newgtld",
6582
- "adapter": "none"
6583
- },
6584
6487
  "xn--mgbbh1a": {
6585
6488
  "_type": "newgtld",
6586
6489
  "host": "whois.registry.in"
data/lib/whois/client.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -88,7 +90,7 @@ module Whois
88
90
  #
89
91
  def lookup(object)
90
92
  string = object.to_s.downcase
91
- Timeout::timeout(timeout) do
93
+ Timeout.timeout(timeout) do
92
94
  @server = Server.guess(string)
93
95
  @server.configure(settings)
94
96
  @server.lookup(string)
data/lib/whois/errors.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -69,7 +71,7 @@ module Whois
69
71
 
70
72
  # Raised when the class has found a server but it doesn't support the
71
73
  # standard WHOIS interface via port 43. This is the case of some
72
- # specific domains that only provide a webbased WHOIS interface. (\x01)
74
+ # specific domains that only provide a web-based WHOIS interface. (\x01)
73
75
  class WebInterfaceError < InterfaceNotSupported
74
76
 
75
77
  # @return [String] The URL of the web-based WHOIS interface.
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -20,12 +22,11 @@ module Whois
20
22
  # @attr [String] body The body containing the WHOIS output.
21
23
  # @attr [String] host The host which returned the body.
22
24
  #
23
- class Part < Struct.new(:body, :host)
24
-
25
+ Part = Struct.new(:body, :host) do
25
26
  def initialize(*args)
26
27
  if args.first.is_a? Hash
27
28
  initialize_with_hash(args.first)
28
- elsif args.size == 0
29
+ elsif args.size.zero?
29
30
  super
30
31
  else
31
32
  raise ArgumentError
data/lib/whois/record.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -65,7 +67,7 @@ module Whois
65
67
  end
66
68
  end
67
69
 
68
- alias_method :eql?, :==
70
+ alias eql? ==
69
71
 
70
72
 
71
73
  # Invokes {#match} on record {#content}
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -40,6 +42,7 @@ module Whois
40
42
 
41
43
  def extract_referral(response)
42
44
  return unless (match = response.match(/Registrar WHOIS Server:(.+?)$/))
45
+
43
46
  server = match[match.size - 1].strip
44
47
  server.empty? ? nil : server
45
48
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -38,10 +40,11 @@ module Whois
38
40
  private
39
41
 
40
42
  def extract_referral(response)
41
- return unless response =~ /ReferralServer:\s*r?whois:\/\/([\w.-]+)(?::(\d+))?/
43
+ return unless response =~ %r{ReferralServer:\s*r?whois://([\w.-]+)(?::(\d+))?}
44
+
42
45
  {
43
- host: $1,
44
- port: $2 ? $2.to_i : nil
46
+ host: Regexp.last_match(1),
47
+ port: Regexp.last_match(2) ? Regexp.last_match(2).to_i : nil,
45
48
  }
46
49
  end
47
50
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -22,25 +24,24 @@ module Whois
22
24
 
23
25
  private
24
26
 
25
- # "127.1.168.192.in-addr.arpa" => "192.168.1.127"
26
- # "1.168.192.in-addr.arpa" => "192.168.1.0"
27
- # "168.192.in-addr.arpa" => "192.168.0.0"
28
- # "192.in-addr.arpa" => "192.0.0.0"
29
- # "in-addr.arpa" => "0.0.0.0"
30
- def inaddr_to_ip(string)
31
- unless /^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/ =~ string
32
- raise ServerError, "Invalid .in-addr.arpa address"
27
+ # "127.1.168.192.in-addr.arpa" => "192.168.1.127"
28
+ # "1.168.192.in-addr.arpa" => "192.168.1.0"
29
+ # "168.192.in-addr.arpa" => "192.168.0.0"
30
+ # "192.in-addr.arpa" => "192.0.0.0"
31
+ # "in-addr.arpa" => "0.0.0.0"
32
+ def inaddr_to_ip(string)
33
+ raise ServerError, "Invalid .in-addr.arpa address" unless string.match?(/^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/)
34
+
35
+ a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
36
+ [a, b, c, d].map do |token|
37
+ token = (token || 0).to_i
38
+ if token <= 255 && token >= 0
39
+ token
40
+ else
41
+ raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
33
42
  end
34
- a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
35
- [a, b, c, d].map do |token|
36
- token = (token ||= 0).to_i
37
- if token <= 255 && token >= 0
38
- token
39
- else
40
- raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
41
- end
42
- end.join(".")
43
- end
43
+ end.join(".")
44
+ end
44
45
 
45
46
  end
46
47
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -22,9 +24,7 @@ module Whois
22
24
  @query_handler ||= SocketHandler.new
23
25
  end
24
26
 
25
- def query_handler=(handler)
26
- @query_handler = handler
27
- end
27
+ attr_writer :query_handler
28
28
  end
29
29
 
30
30
  # Default WHOIS request port.
@@ -48,15 +48,10 @@ module Whois
48
48
  attr_reader :buffer
49
49
 
50
50
 
51
- # @param [Symbol] type
52
- # The type of WHOIS adapter to define.
53
- # Known values are :tld, :ipv4, :ipv6.
54
- # @param [String] allocation
55
- # The allocation, range or hostname, this server is responsible for.
56
- # @param [String, nil] host
57
- # The server hostname. Use nil if unknown or not available.
58
- # @param [Hash] options Optional adapter properties.
59
- #
51
+ # @param type [Symbol] the type of WHOIS adapter to define. Known values are :tld, :ipv4, :ipv6,
52
+ # @param allocation [String] the allocation, range or hostname, this server is responsible for.
53
+ # @param host [String, nil] the server hostname. Use nil if unknown or not available.
54
+ # @param options [Hash] optional adapter properties
60
55
  def initialize(type, allocation, host, options = {})
61
56
  @type = type
62
57
  @allocation = allocation
@@ -66,53 +61,44 @@ module Whois
66
61
 
67
62
  # Checks self and other for equality.
68
63
  #
69
- # @param [The Whois::Server::Adapters::Base] other
70
- # @return [Boolean] Returns true if the other is the same object,
64
+ # @param other [The Whois::Server::Adapters::Base]
65
+ # @return [Boolean] true if the other is the same object,
71
66
  # or <tt>other</tt> attributes matches this object attributes.
72
- #
73
67
  def ==(other)
74
- (
75
- self.equal?(other)
76
- ) || (
68
+ equal?(other) || (
77
69
  other.is_a?(self.class) &&
78
- self.type == other.type &&
79
- self.allocation == other.allocation &&
80
- self.host == other.host &&
81
- self.options == other.options
70
+ type == other.type &&
71
+ allocation == other.allocation &&
72
+ host == other.host &&
73
+ options == other.options
82
74
  )
83
75
  end
84
76
 
85
- alias_method :eql?, :==
77
+ alias eql? ==
86
78
 
87
79
 
88
80
  # Merges given +settings+ into current {#options}.
89
81
  #
90
- # @param [Hash] settings
91
- # @return [Hash] The updated options for this object.
92
- #
82
+ # @param settings [Hash]
83
+ # @return [Hash] the updated options for this object
93
84
  def configure(settings)
94
85
  @host = settings[:host] if settings[:host]
95
86
  options.merge!(settings)
96
87
  end
97
88
 
98
89
 
99
- # Performs a Whois lookup for <tt>string</tt>
100
- # using the current server adapter.
90
+ # Performs a Whois lookup for <tt>string</tt> using the current server adapter.
101
91
  #
102
- # Internally, this method calls {#request}
103
- # using the Template Method design pattern.
92
+ # Internally, this method calls {#request} using the Template Method design pattern.
104
93
  #
105
94
  # server.lookup("google.com")
106
95
  # # => Whois::Record
107
96
  #
108
- # @param [String] string The string to be sent as query parameter.
97
+ # @param string [String] the string to query
109
98
  # @return [Whois::Record]
110
- #
111
99
  def lookup(string)
112
- buffer_start do |buffer|
113
- request(string)
114
- Whois::Record.new(self, buffer.dup)
115
- end
100
+ parts = buffer_start { request(string) }
101
+ Whois::Record.new(self, parts)
116
102
  end
117
103
 
118
104
  # Performs the real WHOIS request.
@@ -121,11 +107,10 @@ module Whois
121
107
  # it is intended to be overwritten in the concrete subclasses.
122
108
  # This is the heart of the Template Method design pattern.
123
109
  #
124
- # @param [String] string The string to be sent as query parameter.
110
+ # @param string [String] the string to query
125
111
  # @return [void]
126
112
  # @raise [NotImplementedError]
127
113
  # @abstract
128
- #
129
114
  def request(string)
130
115
  raise NotImplementedError
131
116
  end
@@ -149,6 +134,7 @@ module Whois
149
134
  def buffer_start
150
135
  @buffer ||= []
151
136
  yield(@buffer)
137
+ @buffer.dup
152
138
  ensure
153
139
  @buffer.clear
154
140
  end
@@ -183,7 +169,7 @@ module Whois
183
169
  self.class.query_handler.call(query, *args)
184
170
  end
185
171
 
186
- alias :query_the_socket :query
172
+ alias query_the_socket query
187
173
 
188
174
  end
189
175
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -47,7 +49,7 @@ module Whois
47
49
  #
48
50
  def request(string)
49
51
  options[:format] || raise(ServerError, "Missing mandatory :format option for adapter `Formatted'")
50
- response = query_the_socket(sprintf(options[:format], string), host)
52
+ response = query_the_socket(format(options[:format], string), host)
51
53
  buffer_append response, host
52
54
  end
53
55
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Ruby Whois
3
5
  #
4
6
  # An intelligent pure Ruby WHOIS client and parser.
5
7
  #
6
- # Copyright (c) 2009-2019 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
9
  #++
8
10
 
9
11