resolv-hosts-dynamic 0.0.2 → 1.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 +5 -5
- data/.github/workflows/test.yml +31 -0
- data/.gitignore +0 -1
- data/.pre-commit-config.yaml +14 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +36 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +60 -0
- data/README.md +8 -4
- data/Rakefile +6 -2
- data/lib/resolv-hosts-dynamic.rb +26 -28
- data/resolv-hosts-dynamic.gemspec +27 -14
- data/spec/resolv-hosts-dynamic_spec.rb +10 -9
- data/spec/spec.gemfile +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +29 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c2abe5a079619b0c2c70c89c3e1cae72e6f2ddb0eb70f1bc840f942fc3782e18
|
|
4
|
+
data.tar.gz: a6877d1a9884e078145440a96c2ae76dd31bff801eb30fc066d405071ec499ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a0e7913053632a9db051decb67dbc6461fa1499522986ded796469c1653d862cd69dd1957aaba3c5932900658098acebfc98a7441877a8c37afddae88ad63ce
|
|
7
|
+
data.tar.gz: 1bf8aa05e5352e20bb49c14fc44bbc2319ebb1041a7c0cc65a3591bd346b0d199de5fee276fa00aedd7785c5d42532e289428d523c9113021405f33e3ef0cc55
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Run tests
|
|
3
|
+
on: [push, pull_request] # yamllint disable-line rule:truthy
|
|
4
|
+
jobs:
|
|
5
|
+
test:
|
|
6
|
+
strategy:
|
|
7
|
+
fail-fast: false
|
|
8
|
+
matrix:
|
|
9
|
+
ruby: [
|
|
10
|
+
'2.3', '2.4', '2.5', '2.6', '2.7',
|
|
11
|
+
'3.0', '3.1', '3.2', '3.3', '3.4'
|
|
12
|
+
]
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
env:
|
|
15
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/spec/spec.gemfile
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v5
|
|
18
|
+
- uses: ruby/setup-ruby@v1
|
|
19
|
+
with:
|
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
|
21
|
+
bundler-cache: true
|
|
22
|
+
- run: bundle exec rspec
|
|
23
|
+
lint:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v5
|
|
27
|
+
- uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: 2.7
|
|
30
|
+
bundler-cache: true
|
|
31
|
+
- run: bundle exec rubocop
|
data/.gitignore
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.4.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-added-large-files
|
|
6
|
+
- id: check-merge-conflict
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- id: trailing-whitespace
|
|
10
|
+
- repo: https://github.com/mattlqx/pre-commit-ruby
|
|
11
|
+
rev: v1.3.5
|
|
12
|
+
hooks:
|
|
13
|
+
- id: rspec
|
|
14
|
+
- id: rubocop
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
AllCops:
|
|
3
|
+
Exclude:
|
|
4
|
+
- 'spec/fixtures/**/*'
|
|
5
|
+
- 'vendor/bundle/**/*'
|
|
6
|
+
NewCops: enable
|
|
7
|
+
Layout/HashAlignment:
|
|
8
|
+
EnforcedColonStyle: table
|
|
9
|
+
EnforcedHashRocketStyle: table
|
|
10
|
+
Layout/FirstArrayElementIndentation:
|
|
11
|
+
EnforcedStyle: consistent
|
|
12
|
+
Layout/FirstHashElementIndentation:
|
|
13
|
+
EnforcedStyle: consistent
|
|
14
|
+
Metrics:
|
|
15
|
+
Enabled: false
|
|
16
|
+
Naming/FileName:
|
|
17
|
+
Enabled: false
|
|
18
|
+
Style/TrailingCommaInArrayLiteral:
|
|
19
|
+
EnforcedStyleForMultiline: consistent_comma
|
|
20
|
+
Style/TrailingCommaInHashLiteral:
|
|
21
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## [1.1.0] - 2025-11-17
|
|
5
|
+
|
|
6
|
+
### Changed
|
|
7
|
+
|
|
8
|
+
- Add support for ruby >= 3.3 (@markeganfuller).
|
|
9
|
+
- Drop use of `untainted` (@markeganfuller).
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## [1.0.0] - 2023-03-12
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Drop support for rubies older than 2.3.0.
|
|
17
|
+
- Improve documentation.
|
|
18
|
+
- Various lint fixes.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [0.0.2] - 2016-04-12
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Fix minor doc bugs.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [0.0.1] - 2016-04-08
|
|
29
|
+
|
|
30
|
+
Initial release.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
[1.1.0]: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/compare/v1.0.0...v1.1.0
|
|
34
|
+
[1.0.0]: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/compare/v0.0.2...v1.0.0
|
|
35
|
+
[0.0.2]: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/compare/v0.0.1...v0.0.2
|
|
36
|
+
[0.0.1]: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/releases/tag/v0.0.1
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
5
|
+
ruby '2.7.8'
|
|
6
|
+
|
|
3
7
|
# Specify your gem's dependencies in resolv-hosts-dynamic.gemspec
|
|
4
8
|
gemspec
|
|
9
|
+
|
|
10
|
+
# Development dependencies
|
|
11
|
+
group :development do
|
|
12
|
+
gem 'bundler', '~> 2'
|
|
13
|
+
gem 'rake', '~> 10.0'
|
|
14
|
+
gem 'rspec'
|
|
15
|
+
gem 'rubocop', '~> 1.26'
|
|
16
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
resolv-hosts-dynamic (1.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.2)
|
|
10
|
+
diff-lcs (1.5.0)
|
|
11
|
+
parallel (1.22.1)
|
|
12
|
+
parser (3.1.2.0)
|
|
13
|
+
ast (~> 2.4.1)
|
|
14
|
+
rainbow (3.1.1)
|
|
15
|
+
rake (10.5.0)
|
|
16
|
+
regexp_parser (2.5.0)
|
|
17
|
+
rexml (3.2.5)
|
|
18
|
+
rspec (3.11.0)
|
|
19
|
+
rspec-core (~> 3.11.0)
|
|
20
|
+
rspec-expectations (~> 3.11.0)
|
|
21
|
+
rspec-mocks (~> 3.11.0)
|
|
22
|
+
rspec-core (3.11.0)
|
|
23
|
+
rspec-support (~> 3.11.0)
|
|
24
|
+
rspec-expectations (3.11.0)
|
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
26
|
+
rspec-support (~> 3.11.0)
|
|
27
|
+
rspec-mocks (3.11.1)
|
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
29
|
+
rspec-support (~> 3.11.0)
|
|
30
|
+
rspec-support (3.11.0)
|
|
31
|
+
rubocop (1.28.2)
|
|
32
|
+
parallel (~> 1.10)
|
|
33
|
+
parser (>= 3.1.0.0)
|
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
35
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
36
|
+
rexml
|
|
37
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
|
38
|
+
ruby-progressbar (~> 1.7)
|
|
39
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
40
|
+
rubocop-ast (1.17.0)
|
|
41
|
+
parser (>= 3.1.1.0)
|
|
42
|
+
ruby-progressbar (1.11.0)
|
|
43
|
+
unicode-display_width (2.2.0)
|
|
44
|
+
|
|
45
|
+
PLATFORMS
|
|
46
|
+
ruby
|
|
47
|
+
x86_64-linux
|
|
48
|
+
|
|
49
|
+
DEPENDENCIES
|
|
50
|
+
bundler (~> 2)
|
|
51
|
+
rake (~> 10.0)
|
|
52
|
+
resolv-hosts-dynamic!
|
|
53
|
+
rspec
|
|
54
|
+
rubocop (~> 1.26)
|
|
55
|
+
|
|
56
|
+
RUBY VERSION
|
|
57
|
+
ruby 2.7.7p221
|
|
58
|
+
|
|
59
|
+
BUNDLED WITH
|
|
60
|
+
2.3.8
|
data/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Resolv::Hosts::Dynamic
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/resolv-hosts-dynamic)
|
|
4
|
+
[](https://github.com/chris-reeves/gem-resolv-hosts-dynamic/actions/workflows/test.yml)
|
|
5
|
+
|
|
3
6
|
Dynamic in-memory 'hosts' file for resolving hostnames. Injects entries into
|
|
4
7
|
an in-memory 'hosts' file which can later be used for name resolution without
|
|
5
8
|
having to modify the system hosts file. This is an extension to the standard
|
|
@@ -126,7 +129,8 @@ Resolv.getaddresses('www.google.com')
|
|
|
126
129
|
## Contributing
|
|
127
130
|
|
|
128
131
|
1. Fork it ( https://github.com/chris-reeves/gem-resolv-hosts-dynamic/fork )
|
|
129
|
-
2.
|
|
130
|
-
3.
|
|
131
|
-
4.
|
|
132
|
-
5.
|
|
132
|
+
2. Install pre-commit (`pip install pre-commit; pre-commit install`)
|
|
133
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
|
134
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
135
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
|
136
|
+
6. Create a new Pull Request
|
data/Rakefile
CHANGED
data/lib/resolv-hosts-dynamic.rb
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'resolv'
|
|
2
4
|
|
|
3
5
|
class Resolv
|
|
4
6
|
class Hosts
|
|
7
|
+
##
|
|
8
|
+
# Resolve::Hosts::Dynamic is a dynamic in-memory 'hosts' file for
|
|
9
|
+
# resolving hostnames. It injects entries into an in-memory 'hosts' file
|
|
10
|
+
# which can later be used for name resolution without having to modify the
|
|
11
|
+
# system hosts file. This is an extension to the standard ruby Resolv
|
|
12
|
+
# library and is useful for over-riding name resolution during testing.
|
|
5
13
|
class Dynamic
|
|
6
|
-
|
|
7
14
|
def initialize(hosts = [])
|
|
8
15
|
@mutex = Mutex.new
|
|
9
16
|
@name2addr = {}
|
|
10
17
|
@addr2name = {}
|
|
11
18
|
|
|
12
|
-
hosts = [hosts]
|
|
19
|
+
hosts = [hosts] unless hosts.is_a? Array
|
|
13
20
|
|
|
14
|
-
hosts.each
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
hosts.each do |host|
|
|
22
|
+
add_address(host)
|
|
23
|
+
end
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
##
|
|
20
27
|
# Adds +host+ to the custom resolver.
|
|
21
28
|
|
|
22
29
|
def add_address(host)
|
|
23
|
-
@mutex.synchronize
|
|
30
|
+
@mutex.synchronize do
|
|
24
31
|
addr = host['addr']
|
|
25
32
|
hostname = host['hostname']
|
|
26
33
|
aliases = host['aliases']
|
|
@@ -28,9 +35,6 @@ class Resolv
|
|
|
28
35
|
raise "Must specify 'addr' for host" unless addr
|
|
29
36
|
raise "Must specify 'hostname' for host" unless hostname
|
|
30
37
|
|
|
31
|
-
addr.untaint
|
|
32
|
-
hostname.untaint
|
|
33
|
-
|
|
34
38
|
# So that aliases can be passed a string or an array of strings
|
|
35
39
|
aliases = [aliases] if aliases.is_a? String
|
|
36
40
|
|
|
@@ -39,20 +43,19 @@ class Resolv
|
|
|
39
43
|
@addr2name[addr] += aliases if aliases
|
|
40
44
|
@name2addr[hostname] = [] unless @name2addr.include? hostname
|
|
41
45
|
@name2addr[hostname] << addr
|
|
42
|
-
aliases
|
|
43
|
-
n.untaint
|
|
46
|
+
aliases&.each do |n|
|
|
44
47
|
@name2addr[n] = [] unless @name2addr.include? n
|
|
45
48
|
@name2addr[n] << addr
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
end
|
|
50
|
+
end
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
##
|
|
51
54
|
# Gets the IP address of +name+ from the custom resolver.
|
|
52
55
|
|
|
53
56
|
def getaddress(name)
|
|
54
|
-
each_address(name) {|address| return address}
|
|
55
|
-
raise ResolvError
|
|
57
|
+
each_address(name) { |address| return address } # rubocop:disable Lint/UnreachableLoop
|
|
58
|
+
raise ResolvError, "No dynamic hosts entry for name: #{name}"
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
##
|
|
@@ -60,25 +63,23 @@ class Resolv
|
|
|
60
63
|
|
|
61
64
|
def getaddresses(name)
|
|
62
65
|
ret = []
|
|
63
|
-
each_address(name) {|address| ret << address}
|
|
64
|
-
|
|
66
|
+
each_address(name) { |address| ret << address }
|
|
67
|
+
ret
|
|
65
68
|
end
|
|
66
69
|
|
|
67
70
|
##
|
|
68
71
|
# Iterates over all IP addresses for +name+ retrieved from the custom resolver.
|
|
69
72
|
|
|
70
73
|
def each_address(name, &proc)
|
|
71
|
-
if @name2addr.include?(name)
|
|
72
|
-
@name2addr[name].each(&proc)
|
|
73
|
-
end
|
|
74
|
+
@name2addr[name].each(&proc) if @name2addr.include?(name)
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
##
|
|
77
78
|
# Gets the hostname of +address+ from the custom resolver.
|
|
78
79
|
|
|
79
80
|
def getname(address)
|
|
80
|
-
each_name(address) {|name| return name}
|
|
81
|
-
raise ResolvError
|
|
81
|
+
each_name(address) { |name| return name } # rubocop:disable Lint/UnreachableLoop
|
|
82
|
+
raise ResolvError, "No dynamic hosts entry for address: #{address}"
|
|
82
83
|
end
|
|
83
84
|
|
|
84
85
|
##
|
|
@@ -86,19 +87,16 @@ class Resolv
|
|
|
86
87
|
|
|
87
88
|
def getnames(address)
|
|
88
89
|
ret = []
|
|
89
|
-
each_name(address) {|name| ret << name}
|
|
90
|
-
|
|
90
|
+
each_name(address) { |name| ret << name }
|
|
91
|
+
ret
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
##
|
|
94
95
|
# Iterates over all hostnames for +address+ retrieved from the custom resolver.
|
|
95
96
|
|
|
96
97
|
def each_name(address, &proc)
|
|
97
|
-
if @addr2name.include?(address)
|
|
98
|
-
@addr2name[address].each(&proc)
|
|
99
|
-
end
|
|
98
|
+
@addr2name[address].each(&proc) if @addr2name.include?(address)
|
|
100
99
|
end
|
|
101
|
-
|
|
102
100
|
end
|
|
103
101
|
end
|
|
104
102
|
end
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
5
|
|
|
5
6
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
7
|
-
spec.version =
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
10
|
-
spec.summary =
|
|
11
|
-
spec.description =
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
spec.name = 'resolv-hosts-dynamic'
|
|
8
|
+
spec.version = '1.1.0'
|
|
9
|
+
spec.authors = ['Chris Reeves']
|
|
10
|
+
spec.email = ['chris.reeves@iname.com']
|
|
11
|
+
spec.summary = "Dynamic in-memory 'hosts' file for resolving hostnames."
|
|
12
|
+
spec.description = <<-DESCRIPTION
|
|
13
|
+
Dynamic in-memory 'hosts' file for resolving hostnames. Injects entries
|
|
14
|
+
into an in-memory 'hosts' file which can later be used for name resolution
|
|
15
|
+
without having to modify the system hosts file. This is an extension to
|
|
16
|
+
the standard ruby Resolv library and is useful for over-riding name
|
|
17
|
+
resolution during testing.
|
|
18
|
+
DESCRIPTION
|
|
19
|
+
spec.homepage = 'https://github.com/chris-reeves/gem-resolv-hosts-dynamic'
|
|
20
|
+
spec.license = 'MIT'
|
|
21
|
+
|
|
22
|
+
spec.metadata = {
|
|
23
|
+
'homepage_uri' => 'https://github.com/chris-reeves/gem-resolv-hosts-dynamic',
|
|
24
|
+
'changelog_uri' => 'https://github.com/chris-reeves/gem-resolv-hosts-dynamic/blob/master/CHANGELOG.md',
|
|
25
|
+
'source_code_uri' => 'https://github.com/chris-reeves/gem-resolv-hosts-dynamic',
|
|
26
|
+
'bug_tracker_uri' => 'https://github.com/chris-reeves/gem-resolv-hosts-dynamic/issues',
|
|
27
|
+
'rubygems_mfa_required' => 'true',
|
|
28
|
+
}
|
|
14
29
|
|
|
15
30
|
spec.files = `git ls-files -z`.split("\x0")
|
|
16
31
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
17
32
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
-
spec.require_paths = [
|
|
33
|
+
spec.require_paths = ['lib']
|
|
19
34
|
|
|
20
|
-
spec.
|
|
21
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
22
|
-
spec.add_development_dependency "rspec"
|
|
35
|
+
spec.required_ruby_version = '>= 2.3.0' # rubocop:disable Gemspec/RequiredRubyVersion
|
|
23
36
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Resolv::Hosts::Dynamic do
|
|
4
|
-
|
|
5
6
|
describe '#initialize' do
|
|
6
7
|
context 'with an empty params list' do
|
|
7
8
|
res = Resolv::Hosts::Dynamic.new
|
|
@@ -122,7 +123,7 @@ describe Resolv::Hosts::Dynamic do
|
|
|
122
123
|
res.add_address({
|
|
123
124
|
'addr' => '127.1.2.3',
|
|
124
125
|
'hostname' => 'host.example.com',
|
|
125
|
-
'aliases' => [
|
|
126
|
+
'aliases' => %w[host host2],
|
|
126
127
|
})
|
|
127
128
|
|
|
128
129
|
it 'should map the hostname to the address' do
|
|
@@ -217,7 +218,7 @@ describe Resolv::Hosts::Dynamic do
|
|
|
217
218
|
dynres.add_address({
|
|
218
219
|
'addr' => '127.1.2.3',
|
|
219
220
|
'hostname' => 'host.example.com',
|
|
220
|
-
'aliases' => 'host'
|
|
221
|
+
'aliases' => 'host',
|
|
221
222
|
})
|
|
222
223
|
|
|
223
224
|
# name with multiple addresses
|
|
@@ -236,9 +237,9 @@ describe Resolv::Hosts::Dynamic do
|
|
|
236
237
|
end
|
|
237
238
|
|
|
238
239
|
it 'raises ResolvError if the name can not be looked up' do
|
|
239
|
-
expect
|
|
240
|
+
expect do
|
|
240
241
|
res.getaddress('no.such.host.')
|
|
241
|
-
|
|
242
|
+
end.to raise_error(Resolv::ResolvError)
|
|
242
243
|
end
|
|
243
244
|
end
|
|
244
245
|
|
|
@@ -246,7 +247,7 @@ describe Resolv::Hosts::Dynamic do
|
|
|
246
247
|
it 'resolves host.example.com to multiple addresses' do
|
|
247
248
|
expect(
|
|
248
249
|
res.getaddresses('host.example.com')
|
|
249
|
-
).to eq [
|
|
250
|
+
).to eq ['127.1.2.3', '127.4.5.6']
|
|
250
251
|
end
|
|
251
252
|
|
|
252
253
|
it 'resolves to no addresses if the name can not be looked up' do
|
|
@@ -264,9 +265,9 @@ describe Resolv::Hosts::Dynamic do
|
|
|
264
265
|
end
|
|
265
266
|
|
|
266
267
|
it 'raises ResolvError if the address can not be looked up' do
|
|
267
|
-
expect
|
|
268
|
+
expect do
|
|
268
269
|
res.getname('127.7.8.9')
|
|
269
|
-
|
|
270
|
+
end.to raise_error(Resolv::ResolvError)
|
|
270
271
|
end
|
|
271
272
|
end
|
|
272
273
|
|
|
@@ -274,7 +275,7 @@ describe Resolv::Hosts::Dynamic do
|
|
|
274
275
|
it 'resolves 127.1.2.3 to a single hostname' do
|
|
275
276
|
expect(
|
|
276
277
|
res.getnames('127.1.2.3')
|
|
277
|
-
).to eq [
|
|
278
|
+
).to eq ['host.example.com', 'host']
|
|
278
279
|
end
|
|
279
280
|
|
|
280
281
|
it 'resolves to no hostnames if the address can not be looked up' do
|
data/spec/spec.gemfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gemspec path: '..'
|
|
6
|
+
|
|
7
|
+
# This is a cut down Gemfile with minimal dependencies sufficient to run spec
|
|
8
|
+
# tests across as wide a range of ruby versions as possible.
|
|
9
|
+
group :development do
|
|
10
|
+
gem 'rspec'
|
|
11
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,82 +1,53 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resolv-hosts-dynamic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Reeves
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
version: '1.7'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.7'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '10.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '10.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
description: Dynamic in-memory 'hosts' file for resolving hostnames. Injects entries
|
|
56
|
-
into an in-memory 'hosts' file which can later be used for name resolution without
|
|
57
|
-
having to modify the system hosts file. This is an extension to the standard ruby
|
|
58
|
-
Resolv library and is useful for over-riding name resolution during testing.
|
|
11
|
+
date: 2025-11-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: |2
|
|
14
|
+
Dynamic in-memory 'hosts' file for resolving hostnames. Injects entries
|
|
15
|
+
into an in-memory 'hosts' file which can later be used for name resolution
|
|
16
|
+
without having to modify the system hosts file. This is an extension to
|
|
17
|
+
the standard ruby Resolv library and is useful for over-riding name
|
|
18
|
+
resolution during testing.
|
|
59
19
|
email:
|
|
60
|
-
- chris.reeves@
|
|
20
|
+
- chris.reeves@iname.com
|
|
61
21
|
executables: []
|
|
62
22
|
extensions: []
|
|
63
23
|
extra_rdoc_files: []
|
|
64
24
|
files:
|
|
25
|
+
- ".github/workflows/test.yml"
|
|
65
26
|
- ".gitignore"
|
|
27
|
+
- ".pre-commit-config.yaml"
|
|
66
28
|
- ".rspec"
|
|
29
|
+
- ".rubocop.yml"
|
|
30
|
+
- CHANGELOG.md
|
|
67
31
|
- Gemfile
|
|
32
|
+
- Gemfile.lock
|
|
68
33
|
- LICENSE
|
|
69
34
|
- README.md
|
|
70
35
|
- Rakefile
|
|
71
36
|
- lib/resolv-hosts-dynamic.rb
|
|
72
37
|
- resolv-hosts-dynamic.gemspec
|
|
73
38
|
- spec/resolv-hosts-dynamic_spec.rb
|
|
39
|
+
- spec/spec.gemfile
|
|
74
40
|
- spec/spec_helper.rb
|
|
75
|
-
homepage:
|
|
41
|
+
homepage: https://github.com/chris-reeves/gem-resolv-hosts-dynamic
|
|
76
42
|
licenses:
|
|
77
43
|
- MIT
|
|
78
|
-
metadata:
|
|
79
|
-
|
|
44
|
+
metadata:
|
|
45
|
+
homepage_uri: https://github.com/chris-reeves/gem-resolv-hosts-dynamic
|
|
46
|
+
changelog_uri: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/blob/master/CHANGELOG.md
|
|
47
|
+
source_code_uri: https://github.com/chris-reeves/gem-resolv-hosts-dynamic
|
|
48
|
+
bug_tracker_uri: https://github.com/chris-reeves/gem-resolv-hosts-dynamic/issues
|
|
49
|
+
rubygems_mfa_required: 'true'
|
|
50
|
+
post_install_message:
|
|
80
51
|
rdoc_options: []
|
|
81
52
|
require_paths:
|
|
82
53
|
- lib
|
|
@@ -84,18 +55,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
84
55
|
requirements:
|
|
85
56
|
- - ">="
|
|
86
57
|
- !ruby/object:Gem::Version
|
|
87
|
-
version:
|
|
58
|
+
version: 2.3.0
|
|
88
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
60
|
requirements:
|
|
90
61
|
- - ">="
|
|
91
62
|
- !ruby/object:Gem::Version
|
|
92
63
|
version: '0'
|
|
93
64
|
requirements: []
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
signing_key:
|
|
65
|
+
rubygems_version: 3.3.15
|
|
66
|
+
signing_key:
|
|
97
67
|
specification_version: 4
|
|
98
68
|
summary: Dynamic in-memory 'hosts' file for resolving hostnames.
|
|
99
69
|
test_files:
|
|
100
70
|
- spec/resolv-hosts-dynamic_spec.rb
|
|
71
|
+
- spec/spec.gemfile
|
|
101
72
|
- spec/spec_helper.rb
|