net-ping 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/MANIFEST +5 -5
- data/README +5 -2
- data/Rakefile +62 -32
- 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.rb +10 -6
- data/lib/net/ping/external.rb +18 -10
- data/lib/net/ping/http.rb +14 -5
- data/lib/net/ping/icmp.rb +7 -5
- data/lib/net/ping/ping.rb +2 -1
- data/lib/net/ping/tcp.rb +4 -4
- data/lib/net/ping/udp.rb +10 -7
- data/lib/net/ping/wmi.rb +2 -3
- data/net-ping.gemspec +18 -21
- data/test/test_net_ping.rb +10 -10
- data/test/test_net_ping_external.rb +2 -2
- data/test/test_net_ping_http.rb +2 -2
- data/test/test_net_ping_icmp.rb +3 -3
- data/test/test_net_ping_tcp.rb +2 -2
- data/test/test_net_ping_udp.rb +2 -2
- data/test/test_net_ping_wmi.rb +3 -3
- metadata +8 -8
- data/examples/test_pingexternal.rb +0 -18
- data/examples/test_pinghttp.rb +0 -19
- data/examples/test_pingtcp.rb +0 -22
- data/examples/test_pingudp.rb +0 -15
data/CHANGES
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
== 1.3.2 - 21-Sep-2009
|
2
|
+
* Doing a 'require "net/ping"' was not automatically loading the
|
3
|
+
Net::Ping::WMI class on MS Windows. This has been fixed. Thanks go to
|
4
|
+
Joseph M. for the spot.
|
5
|
+
* Removed all $LOAD_PATH mangling for both the library and tests.
|
6
|
+
* Fixed a bug in the Net::Ping::HTTP class where a failed redirect did
|
7
|
+
not set the @exception and @warning instance variables properly.
|
8
|
+
* The PingStatus struct returned by Net::Ping::WMI is now frozen.
|
9
|
+
* The test-unit library was switched from a runtime dependency to a
|
10
|
+
development dependency.
|
11
|
+
* Added the :gem Rake task that builds a gem.
|
12
|
+
* Updated the :gem_install task to use the :gem task as a prerequisite.
|
13
|
+
* Updated the dependencies for MS Windows.
|
14
|
+
* The Rake test tasks are now more Rakish, e.g. test:tcp instead of test_tcp.
|
15
|
+
* Renamed example file names to avoid any potential confusion with actual
|
16
|
+
test files.
|
17
|
+
|
1
18
|
== 1.3.1 - 22-Jul-2009
|
2
19
|
* Removed class aliases, e.g. use Ping::External, not PingExternal.
|
3
20
|
* Minor code change to eliminate a warning that popped up in 1.9.x.
|
data/MANIFEST
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
* Rakefile
|
4
4
|
* README
|
5
5
|
* net-ping.gemspec
|
6
|
-
* examples/
|
7
|
-
* examples/
|
8
|
-
* examples/
|
9
|
-
* examples/
|
6
|
+
* examples/example_pingexternal.rb
|
7
|
+
* examples/example_pinghttp.rb
|
8
|
+
* examples/example_pingtcp.rb
|
9
|
+
* examples/example_pingudp.rb
|
10
10
|
* lib/net/ping.rb
|
11
11
|
* lib/net/ping/icmp.rb
|
12
12
|
* lib/net/ping/tcp.rb
|
@@ -20,4 +20,4 @@
|
|
20
20
|
* test/test_net_ping_tcp.rb
|
21
21
|
* test/test_net_ping_udp.rb
|
22
22
|
* test/test_net_ping_wmi.rb
|
23
|
-
* test/test_net_ping.rb
|
23
|
+
* test/test_net_ping.rb
|
data/README
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
== Prerequisites
|
5
5
|
* Ruby 1.8.0 or later
|
6
|
-
* The win32-open3 and windows-pr libraries are required on
|
7
|
-
when using the Net::Ping::External class.
|
6
|
+
* The win32-open3 (1.8.x) and windows-pr libraries are required on
|
7
|
+
MS Windows when using the Net::Ping::External class.
|
8
8
|
* Windows 2000 or later is required to use the Ping::WMI class.
|
9
9
|
|
10
10
|
== Installation
|
@@ -20,6 +20,9 @@
|
|
20
20
|
attention to the documentation pertaining to ECONNREFUSED and TCP pings.
|
21
21
|
|
22
22
|
Also note the documentation regarding down hosts.
|
23
|
+
|
24
|
+
You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
|
25
|
+
as part of the Ruby standard library should work.
|
23
26
|
|
24
27
|
== How to require net-ping
|
25
28
|
You can do either this:
|
data/Rakefile
CHANGED
@@ -17,51 +17,81 @@ task :install do
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
desc
|
21
|
-
task :gem_install do
|
22
|
-
ruby 'net-ping.gemspec'
|
20
|
+
desc 'Create and install the net-ping gem'
|
21
|
+
task :gem_install => [:gem] do
|
23
22
|
gem_file = Dir["*.gem"].first
|
24
23
|
sh "gem install #{gem_file}"
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
desc 'Create the net-ping gem'
|
27
|
+
task :gem do
|
28
|
+
spec = eval(IO.read('net-ping.gemspec'))
|
29
|
+
Gem::Builder.new(spec).build
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
namespace 'example' do
|
33
|
+
desc 'Run the external ping example program'
|
34
|
+
task :external do
|
35
|
+
ruby '-Ilib examples/example_pingexternal.rb'
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
38
|
+
desc 'Run the http ping example program'
|
39
|
+
task :http do
|
40
|
+
ruby '-Ilib examples/example_pinghttp.rb'
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
43
|
+
desc 'Run the tcp ping example program'
|
44
|
+
task :tcp do
|
45
|
+
ruby '-Ilib examples/example_pingtcp.rb'
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
desc 'Run the udp ping example program'
|
49
|
+
task :udp do
|
50
|
+
ruby '-Ilib examples/example_pingudp.rb'
|
51
|
+
end
|
55
52
|
end
|
56
53
|
|
57
|
-
Rake::TestTask.new
|
54
|
+
Rake::TestTask.new do |t|
|
55
|
+
t.libs << 'test'
|
58
56
|
t.warning = true
|
59
57
|
t.verbose = true
|
60
|
-
t.test_files = FileList['test/
|
58
|
+
t.test_files = FileList['test/test_net_ping.rb']
|
61
59
|
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
namespace 'test' do
|
62
|
+
Rake::TestTask.new('external') do |t|
|
63
|
+
t.warning = true
|
64
|
+
t.verbose = true
|
65
|
+
t.test_files = FileList['test/test_net_ping_external.rb']
|
66
|
+
end
|
67
|
+
|
68
|
+
Rake::TestTask.new('http') do |t|
|
69
|
+
t.warning = true
|
70
|
+
t.verbose = true
|
71
|
+
t.test_files = FileList['test/test_net_ping_http.rb']
|
72
|
+
end
|
73
|
+
|
74
|
+
Rake::TestTask.new('icmp') do |t|
|
75
|
+
t.warning = true
|
76
|
+
t.verbose = true
|
77
|
+
t.test_files = FileList['test/test_net_ping_icmp.rb']
|
78
|
+
end
|
79
|
+
|
80
|
+
Rake::TestTask.new('tcp') do |t|
|
81
|
+
t.warning = true
|
82
|
+
t.verbose = true
|
83
|
+
t.test_files = FileList['test/test_net_ping_tcp.rb']
|
84
|
+
end
|
85
|
+
|
86
|
+
Rake::TestTask.new('udp') do |t|
|
87
|
+
t.warning = true
|
88
|
+
t.verbose = true
|
89
|
+
t.test_files = FileList['test/test_net_ping_udp.rb']
|
90
|
+
end
|
91
|
+
|
92
|
+
Rake::TestTask.new('wmi') do |t|
|
93
|
+
t.warning = true
|
94
|
+
t.verbose = true
|
95
|
+
t.test_files = FileList['test/test_net_ping_wmi.rb']
|
96
|
+
end
|
67
97
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
########################################################################
|
2
|
+
# example_pingexternal.rb
|
3
|
+
#
|
4
|
+
# A short sample program demonstrating an external ping. You can run
|
5
|
+
# this program via the example:external task. Modify as you see fit.
|
6
|
+
########################################################################
|
7
|
+
require 'net/ping'
|
8
|
+
|
9
|
+
good = 'www.rubyforge.org'
|
10
|
+
bad = 'foo.bar.baz'
|
11
|
+
|
12
|
+
p1 = Net::Ping::External.new(good)
|
13
|
+
p p1.ping?
|
14
|
+
|
15
|
+
p2 = Net::Ping::External.new(bad)
|
16
|
+
p p2.ping?
|
@@ -0,0 +1,22 @@
|
|
1
|
+
########################################################################
|
2
|
+
# example_pinghttp.rb
|
3
|
+
#
|
4
|
+
# A short sample program demonstrating an http ping. You can run
|
5
|
+
# this program via the example:http task. Modify as you see fit.
|
6
|
+
########################################################################
|
7
|
+
require 'net/ping'
|
8
|
+
|
9
|
+
good = 'http://www.google.com/index.html'
|
10
|
+
bad = 'http://www.ruby-lang.org/index.html'
|
11
|
+
|
12
|
+
puts "== Good ping, no redirect"
|
13
|
+
|
14
|
+
p1 = Net::Ping::HTTP.new(good)
|
15
|
+
p p1.ping?
|
16
|
+
|
17
|
+
puts "== Bad ping"
|
18
|
+
|
19
|
+
p2 = Net::Ping::HTTP.new(bad)
|
20
|
+
p p2.ping?
|
21
|
+
p p2.warning
|
22
|
+
p p2.exception
|
@@ -0,0 +1,16 @@
|
|
1
|
+
########################################################################
|
2
|
+
# example_pingtcp.rb
|
3
|
+
#
|
4
|
+
# A short sample program demonstrating a tcp ping. You can run
|
5
|
+
# this program via the example:tcp task. Modify as you see fit.
|
6
|
+
########################################################################
|
7
|
+
require 'net/ping'
|
8
|
+
|
9
|
+
good = 'www.google.com'
|
10
|
+
bad = 'foo.bar.baz'
|
11
|
+
|
12
|
+
p1 = Net::Ping::TCP.new(good, 'http')
|
13
|
+
p p1.ping?
|
14
|
+
|
15
|
+
p2 = Net::Ping::TCP.new(bad)
|
16
|
+
p p2.ping?
|
@@ -0,0 +1,12 @@
|
|
1
|
+
########################################################################
|
2
|
+
# example_pingudp.rb
|
3
|
+
#
|
4
|
+
# A short sample program demonstrating a UDP ping. You can run
|
5
|
+
# this program via the example:udp task. Modify as you see fit.
|
6
|
+
########################################################################
|
7
|
+
require 'net/ping'
|
8
|
+
|
9
|
+
host = 'www.google.com'
|
10
|
+
|
11
|
+
u = Net::Ping::UDP.new(host)
|
12
|
+
p u.ping?
|
data/lib/net/ping.rb
CHANGED
@@ -2,10 +2,14 @@
|
|
2
2
|
# want to require a specific ping type only, do "require 'net/ping/tcp'",
|
3
3
|
# for example.
|
4
4
|
#
|
5
|
-
|
5
|
+
require 'rbconfig'
|
6
6
|
|
7
|
-
require 'ping/tcp'
|
8
|
-
require 'ping/udp'
|
9
|
-
require 'ping/icmp'
|
10
|
-
require 'ping/external'
|
11
|
-
require 'ping/http'
|
7
|
+
require File.join(File.dirname(__FILE__), 'ping/tcp')
|
8
|
+
require File.join(File.dirname(__FILE__), 'ping/udp')
|
9
|
+
require File.join(File.dirname(__FILE__), 'ping/icmp')
|
10
|
+
require File.join(File.dirname(__FILE__), 'ping/external')
|
11
|
+
require File.join(File.dirname(__FILE__), 'ping/http')
|
12
|
+
|
13
|
+
if Config::CONFIG['host_os'] =~ /dos|mswin|cygwin|mingw|win32/i
|
14
|
+
require File.join(File.dirname(__FILE__), 'ping/wmi')
|
15
|
+
end
|
data/lib/net/ping/external.rb
CHANGED
@@ -1,25 +1,31 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require 'rbconfig'
|
2
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
3
|
|
4
|
-
if
|
4
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
5
5
|
if RUBY_VERSION.to_f < 1.9
|
6
6
|
require 'win32/open3'
|
7
7
|
end
|
8
8
|
require 'windows/console'
|
9
|
-
include Windows::Console
|
10
9
|
else
|
11
10
|
require 'open3'
|
12
11
|
end
|
13
12
|
|
13
|
+
# The Net module serves as a namespace only.
|
14
14
|
module Net
|
15
|
+
|
16
|
+
# The Ping::External class encapsulates methods for external (system) pings.
|
15
17
|
class Ping::External < Ping
|
18
|
+
|
19
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
20
|
+
include Windows::Console
|
21
|
+
end
|
16
22
|
|
17
23
|
# Pings the host using your system's ping utility and checks for any
|
18
|
-
# errors or warnings.
|
24
|
+
# errors or warnings. Returns true if successful, or false if not.
|
19
25
|
#
|
20
|
-
# If
|
21
|
-
# string indicating what went wrong.
|
22
|
-
# method may or may not contain a value.
|
26
|
+
# If the ping failed then the Ping::External#exception method should
|
27
|
+
# contain a string indicating what went wrong. If the ping succeeded then
|
28
|
+
# the Ping::External#warning method may or may not contain a value.
|
23
29
|
#
|
24
30
|
def ping(host = @host)
|
25
31
|
super(host)
|
@@ -29,7 +35,7 @@ module Net
|
|
29
35
|
bool = false
|
30
36
|
orig_cp = nil
|
31
37
|
|
32
|
-
case
|
38
|
+
case Config::CONFIG['host_os']
|
33
39
|
when /linux|bsd|osx|mach|darwin/i
|
34
40
|
pstring += "-c 1 #{host}"
|
35
41
|
when /solaris|sunos/i
|
@@ -57,7 +63,9 @@ module Net
|
|
57
63
|
input.close
|
58
64
|
error.close
|
59
65
|
|
60
|
-
if
|
66
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|dos/i &&
|
67
|
+
GetConsoleCP() != orig_cp
|
68
|
+
then
|
61
69
|
SetConsoleCP(orig_cp)
|
62
70
|
end
|
63
71
|
|
data/lib/net/ping/http.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
2
|
require 'net/http'
|
4
3
|
require 'uri'
|
5
4
|
require 'rbconfig'
|
6
5
|
|
7
6
|
# Force non-blocking Socket.getaddrinfo on Unix systems. Do not use on
|
8
|
-
# Windows because it causes problems.
|
9
|
-
unless Config::CONFIG['host_os']
|
7
|
+
# Windows because it (ironically) causes blocking problems.
|
8
|
+
unless Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
10
9
|
require 'resolv-replace'
|
11
10
|
end
|
12
11
|
|
12
|
+
# The Net module serves as a namespace only.
|
13
13
|
module Net
|
14
|
+
|
15
|
+
# The Ping::HTTP class encapsulates methods for HTTP pings.
|
14
16
|
class Ping::HTTP < Ping
|
15
17
|
|
16
18
|
# By default an http ping will follow a redirect and give you the result
|
@@ -59,12 +61,19 @@ module Net
|
|
59
61
|
else
|
60
62
|
if @follow_redirect
|
61
63
|
@warning = response.message
|
64
|
+
|
62
65
|
while response.is_a?(Net::HTTPRedirection)
|
63
66
|
redirect = URI.parse(response['location'])
|
64
67
|
redirect = uri + redirect if redirect.relative?
|
65
68
|
response = Net::HTTP.get_response(redirect.host, redirect.path, @port)
|
66
69
|
end
|
67
|
-
|
70
|
+
|
71
|
+
if response.is_a?(Net::HTTPSuccess)
|
72
|
+
bool = true
|
73
|
+
else
|
74
|
+
@warning = nil
|
75
|
+
@exception = response.message
|
76
|
+
end
|
68
77
|
else
|
69
78
|
@exception = response.message
|
70
79
|
end
|
data/lib/net/ping/icmp.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
2
|
|
3
|
+
# The Net module serves as a namespace only.
|
4
4
|
module Net
|
5
|
+
|
6
|
+
# The Net::Ping::ICMP class encapsulates an icmp ping.
|
5
7
|
class Ping::ICMP < Ping
|
6
|
-
ICMP_ECHOREPLY = 0
|
7
|
-
ICMP_ECHO = 8
|
8
|
+
ICMP_ECHOREPLY = 0 # Echo reply
|
9
|
+
ICMP_ECHO = 8 # Echo request
|
8
10
|
ICMP_SUBCODE = 0
|
9
11
|
|
10
|
-
# You cannot set or change the port value.
|
12
|
+
# You cannot set or change the port value. A value of 0 is always
|
11
13
|
# used internally for ICMP pings.
|
12
14
|
#
|
13
15
|
undef_method :port=
|
data/lib/net/ping/ping.rb
CHANGED
@@ -9,7 +9,8 @@ module Net
|
|
9
9
|
# types. You should not instantiate this class directly.
|
10
10
|
#
|
11
11
|
class Ping
|
12
|
-
|
12
|
+
# The version of the net-ping library.
|
13
|
+
VERSION = '1.3.2'
|
13
14
|
|
14
15
|
# The host to ping. In the case of Ping::HTTP, this is the URI.
|
15
16
|
attr_accessor :host
|
data/lib/net/ping/tcp.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
2
|
|
3
|
+
# The Net module serves as a namespace only.
|
4
4
|
module Net
|
5
5
|
|
6
|
-
# With a TCP ping
|
7
|
-
# assume
|
6
|
+
# With a TCP ping simply try to open a connection. If we are successful,
|
7
|
+
# assume success. In either case close the connection to be polite.
|
8
8
|
#
|
9
9
|
class Ping::TCP < Ping
|
10
10
|
@@service_check = false
|
data/lib/net/ping/udp.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
2
|
|
3
|
+
# The Net module serves as a namespace only.
|
4
4
|
module Net
|
5
|
+
|
6
|
+
# The Ping::UDP class encapsulates methods for UDP pings.
|
5
7
|
class Ping::UDP < Ping
|
6
8
|
@@service_check = true
|
7
9
|
|
@@ -26,9 +28,10 @@ module Net
|
|
26
28
|
@@service_check = bool
|
27
29
|
end
|
28
30
|
|
31
|
+
# The maximum data size that can be sent in a UDP ping.
|
29
32
|
MAX_DATA = 64
|
30
33
|
|
31
|
-
# The data to send to the remote host.
|
34
|
+
# The data to send to the remote host. By default this is 'ping'.
|
32
35
|
# This should be MAX_DATA size characters or less.
|
33
36
|
#
|
34
37
|
attr_reader :data
|
@@ -45,7 +48,7 @@ module Net
|
|
45
48
|
@bind_port = nil
|
46
49
|
end
|
47
50
|
|
48
|
-
# Sets the data string sent to the remote host.
|
51
|
+
# Sets the data string sent to the remote host. This value cannot have
|
49
52
|
# a size greater than MAX_DATA.
|
50
53
|
#
|
51
54
|
def data=(string)
|
@@ -58,16 +61,16 @@ module Net
|
|
58
61
|
end
|
59
62
|
|
60
63
|
# Associates the local end of the UDP connection with the given +host+
|
61
|
-
# and +port+.
|
64
|
+
# and +port+. This is essentially a wrapper for UDPSocket#bind.
|
62
65
|
#
|
63
66
|
def bind(host, port)
|
64
67
|
@bind_host = host
|
65
68
|
@bind_port = port
|
66
69
|
end
|
67
70
|
|
68
|
-
# Sends a simple text string to the host and checks the return string.
|
71
|
+
# Sends a simple text string to the host and checks the return string. If
|
69
72
|
# the string sent and the string returned are a match then the ping was
|
70
|
-
# successful and true is returned.
|
73
|
+
# successful and true is returned. Otherwise, false is returned.
|
71
74
|
#
|
72
75
|
def ping(host = @host)
|
73
76
|
super(host)
|
data/lib/net/ping/wmi.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'ping'
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
3
2
|
require 'win32ole'
|
4
3
|
|
5
4
|
# The Net module serves as a namespace only.
|
@@ -106,7 +105,7 @@ module Net
|
|
106
105
|
status.type_of_service = obj.TypeOfService
|
107
106
|
}
|
108
107
|
|
109
|
-
status
|
108
|
+
status.freeze # Read-only data
|
110
109
|
end
|
111
110
|
|
112
111
|
# Unlike Net::Ping::WMI#ping, this method returns true or false to
|
data/net-ping.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'net-ping'
|
6
|
+
gem.version = '1.3.2'
|
7
|
+
gem.license = 'Artistic 2.0'
|
8
|
+
gem.author = 'Daniel J. Berger'
|
9
|
+
gem.email = 'djberg96@gmail.com'
|
10
|
+
gem.homepage = 'http://www.rubyforge.org/projects/shards'
|
11
|
+
gem.summary = 'A ping interface for Ruby.'
|
12
|
+
gem.test_file = 'test/test_net_ping.rb'
|
13
|
+
gem.has_rdoc = true
|
14
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
2
15
|
|
3
|
-
spec = Gem::Specification.new do |gem|
|
4
|
-
gem.name = 'net-ping'
|
5
|
-
gem.version = '1.3.1'
|
6
|
-
gem.license = 'Artistic 2.0'
|
7
|
-
gem.author = 'Daniel J. Berger'
|
8
|
-
gem.email = 'djberg96@gmail.com'
|
9
|
-
gem.homepage = 'http://www.rubyforge.org/projects/shards'
|
10
|
-
gem.summary = 'A ping interface for Ruby.'
|
11
|
-
gem.test_file = 'test/test_net_ping.rb'
|
12
|
-
gem.has_rdoc = true
|
13
16
|
gem.rubyforge_project = 'shards'
|
14
|
-
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
15
17
|
gem.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
|
16
18
|
|
17
|
-
gem.
|
19
|
+
gem.add_development_dependency('test-unit', '>= 2.0.3')
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
# These dependencies are for Net::Ping::External
|
22
|
+
if Config::CONFIG['host_os'] =~ /mswin|dos|win32|cygwin|mingw/i
|
21
23
|
gem.platform = Gem::Platform::CURRENT
|
22
|
-
gem.add_dependency('windows-pr', '>= 1.0.
|
24
|
+
gem.add_dependency('windows-pr', '>= 1.0.8')
|
23
25
|
|
24
26
|
if RUBY_VERSION.to_f < 1.9
|
25
|
-
gem.add_dependency('win32-open3', '>= 0.3.
|
27
|
+
gem.add_dependency('win32-open3', '>= 0.3.1')
|
26
28
|
end
|
27
|
-
else
|
28
|
-
gem.platform = Gem::Platform::RUBY
|
29
29
|
end
|
30
30
|
|
31
31
|
gem.description = <<-EOF
|
@@ -34,6 +34,3 @@ spec = Gem::Specification.new do |gem|
|
|
34
34
|
classes.
|
35
35
|
EOF
|
36
36
|
end
|
37
|
-
|
38
|
-
Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
|
39
|
-
Gem::Builder.new(spec).build
|
data/test/test_net_ping.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
######################################################################
|
2
2
|
# test_net_ping.rb
|
3
3
|
#
|
4
|
-
# Test suite for all the Ping subclasses.
|
4
|
+
# Test suite for all the Ping subclasses. Note that the Ping::ICMP
|
5
5
|
# class test won't be run unless this is run as a privileged process.
|
6
6
|
######################################################################
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require "test_net_ping_external"
|
12
|
-
require "test_net_ping_http"
|
13
|
-
require "test_net_ping_tcp"
|
14
|
-
require "test_net_ping_udp"
|
7
|
+
require 'test_net_ping_external'
|
8
|
+
require 'test_net_ping_http'
|
9
|
+
require 'test_net_ping_tcp'
|
10
|
+
require 'test_net_ping_udp'
|
15
11
|
|
16
12
|
if Process.euid == 0
|
17
|
-
require
|
13
|
+
require 'test_net_ping_icmp'
|
14
|
+
end
|
15
|
+
|
16
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
17
|
+
require 'test_net_ping_wmi'
|
18
18
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# test_net_ping_external.rb
|
3
3
|
#
|
4
4
|
# Test case for the Net::PingExternal class. Run this via the 'test' or
|
5
|
-
# '
|
5
|
+
# 'test:external' rake task.
|
6
6
|
#########################################################################
|
7
7
|
require 'rubygems'
|
8
8
|
gem 'test-unit'
|
@@ -20,7 +20,7 @@ class TC_PingExternal < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_version
|
23
|
-
assert_equal('1.3.
|
23
|
+
assert_equal('1.3.2', Ping::External::VERSION)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_ping
|
data/test/test_net_ping_http.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# test_net_ping_http.rb
|
3
3
|
#
|
4
4
|
# Test case for the Net::PingHTTP class. This should be run via the 'test' or
|
5
|
-
# '
|
5
|
+
# 'test:http' Rake task.
|
6
6
|
#################################################################################
|
7
7
|
require 'rubygems'
|
8
8
|
gem 'test-unit'
|
@@ -19,7 +19,7 @@ class TC_PingHTTP < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_version
|
22
|
-
assert_equal('1.3.
|
22
|
+
assert_equal('1.3.2', Ping::HTTP::VERSION)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_ping
|
data/test/test_net_ping_icmp.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the Net::PingICMP class. You must run this test case
|
5
5
|
# with root privileges on UNIX systems. This should be run via the
|
6
|
-
# 'test' or '
|
6
|
+
# 'test' or 'test:icmp' Rake task.
|
7
7
|
#######################################################################
|
8
8
|
require 'rubygems'
|
9
9
|
gem 'test-unit'
|
@@ -13,7 +13,7 @@ require 'net/ping/icmp'
|
|
13
13
|
include Net
|
14
14
|
|
15
15
|
unless Process.euid == 0
|
16
|
-
raise "The
|
16
|
+
raise "The test:icmp task must be run with root privileges"
|
17
17
|
end
|
18
18
|
|
19
19
|
class TC_PingICMP < Test::Unit::TestCase
|
@@ -27,7 +27,7 @@ class TC_PingICMP < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_version
|
30
|
-
assert_equal('1.3.
|
30
|
+
assert_equal('1.3.2', Ping::ICMP::VERSION)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_ping
|
data/test/test_net_ping_tcp.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# test_net_ping_tcp.rb
|
3
3
|
#
|
4
4
|
# Test case for the Net::PingTCP class. This test should be run via
|
5
|
-
# the 'test' or '
|
5
|
+
# the 'test' or 'test:tcp' Rake task.
|
6
6
|
#####################################################################
|
7
7
|
require 'rubygems'
|
8
8
|
gem 'test-unit'
|
@@ -19,7 +19,7 @@ class TC_PingTCP < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_version
|
22
|
-
assert_equal('1.3.
|
22
|
+
assert_equal('1.3.2', Ping::TCP::VERSION)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_ping
|
data/test/test_net_ping_udp.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# test_net_ping_udp.rb
|
3
3
|
#
|
4
4
|
# Test case for the Net::Ping::UDP class. This should be run
|
5
|
-
# via the 'test' or '
|
5
|
+
# via the 'test' or 'test:udp' Rake task.
|
6
6
|
#
|
7
7
|
# If someone could provide me a host where a udp ping actually
|
8
8
|
# works (with a service check), I would appreciate it. :)
|
@@ -22,7 +22,7 @@ class TC_PingUDP < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_version
|
25
|
-
assert_equal('1.3.
|
25
|
+
assert_equal('1.3.2', Ping::UDP::VERSION)
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_ping
|
data/test/test_net_ping_wmi.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the Net::Ping::WMI class. These tests will only be
|
5
5
|
# run MS Windows. You should run this test via the 'test' or
|
6
|
-
# '
|
6
|
+
# 'test:wmi' Rake task.
|
7
7
|
#######################################################################
|
8
8
|
require 'rubygems'
|
9
9
|
gem 'test-unit'
|
@@ -14,7 +14,7 @@ include Net
|
|
14
14
|
|
15
15
|
class TC_Ping_WMI < Test::Unit::TestCase
|
16
16
|
def self.startup
|
17
|
-
@@windows = Config::CONFIG['host_os'] =~ /mswin|cygwin|mingw/i
|
17
|
+
@@windows = Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
18
18
|
end
|
19
19
|
|
20
20
|
def setup
|
@@ -23,7 +23,7 @@ class TC_Ping_WMI < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_version
|
26
|
-
assert_equal('1.3.
|
26
|
+
assert_equal('1.3.2', Ping::WMI::VERSION)
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_ping_basic
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,12 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-21 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: test-unit
|
17
|
-
type: :
|
17
|
+
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
@@ -35,10 +35,10 @@ extra_rdoc_files:
|
|
35
35
|
files:
|
36
36
|
- CHANGES
|
37
37
|
- doc/ping.txt
|
38
|
-
- examples/
|
39
|
-
- examples/
|
40
|
-
- examples/
|
41
|
-
- examples/
|
38
|
+
- examples/example_pingexternal.rb
|
39
|
+
- examples/example_pinghttp.rb
|
40
|
+
- examples/example_pingtcp.rb
|
41
|
+
- examples/example_pingudp.rb
|
42
42
|
- lib/net/ping/external.rb
|
43
43
|
- lib/net/ping/http.rb
|
44
44
|
- lib/net/ping/icmp.rb
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
requirements: []
|
83
83
|
|
84
84
|
rubyforge_project: shards
|
85
|
-
rubygems_version: 1.3.
|
85
|
+
rubygems_version: 1.3.5
|
86
86
|
signing_key:
|
87
87
|
specification_version: 3
|
88
88
|
summary: A ping interface for Ruby.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
base = File.basename(Dir.pwd)
|
2
|
-
|
3
|
-
if base == "examples" || base =~ /net-pingsimple.*/
|
4
|
-
Dir.chdir("..") if base == "examples"
|
5
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
6
|
-
end
|
7
|
-
|
8
|
-
require "net/ping"
|
9
|
-
include Net
|
10
|
-
|
11
|
-
good = "www.rubyforge.org"
|
12
|
-
bad = "foo.bar.baz"
|
13
|
-
|
14
|
-
pe = PingExternal.new(good)
|
15
|
-
p pe.ping?
|
16
|
-
|
17
|
-
pe = PingExternal.new(bad)
|
18
|
-
p pe.ping?
|
data/examples/test_pinghttp.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
base = File.basename(Dir.pwd)
|
2
|
-
|
3
|
-
if base == "examples" || base =~ /net-pingsimple.*/
|
4
|
-
Dir.chdir("..") if base == "examples"
|
5
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
6
|
-
end
|
7
|
-
|
8
|
-
require "net/ping"
|
9
|
-
include Net
|
10
|
-
|
11
|
-
good = "http://www.pragmaticprogrammer.com/index.html"
|
12
|
-
bad = "http://www.ruby-lang.org/index.html"
|
13
|
-
|
14
|
-
hp = PingHTTP.new(good)
|
15
|
-
p hp.ping?
|
16
|
-
|
17
|
-
hp = PingHTTP.new(bad)
|
18
|
-
p hp.ping?
|
19
|
-
p hp.exception
|
data/examples/test_pingtcp.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
base = File.basename(Dir.pwd)
|
2
|
-
|
3
|
-
if base == "examples" || base =~ /net-pingsimple.*/
|
4
|
-
Dir.chdir("..") if base == "examples"
|
5
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
6
|
-
end
|
7
|
-
|
8
|
-
host = "www.ruby-lang.org"
|
9
|
-
|
10
|
-
require "net/ping"
|
11
|
-
include Net
|
12
|
-
|
13
|
-
good = "www.rubyforge.org"
|
14
|
-
bad = "foo.bar.baz"
|
15
|
-
|
16
|
-
PingTCP.ecr = true
|
17
|
-
|
18
|
-
pe = PingTCP.new(good,"http")
|
19
|
-
p pe.ping?
|
20
|
-
|
21
|
-
pe = PingTCP.new(bad)
|
22
|
-
p pe.ping?
|
data/examples/test_pingudp.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
base = File.basename(Dir.pwd)
|
2
|
-
|
3
|
-
if base == "examples" || base =~ /net-pingsimple.*/
|
4
|
-
Dir.chdir("..") if base == "examples"
|
5
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
6
|
-
end
|
7
|
-
|
8
|
-
require "net/ping"
|
9
|
-
include Net
|
10
|
-
|
11
|
-
host = "www.ruby-lang.org"
|
12
|
-
u = PingUDP.new(host)
|
13
|
-
p u.ping?
|
14
|
-
|
15
|
-
puts "Done"
|