net-ping 2.1.0-universal-linux
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 +7 -0
- data/CHANGES +28 -0
- data/CHANGES.out_of_date +354 -0
- data/CLAUDE.md +89 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +53 -0
- data/MANIFEST +25 -0
- data/README.md +65 -0
- data/Rakefile +183 -0
- data/doc/ping.txt +246 -0
- 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/examples/example_pingexternal.rb +16 -0
- data/examples/example_pinghttp.rb +22 -0
- data/examples/example_pingtcp.rb +16 -0
- data/examples/example_pingudp.rb +12 -0
- data/lib/net/ping/external.rb +185 -0
- data/lib/net/ping/http.rb +189 -0
- data/lib/net/ping/icmp.rb +188 -0
- data/lib/net/ping/ping.rb +99 -0
- data/lib/net/ping/tcp.rb +110 -0
- data/lib/net/ping/udp.rb +117 -0
- data/lib/net/ping/version.rb +6 -0
- data/lib/net/ping/wmi.rb +118 -0
- data/lib/net/ping.rb +24 -0
- data/net-ping-universal-linux.gemspec +4 -0
- data/net-ping-universal-mingw-ucrt.gemspec +7 -0
- data/net-ping.gemspec +36 -0
- data/test/test_net_ping.rb +44 -0
- data/test/test_net_ping_external.rb +232 -0
- data/test/test_net_ping_gem_packaging.rb +333 -0
- data/test/test_net_ping_http.rb +264 -0
- data/test/test_net_ping_icmp.rb +199 -0
- data/test/test_net_ping_tcp.rb +106 -0
- data/test/test_net_ping_udp.rb +117 -0
- data/test/test_net_ping_wmi.rb +81 -0
- metadata +159 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#######################################################################
|
|
2
|
+
# test_net_ping_icmp.rb
|
|
3
|
+
#
|
|
4
|
+
# Test case for the Net::PingICMP class. You must run this test case
|
|
5
|
+
# with root privileges on UNIX systems. This should be run via the
|
|
6
|
+
# 'test' or 'test:icmp' Rake task.
|
|
7
|
+
#######################################################################
|
|
8
|
+
require 'test-unit'
|
|
9
|
+
require 'net/ping/icmp'
|
|
10
|
+
require 'thread'
|
|
11
|
+
|
|
12
|
+
if File::ALT_SEPARATOR
|
|
13
|
+
require 'win32/security'
|
|
14
|
+
|
|
15
|
+
unless Win32::Security.elevated_security?
|
|
16
|
+
raise "The test:icmp task must be run with elevated security rights"
|
|
17
|
+
end
|
|
18
|
+
else
|
|
19
|
+
|
|
20
|
+
begin
|
|
21
|
+
# If we have cap2; raise error unless we are root, or have net_raw
|
|
22
|
+
require 'cap2'
|
|
23
|
+
current_process = Cap2.process
|
|
24
|
+
unless Process.euid == 0 \
|
|
25
|
+
|| current_process.permitted?(:net_raw) \
|
|
26
|
+
&& current_process.enabled?(:net_raw)
|
|
27
|
+
raise StandardError, 'requires root privileges or setcap net_raw'
|
|
28
|
+
end
|
|
29
|
+
rescue LoadError
|
|
30
|
+
# Without cap2; raise error unless we are root
|
|
31
|
+
unless Process.euid == 0
|
|
32
|
+
raise StandardError, 'requires root privileges or setcap net_raw'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class TC_PingICMP < Test::Unit::TestCase
|
|
39
|
+
def self.startup
|
|
40
|
+
@@jruby = RUBY_PLATFORM == 'java'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def setup
|
|
44
|
+
@host = '127.0.0.1' # 'localhost'
|
|
45
|
+
@icmp = Net::Ping::ICMP.new(@host)
|
|
46
|
+
@concurrency = 2
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
test "icmp ping basic functionality" do
|
|
50
|
+
assert_respond_to(@icmp, :ping)
|
|
51
|
+
omit_if(@@jruby)
|
|
52
|
+
assert_nothing_raised{ @icmp.ping }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "icmp ping accepts a host" do
|
|
56
|
+
omit_if(@@jruby)
|
|
57
|
+
assert_nothing_raised{ @icmp.ping(@host) }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
test "icmp ping returns a float" do
|
|
61
|
+
omit_if(@@jruby)
|
|
62
|
+
assert_kind_of(Float, @icmp.ping)
|
|
63
|
+
assert_kind_of(Float, @icmp.ping(@host))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
test "icmp ping of local host is successful" do
|
|
67
|
+
omit_if(@@jruby)
|
|
68
|
+
assert_true(Net::Ping::ICMP.new(@host).ping?)
|
|
69
|
+
assert_true(Net::Ping::ICMP.new('127.0.0.1').ping?)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
test "threaded icmp ping returns expected results" do
|
|
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']
|
|
75
|
+
ips = ['127.0.0.1', '8.8.8.9']
|
|
76
|
+
queue = Queue.new
|
|
77
|
+
threads = []
|
|
78
|
+
|
|
79
|
+
ips.each{ |ip| queue << ip }
|
|
80
|
+
|
|
81
|
+
@concurrency.times{
|
|
82
|
+
threads << Thread.new(queue) do |q|
|
|
83
|
+
ip = q.pop
|
|
84
|
+
icmp = Net::Ping::ICMP.new(ip, nil, 1)
|
|
85
|
+
if ip =~ /\.9$/
|
|
86
|
+
assert_false(icmp.ping?, "#{ip} should not be pingable")
|
|
87
|
+
else
|
|
88
|
+
assert_true(icmp.ping?, "#{ip} should be pingable")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
threads.each{ |t| t.join }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
test "ping? is inherited" do
|
|
97
|
+
assert_respond_to(@icmp, :ping?)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
test "pingecho is inherited" do
|
|
101
|
+
assert_respond_to(@icmp, :pingecho)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
test "icmp ping fails if host is invalid" do
|
|
105
|
+
omit_if(@@jruby)
|
|
106
|
+
assert_false(Net::Ping::ICMP.new('bogus').ping?)
|
|
107
|
+
assert_false(Net::Ping::ICMP.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
test "bind method basic functionality" do
|
|
111
|
+
assert_respond_to(@icmp, :bind)
|
|
112
|
+
assert_nothing_raised{ @icmp.bind(Socket.gethostname) }
|
|
113
|
+
assert_nothing_raised{ @icmp.bind(Socket.gethostname, 80) }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
test "duration method basic functionality" do
|
|
117
|
+
omit_if(@@jruby)
|
|
118
|
+
assert_nothing_raised{ @icmp.ping }
|
|
119
|
+
assert_respond_to(@icmp, :duration)
|
|
120
|
+
assert_kind_of(Float, @icmp.duration)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
test "host getter method basic functionality" do
|
|
124
|
+
assert_respond_to(@icmp, :host)
|
|
125
|
+
assert_equal(@host, @icmp.host)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
test "host setter method basic functionality" do
|
|
129
|
+
assert_respond_to(@icmp, :host=)
|
|
130
|
+
assert_nothing_raised{ @icmp.host = '192.168.0.1' }
|
|
131
|
+
assert_equal(@icmp.host, '192.168.0.1')
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
test "port method basic functionality" do
|
|
135
|
+
assert_respond_to(@icmp, :port)
|
|
136
|
+
assert_equal(nil, @icmp.port)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
test "timeout getter method basic functionality" do
|
|
140
|
+
assert_respond_to(@icmp, :timeout)
|
|
141
|
+
assert_equal(5, @icmp.timeout)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
test "timeout setter method basic functionality" do
|
|
145
|
+
assert_respond_to(@icmp, :timeout=)
|
|
146
|
+
assert_nothing_raised{ @icmp.timeout = 7 }
|
|
147
|
+
assert_equal(7, @icmp.timeout)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
test "timeout works as expected" do
|
|
151
|
+
omit_if(@@jruby)
|
|
152
|
+
icmp = Net::Ping::ICMP.new('8.8.8.8', nil, 0.000001)
|
|
153
|
+
assert_false(icmp.ping?)
|
|
154
|
+
assert_kind_of(Timeout::Error, icmp.exception)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
test "exception method basic functionality" do
|
|
158
|
+
assert_respond_to(@icmp, :exception)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
test "exception method returns nil if no ping has happened yet" do
|
|
162
|
+
assert_nil(@icmp.exception)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
test "warning method basic functionality" do
|
|
166
|
+
assert_respond_to(@icmp, :warning)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
test "data_size getter method basic functionality" do
|
|
170
|
+
assert_respond_to(@icmp, :data_size)
|
|
171
|
+
assert_nothing_raised{ @icmp.data_size }
|
|
172
|
+
assert_kind_of(Numeric, @icmp.data_size)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
test "data_size returns expected value" do
|
|
176
|
+
assert_equal(56, @icmp.data_size)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
test "data_size setter method basic functionality" do
|
|
180
|
+
assert_respond_to(@icmp, :data_size=)
|
|
181
|
+
assert_nothing_raised{ @icmp.data_size = 22 }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
test "setting an odd data_size is valid" do
|
|
185
|
+
omit_if(@@jruby)
|
|
186
|
+
assert_nothing_raised{ @icmp.data_size = 57 }
|
|
187
|
+
assert_kind_of(Float, @icmp.ping)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def teardown
|
|
191
|
+
@host = nil
|
|
192
|
+
@icmp = nil
|
|
193
|
+
@concurrency = nil
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def self.shutdown
|
|
197
|
+
@@jruby = nil
|
|
198
|
+
end
|
|
199
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#####################################################################
|
|
2
|
+
# test_net_ping_tcp.rb
|
|
3
|
+
#
|
|
4
|
+
# Test case for the Net::PingTCP class. This test should be run via
|
|
5
|
+
# the 'test' or 'test:tcp' Rake task.
|
|
6
|
+
#####################################################################
|
|
7
|
+
require 'test-unit'
|
|
8
|
+
require 'net/ping/tcp'
|
|
9
|
+
include Net
|
|
10
|
+
|
|
11
|
+
class TC_PingTCP < Test::Unit::TestCase
|
|
12
|
+
def setup
|
|
13
|
+
@host = 'localhost'
|
|
14
|
+
@port = 22
|
|
15
|
+
@tcp = Ping::TCP.new(@host, @port)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_ping
|
|
19
|
+
assert_respond_to(@tcp, :ping)
|
|
20
|
+
assert_nothing_raised{ @tcp.ping }
|
|
21
|
+
assert_nothing_raised{ @tcp.ping(@host) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_ping_aliases
|
|
25
|
+
assert_respond_to(@tcp, :ping?)
|
|
26
|
+
assert_respond_to(@tcp, :pingecho)
|
|
27
|
+
assert_nothing_raised{ @tcp.ping? }
|
|
28
|
+
assert_nothing_raised{ @tcp.ping?(@host) }
|
|
29
|
+
assert_nothing_raised{ @tcp.pingecho }
|
|
30
|
+
assert_nothing_raised{ @tcp.pingecho(@host) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_ping_service_check_false
|
|
34
|
+
msg = "+this test may fail depending on your network environment+"
|
|
35
|
+
Ping::TCP.service_check = false
|
|
36
|
+
@tcp = Ping::TCP.new('localhost')
|
|
37
|
+
assert_false(@tcp.ping?, msg)
|
|
38
|
+
assert_false(@tcp.exception.nil?, "Bad exception data")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_ping_service_check_true
|
|
42
|
+
msg = "+this test may fail depending on your network environment+"
|
|
43
|
+
Ping::TCP.service_check = true
|
|
44
|
+
assert_true(@tcp.ping?, msg)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_service_check
|
|
48
|
+
assert_respond_to(Ping::TCP, :service_check)
|
|
49
|
+
assert_respond_to(Ping::TCP, :service_check=)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# These will be removed eventually
|
|
53
|
+
def test_service_check_aliases
|
|
54
|
+
assert_respond_to(Ping::TCP, :econnrefused)
|
|
55
|
+
assert_respond_to(Ping::TCP, :econnrefused=)
|
|
56
|
+
assert_respond_to(Ping::TCP, :ecr)
|
|
57
|
+
assert_respond_to(Ping::TCP, :ecr=)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_service_check_expected_errors
|
|
61
|
+
assert_raises(ArgumentError){ Ping::TCP.service_check = "blah" }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# If the ping failed, the duration will be nil
|
|
65
|
+
def test_duration
|
|
66
|
+
assert_nothing_raised{ @tcp.ping }
|
|
67
|
+
assert_respond_to(@tcp, :duration)
|
|
68
|
+
omit_if(@tcp.duration.nil?, 'ping failed, skipping')
|
|
69
|
+
assert_kind_of(Float, @tcp.duration)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_host
|
|
73
|
+
assert_respond_to(@tcp, :host)
|
|
74
|
+
assert_respond_to(@tcp, :host=)
|
|
75
|
+
assert_equal(@host, @tcp.host)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_port
|
|
79
|
+
assert_respond_to(@tcp, :port)
|
|
80
|
+
assert_respond_to(@tcp, :port=)
|
|
81
|
+
assert_equal(22, @tcp.port)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_timeout
|
|
85
|
+
assert_respond_to(@tcp, :timeout)
|
|
86
|
+
assert_respond_to(@tcp, :timeout=)
|
|
87
|
+
assert_equal(5, @tcp.timeout)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_exception
|
|
91
|
+
msg = "+this test may fail depending on your network environment+"
|
|
92
|
+
assert_respond_to(@tcp, :exception)
|
|
93
|
+
assert_nothing_raised{ @tcp.ping }
|
|
94
|
+
# XXX: In some environment, it will get some execption
|
|
95
|
+
assert(@tcp.exception.nil? || @tcp.exception == Errno::ECONNREFUSED, msg)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_warning
|
|
99
|
+
assert_respond_to(@tcp, :warning)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def teardown
|
|
103
|
+
@host = nil
|
|
104
|
+
@tcp = nil
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
########################################################################
|
|
2
|
+
# test_net_ping_udp.rb
|
|
3
|
+
#
|
|
4
|
+
# Test case for the Net::Ping::UDP class. This should be run via the
|
|
5
|
+
# 'test' or 'test:udp' Rake tasks.
|
|
6
|
+
#
|
|
7
|
+
# If someone could provide me a host where a udp ping actually
|
|
8
|
+
# works (with a service check), I would appreciate it. :)
|
|
9
|
+
########################################################################
|
|
10
|
+
require 'test-unit'
|
|
11
|
+
require 'net/ping/udp'
|
|
12
|
+
|
|
13
|
+
class TC_Net_Ping_UDP < Test::Unit::TestCase
|
|
14
|
+
def setup
|
|
15
|
+
Net::Ping::UDP.service_check = false
|
|
16
|
+
@host = '127.0.0.1'
|
|
17
|
+
@udp = Net::Ping::UDP.new(@host)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "ping basic functionality" do
|
|
21
|
+
assert_respond_to(@udp, :ping)
|
|
22
|
+
assert_nothing_raised{ @udp.ping }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "ping accepts a host as an argument" do
|
|
26
|
+
assert_nothing_raised{ @udp.ping(@host) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test "ping? is inherited" do
|
|
30
|
+
assert_respond_to(@udp, :ping?)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "pingecho is inherited" do
|
|
34
|
+
assert_respond_to(@udp, :pingecho)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "a successful udp ping returns true" do
|
|
38
|
+
assert_true(@udp.ping?)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "bind basic functionality" do
|
|
42
|
+
assert_respond_to(@udp, :bind)
|
|
43
|
+
assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test "duration basic functionality" do
|
|
47
|
+
assert_nothing_raised{ @udp.ping }
|
|
48
|
+
assert_respond_to(@udp, :duration)
|
|
49
|
+
assert_kind_of(Float, @udp.duration)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
test "host basic functionality" do
|
|
53
|
+
assert_respond_to(@udp, :host)
|
|
54
|
+
assert_respond_to(@udp, :host=)
|
|
55
|
+
assert_equal('127.0.0.1', @udp.host)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test "port basic functionality" do
|
|
59
|
+
assert_respond_to(@udp, :port)
|
|
60
|
+
assert_respond_to(@udp, :port=)
|
|
61
|
+
assert_equal(7, @udp.port)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
test "timeout basic functionality" do
|
|
65
|
+
assert_respond_to(@udp, :timeout)
|
|
66
|
+
assert_respond_to(@udp, :timeout=)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "timeout default value is five" do
|
|
70
|
+
assert_equal(5, @udp.timeout)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
test "exception basic functionality" do
|
|
74
|
+
assert_respond_to(@udp, :exception)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
test "the exception attribute returns nil if the ping is successful" do
|
|
78
|
+
assert_true(@udp.ping?)
|
|
79
|
+
assert_nil(@udp.exception)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
test "the exception attribute is not nil if the ping is unsuccessful" do
|
|
83
|
+
assert_false(@udp.ping?('www.ruby-lang.org'))
|
|
84
|
+
assert_not_nil(@udp.exception)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
test "warning basic functionality" do
|
|
88
|
+
assert_respond_to(@udp, :warning)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
test "the warning attribute returns nil if the ping is successful" do
|
|
92
|
+
assert_true(@udp.ping?)
|
|
93
|
+
assert_nil(@udp.warning)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
test "service_check basic functionality" do
|
|
97
|
+
assert_respond_to(Net::Ping::UDP, :service_check)
|
|
98
|
+
assert_respond_to(Net::Ping::UDP, :service_check=)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
test "service_check attribute has been set to false" do
|
|
102
|
+
assert_false(Net::Ping::UDP.service_check)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
test "service_check getter method does not accept arguments" do
|
|
106
|
+
assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
test "service_check setter method only accepts boolean arguments" do
|
|
110
|
+
assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def teardown
|
|
114
|
+
@host = nil
|
|
115
|
+
@udp = nil
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#######################################################################
|
|
2
|
+
# test_net_ping_wmi.rb
|
|
3
|
+
#
|
|
4
|
+
# Test case for the Net::Ping::WMI class. These tests will only be
|
|
5
|
+
# run MS Windows. You should run this test via the 'test' or
|
|
6
|
+
# 'test:wmi' Rake task.
|
|
7
|
+
#######################################################################
|
|
8
|
+
require 'test-unit'
|
|
9
|
+
require 'net/ping/wmi'
|
|
10
|
+
include Net
|
|
11
|
+
|
|
12
|
+
class TC_Ping_WMI < Test::Unit::TestCase
|
|
13
|
+
def self.startup
|
|
14
|
+
@@windows = File::ALT_SEPARATOR
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def setup
|
|
18
|
+
@host = "www.ruby-lang.org"
|
|
19
|
+
@wmi = Ping::WMI.new(@host) if @@windows
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_ping_basic
|
|
23
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
24
|
+
assert_respond_to(@wmi, :ping)
|
|
25
|
+
assert_nothing_raised{ @wmi.ping }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_ping_with_host
|
|
29
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
30
|
+
assert_nothing_raised{ @wmi.ping(@host) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_ping_with_options
|
|
34
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
35
|
+
assert_nothing_raised{ @wmi.ping(@host, :NoFragmentation => true) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_pingecho_alias
|
|
39
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
40
|
+
assert_respond_to(@wmi, :pingecho)
|
|
41
|
+
assert_nothing_raised{ @wmi.pingecho }
|
|
42
|
+
assert_nothing_raised{ @wmi.pingecho(@host) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_ping_returns_struct
|
|
46
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
47
|
+
assert_kind_of(Struct::PingStatus, @wmi.ping)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_ping_returns_boolean
|
|
51
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
52
|
+
assert_boolean(@wmi.ping?)
|
|
53
|
+
assert_boolean(@wmi.ping?(@host))
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_ping_expected_failure
|
|
57
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
58
|
+
assert_false(Ping::WMI.new('bogus').ping?)
|
|
59
|
+
assert_false(Ping::WMI.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_exception
|
|
63
|
+
omit_unless(@@windows, 'skipped on Unix platforms')
|
|
64
|
+
assert_respond_to(@wmi, :exception)
|
|
65
|
+
assert_nothing_raised{ @wmi.ping }
|
|
66
|
+
assert_nil(@wmi.exception)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_warning
|
|
70
|
+
assert_respond_to(@wmi, :warning)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def teardown
|
|
74
|
+
@host = nil
|
|
75
|
+
@wmi = nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def self.shutdown
|
|
79
|
+
@@windows = nil
|
|
80
|
+
end
|
|
81
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: net-ping
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.1.0
|
|
5
|
+
platform: universal-linux
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Chernesky
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-08-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: test-unit
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: webmock
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry-byebug
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: cap2
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.2.2
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.2.2
|
|
83
|
+
description: |2
|
|
84
|
+
The net-ping library provides a ping interface for Ruby. It includes
|
|
85
|
+
separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping
|
|
86
|
+
classes.
|
|
87
|
+
email: chris.netping@tinderglow.com
|
|
88
|
+
executables: []
|
|
89
|
+
extensions: []
|
|
90
|
+
extra_rdoc_files:
|
|
91
|
+
- README.md
|
|
92
|
+
- CHANGES
|
|
93
|
+
- doc/ping.txt
|
|
94
|
+
files:
|
|
95
|
+
- CHANGES
|
|
96
|
+
- CHANGES.out_of_date
|
|
97
|
+
- CLAUDE.md
|
|
98
|
+
- Gemfile
|
|
99
|
+
- Gemfile.lock
|
|
100
|
+
- MANIFEST
|
|
101
|
+
- README.md
|
|
102
|
+
- Rakefile
|
|
103
|
+
- doc/ping.txt
|
|
104
|
+
- docs/superpowers/plans/2026-07-25-platform-specific-gems.md
|
|
105
|
+
- docs/superpowers/specs/2026-07-25-platform-specific-gems-design.md
|
|
106
|
+
- examples/example_pingexternal.rb
|
|
107
|
+
- examples/example_pinghttp.rb
|
|
108
|
+
- examples/example_pingtcp.rb
|
|
109
|
+
- examples/example_pingudp.rb
|
|
110
|
+
- lib/net/ping.rb
|
|
111
|
+
- lib/net/ping/external.rb
|
|
112
|
+
- lib/net/ping/http.rb
|
|
113
|
+
- lib/net/ping/icmp.rb
|
|
114
|
+
- lib/net/ping/ping.rb
|
|
115
|
+
- lib/net/ping/tcp.rb
|
|
116
|
+
- lib/net/ping/udp.rb
|
|
117
|
+
- lib/net/ping/version.rb
|
|
118
|
+
- lib/net/ping/wmi.rb
|
|
119
|
+
- net-ping-universal-linux.gemspec
|
|
120
|
+
- net-ping-universal-mingw-ucrt.gemspec
|
|
121
|
+
- net-ping.gemspec
|
|
122
|
+
- test/test_net_ping.rb
|
|
123
|
+
- test/test_net_ping_external.rb
|
|
124
|
+
- test/test_net_ping_gem_packaging.rb
|
|
125
|
+
- test/test_net_ping_http.rb
|
|
126
|
+
- test/test_net_ping_icmp.rb
|
|
127
|
+
- test/test_net_ping_tcp.rb
|
|
128
|
+
- test/test_net_ping_udp.rb
|
|
129
|
+
- test/test_net_ping_wmi.rb
|
|
130
|
+
homepage: https://github.com/chernesk/net-ping
|
|
131
|
+
licenses:
|
|
132
|
+
- Artistic 2.0
|
|
133
|
+
metadata:
|
|
134
|
+
bug_tracker_uri: https://github.com/chernesk/net-ping/issues
|
|
135
|
+
changelog_uri: https://github.com/chernesk/net-ping/blob/master/CHANGES
|
|
136
|
+
documentation_uri: https://www.rubydoc.info/gems/net-ping
|
|
137
|
+
homepage_uri: https://github.com/chernesk/net-ping
|
|
138
|
+
source_code_uri: https://github.com/chernesk/net-ping
|
|
139
|
+
post_install_message:
|
|
140
|
+
rdoc_options: []
|
|
141
|
+
require_paths:
|
|
142
|
+
- lib
|
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
|
+
requirements:
|
|
145
|
+
- - ">="
|
|
146
|
+
- !ruby/object:Gem::Version
|
|
147
|
+
version: 1.9.3
|
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
requirements: []
|
|
154
|
+
rubygems_version: 3.5.22
|
|
155
|
+
signing_key:
|
|
156
|
+
specification_version: 4
|
|
157
|
+
summary: A ping interface for Ruby.
|
|
158
|
+
test_files:
|
|
159
|
+
- test/test_net_ping.rb
|