net-ping 2.0.8 → 2.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/CHANGES +28 -1
- data/CLAUDE.md +89 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +34 -16
- data/README.md +5 -3
- data/Rakefile +93 -8
- data/docs/superpowers/plans/2026-07-25-platform-specific-gems.md +317 -0
- data/docs/superpowers/specs/2026-07-25-platform-specific-gems-design.md +71 -0
- data/lib/net/ping/external.rb +5 -3
- data/lib/net/ping/ping.rb +2 -3
- data/lib/net/ping/version.rb +6 -0
- data/net-ping-universal-linux.gemspec +4 -0
- data/net-ping-universal-mingw-ucrt.gemspec +7 -0
- data/net-ping.gemspec +4 -16
- data/test/test_net_ping.rb +2 -4
- data/test/test_net_ping_external.rb +89 -0
- data/test/test_net_ping_gem_packaging.rb +333 -0
- data/test/test_net_ping_http.rb +27 -31
- data/test/test_net_ping_icmp.rb +6 -5
- data/test/test_net_ping_tcp.rb +2 -1
- metadata +14 -8
data/test/test_net_ping_http.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# 'test:http' Rake task.
|
|
6
6
|
#################################################################################
|
|
7
7
|
require 'test-unit'
|
|
8
|
-
require '
|
|
8
|
+
require 'webmock/test_unit'
|
|
9
9
|
require 'net/ping/http'
|
|
10
10
|
|
|
11
11
|
class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
@@ -17,27 +17,24 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
|
17
17
|
@uri_http_domain_scheme = 'http://http.com'
|
|
18
18
|
@uri_http_domain_schemes = 'https://http.com'
|
|
19
19
|
@proxy = 'http://username:password@proxymoxie:3128'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
FakeWeb.register_uri(:head, 'http://http502.com',
|
|
39
|
-
:body => "",
|
|
40
|
-
:status => ["502", "Bad Gateway"])
|
|
20
|
+
WebMock.disable_net_connect!
|
|
21
|
+
|
|
22
|
+
stub_request(:get, @uri).to_return(body: "PONG")
|
|
23
|
+
stub_request(:head, @uri).to_return(body: "PONG")
|
|
24
|
+
stub_request(:head, @uri_https).to_return(body: "PONG")
|
|
25
|
+
stub_request(:get, @uri_https).to_return(body: "PONG")
|
|
26
|
+
stub_request(:get, "http://#{@uri_http_domain}").to_return(body: "PONG")
|
|
27
|
+
stub_request(:head, "http://#{@uri_http_domain}").to_return(body: "PONG")
|
|
28
|
+
stub_request(:get, @uri_http_domain_scheme).to_return(body: "PONG")
|
|
29
|
+
stub_request(:head, @uri_http_domain_scheme).to_return(body: "PONG")
|
|
30
|
+
stub_request(:get, @uri_http_domain_schemes).to_return(body: "PONG")
|
|
31
|
+
stub_request(:head, @uri_http_domain_schemes).to_return(body: "PONG")
|
|
32
|
+
|
|
33
|
+
stub_request(:head, "https://jigsaw.w3.org/HTTP/300/302.html")
|
|
34
|
+
.to_return(body: "PONG", status: ["302", "Found"], headers: { 'location' => "#{@uri}" })
|
|
35
|
+
|
|
36
|
+
stub_request(:any, "http://www.blabfoobarurghxxxx.com").to_raise(SocketError)
|
|
37
|
+
stub_request(:head, "http://http502.com").to_return(body: "", status: ["502", "Bad Gateway"])
|
|
41
38
|
|
|
42
39
|
@http = Net::Ping::HTTP.new(@uri, 80, 30)
|
|
43
40
|
@http_http_domain = Net::Ping::HTTP.new(@uri_http_domain, 80, 30)
|
|
@@ -120,7 +117,7 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
|
120
117
|
|
|
121
118
|
test 'port attribute is set to expected value' do
|
|
122
119
|
assert_equal(80, @http.port)
|
|
123
|
-
assert_equal(443, Net::Ping::HTTP.new('https://github.com/
|
|
120
|
+
assert_equal(443, Net::Ping::HTTP.new('https://github.com/github').port)
|
|
124
121
|
assert_equal(80, Net::Ping::HTTP.new.port)
|
|
125
122
|
end
|
|
126
123
|
|
|
@@ -134,12 +131,11 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
|
134
131
|
assert_equal(5, @bad.timeout)
|
|
135
132
|
end
|
|
136
133
|
|
|
137
|
-
# TODO: Figure out how to do this with FakeWeb.
|
|
138
134
|
test 'ping fails if timeout exceeded' do
|
|
139
|
-
|
|
140
|
-
@http = Net::Ping::HTTP.new('https://
|
|
135
|
+
stub_request(:head, 'https://www.google.com/').to_timeout
|
|
136
|
+
@http = Net::Ping::HTTP.new('https://www.google.com', 443, 0.001)
|
|
141
137
|
assert_false(@http.ping?)
|
|
142
|
-
|
|
138
|
+
assert_include(['execution expired', 'Net::OpenTimeout'], @http.exception)
|
|
143
139
|
end
|
|
144
140
|
|
|
145
141
|
test 'exception attribute basic functionality' do
|
|
@@ -179,7 +175,7 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
|
179
175
|
test 'ping with user agent' do
|
|
180
176
|
@http.user_agent = "KDDI-CA32"
|
|
181
177
|
assert_true(@http.ping)
|
|
182
|
-
|
|
178
|
+
assert_requested(:any, @uri, headers: { "User-Agent" => "KDDI-CA32" }, times: 1)
|
|
183
179
|
end
|
|
184
180
|
|
|
185
181
|
test 'redirect_limit accessor is defined' do
|
|
@@ -192,18 +188,18 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
|
192
188
|
end
|
|
193
189
|
|
|
194
190
|
test 'redirects succeed by default' do
|
|
195
|
-
@http = Net::Ping::HTTP.new("
|
|
191
|
+
@http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
|
|
196
192
|
assert_true(@http.ping)
|
|
197
193
|
end
|
|
198
194
|
|
|
199
195
|
test 'redirect fail if follow_redirect is set to false' do
|
|
200
|
-
@http = Net::Ping::HTTP.new("
|
|
196
|
+
@http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
|
|
201
197
|
@http.follow_redirect = false
|
|
202
198
|
assert_false(@http.ping)
|
|
203
199
|
end
|
|
204
200
|
|
|
205
201
|
test 'ping with redirect limit set to zero fails' do
|
|
206
|
-
@http = Net::Ping::HTTP.new("
|
|
202
|
+
@http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
|
|
207
203
|
@http.redirect_limit = 0
|
|
208
204
|
assert_false(@http.ping)
|
|
209
205
|
assert_equal("Redirect limit exceeded", @http.exception)
|
data/test/test_net_ping_icmp.rb
CHANGED
|
@@ -43,7 +43,7 @@ class TC_PingICMP < Test::Unit::TestCase
|
|
|
43
43
|
def setup
|
|
44
44
|
@host = '127.0.0.1' # 'localhost'
|
|
45
45
|
@icmp = Net::Ping::ICMP.new(@host)
|
|
46
|
-
@concurrency =
|
|
46
|
+
@concurrency = 2
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
test "icmp ping basic functionality" do
|
|
@@ -71,7 +71,8 @@ class TC_PingICMP < Test::Unit::TestCase
|
|
|
71
71
|
|
|
72
72
|
test "threaded icmp ping returns expected results" do
|
|
73
73
|
omit_if(@@jruby)
|
|
74
|
-
ips = ['8.8.4.4', '8.8.9.9', '127.0.0.1', '8.8.8.8', '8.8.8.9']
|
|
74
|
+
# ips = ['8.8.4.4', '8.8.9.9', '127.0.0.1', '8.8.8.8', '8.8.8.9']
|
|
75
|
+
ips = ['127.0.0.1', '8.8.8.9']
|
|
75
76
|
queue = Queue.new
|
|
76
77
|
threads = []
|
|
77
78
|
|
|
@@ -81,10 +82,10 @@ class TC_PingICMP < Test::Unit::TestCase
|
|
|
81
82
|
threads << Thread.new(queue) do |q|
|
|
82
83
|
ip = q.pop
|
|
83
84
|
icmp = Net::Ping::ICMP.new(ip, nil, 1)
|
|
84
|
-
if ip =~
|
|
85
|
-
assert_false(icmp.ping
|
|
85
|
+
if ip =~ /\.9$/
|
|
86
|
+
assert_false(icmp.ping?, "#{ip} should not be pingable")
|
|
86
87
|
else
|
|
87
|
-
assert_true(icmp.ping
|
|
88
|
+
assert_true(icmp.ping?, "#{ip} should be pingable")
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
}
|
data/test/test_net_ping_tcp.rb
CHANGED
|
@@ -91,7 +91,8 @@ class TC_PingTCP < Test::Unit::TestCase
|
|
|
91
91
|
msg = "+this test may fail depending on your network environment+"
|
|
92
92
|
assert_respond_to(@tcp, :exception)
|
|
93
93
|
assert_nothing_raised{ @tcp.ping }
|
|
94
|
-
|
|
94
|
+
# XXX: In some environment, it will get some execption
|
|
95
|
+
assert(@tcp.exception.nil? || @tcp.exception == Errno::ECONNREFUSED, msg)
|
|
95
96
|
end
|
|
96
97
|
|
|
97
98
|
def test_warning
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-ping
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Chernesky
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-08-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-unit
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: webmock
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -80,12 +80,15 @@ extra_rdoc_files:
|
|
|
80
80
|
files:
|
|
81
81
|
- CHANGES
|
|
82
82
|
- CHANGES.out_of_date
|
|
83
|
+
- CLAUDE.md
|
|
83
84
|
- Gemfile
|
|
84
85
|
- Gemfile.lock
|
|
85
86
|
- MANIFEST
|
|
86
87
|
- README.md
|
|
87
88
|
- Rakefile
|
|
88
89
|
- doc/ping.txt
|
|
90
|
+
- docs/superpowers/plans/2026-07-25-platform-specific-gems.md
|
|
91
|
+
- docs/superpowers/specs/2026-07-25-platform-specific-gems-design.md
|
|
89
92
|
- examples/example_pingexternal.rb
|
|
90
93
|
- examples/example_pinghttp.rb
|
|
91
94
|
- examples/example_pingtcp.rb
|
|
@@ -97,10 +100,14 @@ files:
|
|
|
97
100
|
- lib/net/ping/ping.rb
|
|
98
101
|
- lib/net/ping/tcp.rb
|
|
99
102
|
- lib/net/ping/udp.rb
|
|
103
|
+
- lib/net/ping/version.rb
|
|
100
104
|
- lib/net/ping/wmi.rb
|
|
105
|
+
- net-ping-universal-linux.gemspec
|
|
106
|
+
- net-ping-universal-mingw-ucrt.gemspec
|
|
101
107
|
- net-ping.gemspec
|
|
102
108
|
- test/test_net_ping.rb
|
|
103
109
|
- test/test_net_ping_external.rb
|
|
110
|
+
- test/test_net_ping_gem_packaging.rb
|
|
104
111
|
- test/test_net_ping_http.rb
|
|
105
112
|
- test/test_net_ping_icmp.rb
|
|
106
113
|
- test/test_net_ping_tcp.rb
|
|
@@ -115,7 +122,7 @@ metadata:
|
|
|
115
122
|
documentation_uri: https://www.rubydoc.info/gems/net-ping
|
|
116
123
|
homepage_uri: https://github.com/chernesk/net-ping
|
|
117
124
|
source_code_uri: https://github.com/chernesk/net-ping
|
|
118
|
-
post_install_message:
|
|
125
|
+
post_install_message:
|
|
119
126
|
rdoc_options: []
|
|
120
127
|
require_paths:
|
|
121
128
|
- lib
|
|
@@ -130,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
130
137
|
- !ruby/object:Gem::Version
|
|
131
138
|
version: '0'
|
|
132
139
|
requirements: []
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
signing_key:
|
|
140
|
+
rubygems_version: 3.5.22
|
|
141
|
+
signing_key:
|
|
136
142
|
specification_version: 4
|
|
137
143
|
summary: A ping interface for Ruby.
|
|
138
144
|
test_files:
|