whois 6.0.1 → 6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9783dca8336df04d4554e54f30f71d58c5d5dbdb9a4857e513b37be4ca3aae09
4
- data.tar.gz: cfecb0ebe734dcdc78825d09dccf208bc4f47dcc212fa1a4df97b7bef9f74ea1
3
+ metadata.gz: e64d874205f6eca344d3975f0875549c7d5f2a002e3380544cf869bc1a13eb66
4
+ data.tar.gz: 76d7a2839d49787c470b1e555752916a7b6fae580816b97190f1b0edfcbbd656
5
5
  SHA512:
6
- metadata.gz: 6da4a414226e3f3b838f5a5df21d0598ccd90e133eb46174bef22e52bd8a8eff945cff85dcbb41644ca6a9fc03e77c580885b5dfbb755a0e8e68ad4a4255741b
7
- data.tar.gz: 4aeadb9da22d6fb89b71e49fbe2986f33f45ee7917f7389f443af15ff44233cfc34db9d6bbc6359a55618ab9303d2b921a750d3b8edefe773bc89a137cedd653
6
+ metadata.gz: 7cbd42e91809e62fc7f67ae51dff76392c8d706cff0443c7f26adb26b5590653c777f4e91158de1a75e6d43a96106fcb7d29aa1130dc14c293a0024f43bc010a
7
+ data.tar.gz: 81a76fb294b075cd2bb77e21fd337e9895694d01bd117abe8d694a26b32b8d1ab9df7af9375d21d51bc18d731637c50647df2ee5aa288b46391bcc1686c9fce0
@@ -1,19 +1,17 @@
1
+ ---
1
2
  version: 2
2
3
  updates:
3
4
  - package-ecosystem: bundler
4
5
  directory: /
5
6
  schedule:
6
- interval: daily
7
- time: "04:00"
7
+ interval: weekly
8
8
  open-pull-requests-limit: 10
9
9
  labels:
10
10
  - dependencies
11
11
 
12
- - package-ecosystem: "github-actions"
13
- directory: "/"
12
+ - package-ecosystem: github-actions
13
+ directory: /
14
14
  schedule:
15
- interval: "daily"
16
- time: "04:00"
17
- open-pull-requests-limit: 10
15
+ interval: weekly
18
16
  labels:
19
17
  - dependencies
@@ -1,4 +1,5 @@
1
- name: release
1
+ ---
2
+ name: Release
2
3
 
3
4
  on:
4
5
  workflow_dispatch:
@@ -10,7 +11,7 @@ jobs:
10
11
  release:
11
12
  runs-on: ubuntu-latest
12
13
  steps:
13
- - uses: actions/checkout@v4
14
+ - uses: actions/checkout@v5
14
15
  - name: Release Gem
15
16
  uses: cadwallion/publish-rubygems-action@94a6f4cd5350581749c569b5001eecc864e3ad0b
16
17
  env:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  name: Tests
2
3
 
3
4
  on:
@@ -14,10 +15,10 @@ jobs:
14
15
  - "3.1"
15
16
  - "3.2"
16
17
  - "3.3"
17
- platform: [ubuntu-latest]
18
- runs-on: ${{ matrix.platform }}
18
+ - "3.4"
19
+ runs-on: ubuntu-latest
19
20
  steps:
20
- - uses: actions/checkout@v4
21
+ - uses: actions/checkout@v5
21
22
  - name: Set up Ruby
22
23
  uses: ruby/setup-ruby@v1
23
24
  with:
@@ -26,4 +27,3 @@ jobs:
26
27
  run: bundle install
27
28
  - name: Run tests
28
29
  run: bundle exec rake
29
-
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_from:
2
2
  - .rubocop_opinionated.yml
3
3
  - .rubocop_todo.yml
4
4
 
5
- require:
5
+ plugins:
6
6
  - rubocop-rspec
7
7
 
8
8
  AllCops:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-11-22 13:51:42 UTC using RuboCop version 1.68.0.
3
+ # on 2025-08-19 11:02:59 UTC using RuboCop version 1.79.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -34,7 +34,6 @@ RSpec/MultipleExpectations:
34
34
  RSpec/NamedSubject:
35
35
  Exclude:
36
36
  - 'spec/whois/record_spec.rb'
37
- - 'spec/whois/server/socket_handler_spec.rb'
38
37
 
39
38
  # Offense count: 40
40
39
  RSpec/StubbedMock:
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.2
1
+ ruby 3.4.2
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  This project uses [Semantic Versioning 2.0.0](http://semver.org/).
4
4
 
5
5
 
6
+ ## Release 6.0.2
7
+
8
+ ### Changed
9
+
10
+ - SERVER: Updated .IN and other registry.in TLDs (GH-663).
11
+
12
+
6
13
  ## Release 6.0.1
7
14
 
8
15
  ### Changed
data/CONTRIBUTING.md CHANGED
@@ -4,37 +4,37 @@
4
4
 
5
5
  Fork, then clone the repo:
6
6
 
7
- ```
7
+ ```shell
8
8
  git clone git@github.com:your-username/whois.git
9
9
  ```
10
10
 
11
11
  Set up your machine:
12
12
 
13
- ```
13
+ ```shell
14
14
  bundle
15
15
  ```
16
16
 
17
17
  Make sure the tests pass:
18
18
 
19
- ```
19
+ ```shell
20
20
  bundle exec rake
21
21
  ```
22
22
 
23
23
  To propose a change/feature/patch, create your feature branch:
24
24
 
25
- ```
25
+ ```shell
26
26
  git checkout -b my-new-feature
27
27
  ```
28
28
 
29
29
  Make your change. Add tests for your change. Make the tests pass:
30
30
 
31
- ```
31
+ ```shell
32
32
  bundle exec rake
33
33
  ```
34
34
 
35
35
  Commit your changes:
36
36
 
37
- ```
37
+ ```shell
38
38
  git commit -am 'Add some feature'
39
39
  ```
40
40
 
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "rubocop", require: false
8
- gem "rubocop-rspec", require: false
7
+ gem "rubocop", "~> 1.79.2", require: false
8
+ gem "rubocop-rspec", "~> 3.6.0", require: false
data/data/tld.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_": {
3
3
  "schema": "2",
4
- "updated": "2024-11-02 13:38:00 UTC"
4
+ "updated": "2025-08-19 13:40:00 UTC"
5
5
  },
6
6
  "aaa": {
7
7
  "_type": "newgtld",
@@ -2488,7 +2488,7 @@
2488
2488
  "host": "whois.nic.immobilien"
2489
2489
  },
2490
2490
  "in": {
2491
- "host": "whois.registry.in"
2491
+ "host": "whois.nixiregistry.in"
2492
2492
  },
2493
2493
  "inc": {
2494
2494
  "_type": "newgtld",
@@ -5042,18 +5042,12 @@
5042
5042
  "uk": {
5043
5043
  "host": "whois.nic.uk"
5044
5044
  },
5045
- // "ac.uk": {
5046
- // "host": "whois.nic.ac.uk"
5047
- // },
5048
5045
  "bl.uk": {
5049
5046
  "adapter": "none"
5050
5047
  },
5051
5048
  "british-library.uk": {
5052
5049
  "adapter": "none"
5053
5050
  },
5054
- // "gov.uk": {
5055
- // "host": "whois.gov.uk"
5056
- // },
5057
5051
  "icnet.uk": {
5058
5052
  "adapter": "none"
5059
5053
  },
@@ -5420,7 +5414,7 @@
5420
5414
  },
5421
5415
  "xn--2scrj9c": {
5422
5416
  "_type": "newgtld",
5423
- "host": "whois.registry.in"
5417
+ "host": "whois.nixiregistry.in"
5424
5418
  },
5425
5419
  "xn--30rr7y": {
5426
5420
  "_type": "newgtld",
@@ -5438,7 +5432,7 @@
5438
5432
  "host": "whois.kr"
5439
5433
  },
5440
5434
  "xn--3hcrj9c": {
5441
- "host": "whois.registry.in"
5435
+ "host": "whois.nixiregistry.in"
5442
5436
  },
5443
5437
  "xn--3oq18vl8pn36a": {
5444
5438
  "_type": "newgtld",
@@ -5454,10 +5448,10 @@
5454
5448
  },
5455
5449
  "xn--45br5cyl": {
5456
5450
  "_type": "newgtld",
5457
- "host": "whois.registry.in"
5451
+ "host": "whois.nixiregistry.in"
5458
5452
  },
5459
5453
  "xn--45brj9c": {
5460
- "host": "whois.registry.in"
5454
+ "host": "whois.nixiregistry.in"
5461
5455
  },
5462
5456
  "xn--45q11c": {
5463
5457
  "_type": "newgtld",
@@ -5623,7 +5617,7 @@
5623
5617
  "host": "whois.nic.google"
5624
5618
  },
5625
5619
  "xn--fpcrj9c3d": {
5626
- "host": "whois.registry.in"
5620
+ "host": "whois.nixiregistry.in"
5627
5621
  },
5628
5622
  "xn--fzc2c9e2c": {
5629
5623
  "host": "whois.nic.lk"
@@ -5641,7 +5635,7 @@
5641
5635
  "adapter": "none"
5642
5636
  },
5643
5637
  "xn--gecrj9c": {
5644
- "host": "whois.registry.in"
5638
+ "host": "whois.nixiregistry.in"
5645
5639
  },
5646
5640
  "xn--gk3at1e": {
5647
5641
  "_type": "newgtld",
@@ -5649,14 +5643,14 @@
5649
5643
  },
5650
5644
  "xn--h2breg3eve": {
5651
5645
  "_type": "newgtld",
5652
- "host": "whois.registry.in"
5646
+ "host": "whois.nixiregistry.in"
5653
5647
  },
5654
5648
  "xn--h2brj9c": {
5655
- "host": "whois.registry.in"
5649
+ "host": "whois.nixiregistry.in"
5656
5650
  },
5657
5651
  "xn--h2brj9c8c": {
5658
5652
  "_type": "newgtld",
5659
- "host": "whois.registry.in"
5653
+ "host": "whois.nixiregistry.in"
5660
5654
  },
5661
5655
  "xn--hxt814e": {
5662
5656
  "_type": "newgtld",
@@ -5753,10 +5747,10 @@
5753
5747
  },
5754
5748
  "xn--mgbbh1a": {
5755
5749
  "_type": "newgtld",
5756
- "host": "whois.registry.in"
5750
+ "host": "whois.nixiregistry.in"
5757
5751
  },
5758
5752
  "xn--mgbbh1a71e": {
5759
- "host": "whois.registry.in"
5753
+ "host": "whois.nixiregistry.in"
5760
5754
  },
5761
5755
  "xn--mgbc0a9azcg": {
5762
5756
  "adapter": "none"
@@ -5770,7 +5764,7 @@
5770
5764
  },
5771
5765
  "xn--mgbgu82a": {
5772
5766
  "_type": "newgtld",
5773
- "host": "whois.registry.in"
5767
+ "host": "whois.nixiregistry.in"
5774
5768
  },
5775
5769
  "xn--mgbi4ecexp": {
5776
5770
  "_type": "newgtld",
@@ -5872,10 +5866,10 @@
5872
5866
  },
5873
5867
  "xn--rvc1e0am3e": {
5874
5868
  "_type": "newgtld",
5875
- "host": "whois.registry.in"
5869
+ "host": "whois.nixiregistry.in"
5876
5870
  },
5877
5871
  "xn--s9brj9c": {
5878
- "host": "whois.registry.in"
5872
+ "host": "whois.nixiregistry.in"
5879
5873
  },
5880
5874
  "xn--ses554g": {
5881
5875
  "_type": "newgtld",
@@ -5935,7 +5929,7 @@
5935
5929
  "host": "whois.nic.lk"
5936
5930
  },
5937
5931
  "xn--xkc2dl3a5ee0h": {
5938
- "host": "whois.registry.in"
5932
+ "host": "whois.nixiregistry.in"
5939
5933
  },
5940
5934
  "xn--y9a3aq": {
5941
5935
  "host": "whois.amnic.net"
@@ -35,7 +35,7 @@ module Whois
35
35
  a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
36
36
  [a, b, c, d].map do |token|
37
37
  token = (token || 0).to_i
38
- raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token <= 255 && token >= 0
38
+ raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token.between?(0, 255)
39
39
 
40
40
  token
41
41
  end.join(".")
data/lib/whois/version.rb CHANGED
@@ -11,5 +11,5 @@
11
11
 
12
12
  module Whois
13
13
  # The current library version.
14
- VERSION = "6.0.1"
14
+ VERSION = "6.0.2"
15
15
  end
@@ -7,9 +7,11 @@ describe Whois::Server::SocketHandler do
7
7
  describe "#call" do
8
8
  [Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError].each do |error|
9
9
  it "re-raises #{error} as Whois::ConnectionError" do
10
- expect(subject).to receive(:execute).and_raise(error)
10
+ handler = described_class.new
11
+ expect(handler).to receive(:execute).and_raise(error)
12
+
11
13
  expect {
12
- subject.call("example.test", "whois.test", 43)
14
+ handler.call("example.test", "whois.test", 43)
13
15
  }.to raise_error(Whois::ConnectionError, "#{error}: #{error.new.message}")
14
16
  end
15
17
 
@@ -22,7 +24,9 @@ describe Whois::Server::SocketHandler do
22
24
  expect(TCPSocket).to receive(:new)
23
25
  .with("whois.test", 43)
24
26
  .and_return(socket)
25
- subject.call("example.test", "whois.test", 43)
27
+
28
+ handler = described_class.new
29
+ handler.call("example.test", "whois.test", 43)
26
30
  end
27
31
  end
28
32
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whois
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -61,12 +60,11 @@ executables:
61
60
  - whoisrb
62
61
  extensions: []
63
62
  extra_rdoc_files:
64
- - LICENSE.txt
65
63
  - ".yardopts"
64
+ - LICENSE.txt
66
65
  files:
67
66
  - ".github/FUNDING.yml"
68
67
  - ".github/dependabot.yml"
69
- - ".github/workflows/codeql-analysis.yml"
70
68
  - ".github/workflows/release.yml"
71
69
  - ".github/workflows/tests.yml"
72
70
  - ".gitignore"
@@ -77,7 +75,6 @@ files:
77
75
  - ".simplecov"
78
76
  - ".tool-versions"
79
77
  - ".yardopts"
80
- - 4.0-Upgrade.md
81
78
  - CHANGELOG.md
82
79
  - CONTRIBUTING.md
83
80
  - Gemfile
@@ -152,7 +149,6 @@ homepage: https://whoisrb.org/
152
149
  licenses:
153
150
  - MIT
154
151
  metadata: {}
155
- post_install_message:
156
152
  rdoc_options: []
157
153
  require_paths:
158
154
  - lib
@@ -167,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
163
  - !ruby/object:Gem::Version
168
164
  version: '0'
169
165
  requirements: []
170
- rubygems_version: 3.5.22
171
- signing_key:
166
+ rubygems_version: 3.6.9
172
167
  specification_version: 4
173
168
  summary: An intelligent pure Ruby WHOIS client and parser.
174
169
  test_files: []
@@ -1,64 +0,0 @@
1
- # For most projects, this workflow file will not need changing; you simply need
2
- # to commit it to your repository.
3
- #
4
- # You may wish to alter this file to override the set of languages analyzed,
5
- # or to provide custom queries or build logic.
6
- name: "CodeQL"
7
-
8
- on:
9
- push:
10
- branches: [ main ]
11
- pull_request:
12
- # The branches below must be a subset of the branches above
13
- branches: [ main ]
14
- schedule:
15
- - cron: '39 4 * * 0'
16
-
17
- jobs:
18
- analyze:
19
- name: Analyze
20
- runs-on: ubuntu-latest
21
- permissions:
22
- actions: read
23
- contents: read
24
- security-events: write
25
-
26
- strategy:
27
- fail-fast: false
28
- matrix:
29
- language: [ 'ruby' ]
30
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
31
- # Learn more about CodeQL language support at https://git.io/codeql-language-support
32
-
33
- steps:
34
- - name: Checkout repository
35
- uses: actions/checkout@v4
36
-
37
- # Initializes the CodeQL tools for scanning.
38
- - name: Initialize CodeQL
39
- uses: github/codeql-action/init@v3
40
- with:
41
- languages: ${{ matrix.language }}
42
- # If you wish to specify custom queries, you can do so here or in a config file.
43
- # By default, queries listed here will override any specified in a config file.
44
- # Prefix the list here with "+" to use these queries and those in the config file.
45
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
46
-
47
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
48
- # If this step fails, then you should remove it and run the build manually (see below)
49
- - name: Autobuild
50
- uses: github/codeql-action/autobuild@v3
51
-
52
- # ℹ️ Command-line programs to run using the OS shell.
53
- # 📚 https://git.io/JvXDl
54
-
55
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
56
- # and modify them (or add more) to build your code if your project
57
- # uses a compiled language
58
-
59
- #- run: |
60
- # make bootstrap
61
- # make release
62
-
63
- - name: Perform CodeQL Analysis
64
- uses: github/codeql-action/analyze@v3
data/4.0-Upgrade.md DELETED
@@ -1,143 +0,0 @@
1
- # Welcome to Whois 4.0!
2
-
3
- Whois 4 is a major upgrade compared to Whois 3. This library is now 7 years old, enough mature to offer pretty much all the features you need to perform WHOIS queries.
4
-
5
- In these last 7 years the adoption of this library has grown beyond any expectation. Most of the time was spent updating the definitions to stay up to date with the various registrar changes (thanks ICANN for thew newGLTDs...), updating the registry parsers and polishing up the public interface.
6
-
7
- For Whois 4 I decided to take a step back, and rewrite some of the internal components of this library to improve performance and readability. As a result of these changes, there are several compatibility breaks with Whois 4 that I'm going to document here.
8
-
9
- -- Simone
10
-
11
- ## What's New
12
-
13
- - The Whois client and the Whois parser are now two separate repositories, and they are also distributed as two separate gems:
14
-
15
- - https://github.com/weppos/whois - https://rubygems.org/gems/whois
16
- - https://github.com/weppos/whois-parser https://rubygems.org/gems/whois-parser
17
-
18
- There are several reasons behind this change (see [weppos/whois#503](https://github.com/weppos/whois/pull/503)).
19
-
20
- First of all, the maintenance of the whois-parser component is the most time consuming task. Updating a parser may require from a few minutes to several hours, depending on how big are the changes. It also requires to generate the appropriate fixtures, and write the necessary tests. In the last years I noticed that more than once client updates were delayed because of pending parser changes. Separating the repositories and the release cycles will likely speedup future released of the client gem.
21
-
22
- Moreover, the parser component takes a lot of space (due to all the files and fixtures). If you just need a Ruby whois client, loading the entire parser component is inefficient and a waste of time/CPU/resources.
23
-
24
- Last but not least, in the last years the Whois client inspired several ports in different languages. Most of these ports were not interested in porting the parser as well. However, the parser was so tightly coupled with the client that it made the client code harder to read.
25
-
26
- - The definition files have been largely redesigned, in particular the TLD file. The definitions are now maintained using a set of CLI tools. The goal is to eventually extract the definition files into a separate, standalone repository that other WHOIS libraries can easily fetch.
27
-
28
- ## Upgrade
29
-
30
- When upgrading, here's the most relevant changes to keep an eye on:
31
-
32
- - If you are using the Whois parser, install and require the `whois-parser` gem. The parser will automatically download the appropriate `whois` dependency.
33
-
34
- ```ruby
35
- require 'whois-parser'
36
- ```
37
-
38
- If you only need the client and you don't care about the parser, simply continue to require the `whois` gem directly.
39
-
40
- ```ruby
41
- require 'whois'
42
- ```
43
-
44
- - `Whois::Server.definitions` no longer return the internal definitions. Definitions are no longer accessible directly, because their internal representation may change at any time. If you need to modify the definitions, use the public API.
45
-
46
- ```ruby
47
- Whois::Server.define(Whois::Server::TYPE_TLD, ...)
48
- ```
49
-
50
- You can still use `Whois::Server.definitions`, but it will return a copy of the internal definitions, and you have to specify which type of definitions you want to access.
51
-
52
- ```ruby
53
- Whois::Server.definitions(Whois::Server::TYPE_TLD)
54
- ```
55
-
56
- - **The parser methods are no longer accessible directly within the response object.**
57
-
58
- This is probably one of the most important changes, and it is explained in details at [weppos/whois-parser#5](https://github.com/weppos/whois-parser/pull/5).
59
-
60
- In Whois 3, you can invoke a property method on a record object and the record will automatically route the method call to the underlying parser. If the property is not supported or defined in any of the parsers, then the method will return nil.
61
-
62
- However, this behavior is often the cause of confusion and misunderstandings, especially for partially implemented parsers. Without to mention that the code required for this feature to work added an extra layer of complexity to the `Whois::Record` implementation.
63
-
64
- Starting from Whois 4, the `Whois::Record` doesn't expose any parsing methods anymore. If you want to parse a record, you have to istantiate a parser manually. Of course, you also need to use the `whois-parser` library instead of `whois`.
65
-
66
- Whois 3:
67
-
68
- ```ruby
69
- require 'whois-parser'
70
-
71
- record = Whois.whois("example.it")
72
- record.expires_on
73
- ```
74
-
75
- Whois 4:
76
-
77
- ```ruby
78
- require 'whois-parser'
79
-
80
- record = Whois.whois("example.it")
81
- parser = Whois::Parser.new(record)
82
- parser.expires_on
83
- ```
84
-
85
- You can still use the convenient helper `record.parser` to initialize a parser:
86
-
87
- ```ruby
88
- require 'whois-parser'
89
-
90
- record = Whois.whois("example.it")
91
- record.parser.expires_on
92
- ```
93
-
94
- Also note that any parser method, such as `parser.expires_on`, will raise an error if the property is not implemented, as opposite to silently returning `nil` as it was in Whois 3.
95
-
96
- - **Parser extensions**
97
-
98
- The Parser features available in Whois 3 has been packaged into several extensions. Some of them are loaded by default in Whois 4 when you require `whois-parser`, others not anymore. The reason is because although some of them may appear convenient (because it makes you write more code), it turned out that they made some assumptions that were often source of confusion.
99
-
100
- Check the header of the [`whois/parser.rb`](https://github.com/weppos/whois-parser/blob/master/lib/whois/parser.rb) file to learn more about the purpose of each extension.
101
-
102
- Requiring **all** the extensions will essentially force Whois 4 to work pretty much like Whois 3. This is not recommended, and you should not rely on those extensions to be there forever. Instead, you should write the code depending on what you actually need.
103
-
104
- There is also an ENV variable you can set to rollback compatibility to Whois 3.
105
-
106
- ```ruby
107
- ENV["WHOISRB_4EXTENSIONS"] = 1
108
- ```
109
-
110
- Again, this flag exists only as temporary helper, and it should not become a permanent upgrade workaround.
111
-
112
- - **SafeRecord**
113
-
114
- In the previous point I mentioned that you should write the code you need to customize the `Whois::Record` and extract information with the `Whois::Parser`. However, I omitted an important additional recommendation: avoid monkey patching the Whois::Record object, and instead prefer composition via delegation.
115
-
116
- The SafeRecord is an example of a wrapper around a Record object, that expose a Whois 3 alike interface, without injecting the parser methods directly into the `Whois::Record` itself.
117
-
118
- The advantages are:
119
-
120
- - the code is more maintainable, as it is not tighlty coupled to the Whois::Record
121
- - you don't monkey patch `Whois::Record` in your code, which is an object you don't have control of because it is packaged in a third party library (and can change)
122
- - the library can easily be tested separately
123
-
124
- In these 10 years of writing Ruby code, I've noticed an increasing attitude to monkey patch Ruby classes you don't control, instead of writing your own code and delegate to them. It looks like in several cases Ruby programmers are afraid of writing Ruby code. This results in very fragile code, where methods can easily conflict each other (especially between dependencies).
125
-
126
- The `Whois::SafeRecord` is an alternative example of how you can restore Whois 3 behavior by using a custom object.
127
-
128
- ```ruby
129
- require 'whois/parser'
130
- require 'whois/safe_record'
131
-
132
- record = Whois.whois('example.com')
133
- record.disclaimer
134
- # => Whois::AttributeNotSupported
135
-
136
- safe_record = Whois::SafeRecord.new(record)
137
- safe_record.disclaimer
138
- # => nil
139
- ```
140
-
141
- This is preferred over requiring the `whois/parser_extensions` or enabling v3 compatibility mode.
142
-
143
- Please note that the parser extension is provided as example. It may be removed from future versions therefore, once again, you should write the code you need to access the parsed data.