net-ping 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/doc/ping.txt +1 -1
- data/lib/net/ping.rb +19 -19
- data/test/tc_pingexternal.rb +1 -1
- data/test/tc_pinghttp.rb +1 -1
- data/test/tc_pingtcp.rb +3 -2
- data/test/tc_pingudp.rb +1 -1
- metadata +27 -23
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.1.1 - 15-Jun-2006
|
2
|
+
* Fixed a bug in PingTCP (bad variable name). Thanks go to Anoop Chandran
|
3
|
+
for the spot.
|
4
|
+
* Minor variable name refactoring.
|
5
|
+
* Minor test updates.
|
6
|
+
|
1
7
|
== 1.1.0 - 17-Jul-2005
|
2
8
|
* Fixed a bug in the PingHTTP#ping method where I was accidentally passing
|
3
9
|
the timeout value instead of the port number as the third argument to
|
data/doc/ping.txt
CHANGED
data/lib/net/ping.rb
CHANGED
@@ -4,7 +4,7 @@ require "timeout"
|
|
4
4
|
module Net
|
5
5
|
# An abstract base class. Do not instantiate directly.
|
6
6
|
class Ping
|
7
|
-
VERSION = "1.1.
|
7
|
+
VERSION = "1.1.1"
|
8
8
|
attr_accessor :host, :port, :timeout
|
9
9
|
attr_reader :exception, :warning
|
10
10
|
|
@@ -60,27 +60,27 @@ module Net
|
|
60
60
|
def ping
|
61
61
|
super
|
62
62
|
success = false
|
63
|
-
|
63
|
+
tcp = nil
|
64
64
|
begin
|
65
65
|
Timeout.timeout(@timeout){
|
66
66
|
begin
|
67
|
-
|
68
|
-
rescue Errno::ECONNREFUSED =>
|
67
|
+
tcp = TCPSocket.new(@host,@port)
|
68
|
+
rescue Errno::ECONNREFUSED => err
|
69
69
|
if @@econnrefused == true
|
70
70
|
success = true
|
71
71
|
else
|
72
|
-
@exception =
|
72
|
+
@exception = err
|
73
73
|
end
|
74
|
-
rescue Exception =>
|
75
|
-
@exception =
|
74
|
+
rescue Exception => err
|
75
|
+
@exception = err
|
76
76
|
else
|
77
77
|
success = true
|
78
78
|
end
|
79
79
|
}
|
80
|
-
rescue
|
81
|
-
@exception =
|
80
|
+
rescue Timeout::Error => err
|
81
|
+
@exception = err
|
82
82
|
ensure
|
83
|
-
|
83
|
+
tcp.close if tcp
|
84
84
|
end
|
85
85
|
success
|
86
86
|
end
|
@@ -100,22 +100,22 @@ module Net
|
|
100
100
|
def ping
|
101
101
|
super
|
102
102
|
success = false
|
103
|
-
|
103
|
+
udp = UDPSocket.open
|
104
104
|
a = []
|
105
105
|
begin
|
106
106
|
Timeout.timeout(@timeout){
|
107
|
-
|
108
|
-
|
109
|
-
a =
|
107
|
+
udp.connect(@host, @port)
|
108
|
+
udp.send(@data, 0)
|
109
|
+
a = udp.recvfrom(64)
|
110
110
|
}
|
111
|
-
rescue Exception =>
|
112
|
-
@exception =
|
111
|
+
rescue Exception => err
|
112
|
+
@exception = err
|
113
113
|
else
|
114
114
|
if a[0] == @data
|
115
115
|
success = true
|
116
116
|
end
|
117
117
|
ensure
|
118
|
-
|
118
|
+
udp.close if udp
|
119
119
|
end
|
120
120
|
success
|
121
121
|
end
|
@@ -215,8 +215,8 @@ module Net
|
|
215
215
|
|
216
216
|
begin
|
217
217
|
resp = HTTP.get_response(uri.host, uri.path, @port)
|
218
|
-
rescue Exception =>
|
219
|
-
@exception =
|
218
|
+
rescue Exception => err
|
219
|
+
@exception = err
|
220
220
|
else
|
221
221
|
case resp
|
222
222
|
when Net::HTTPSuccess, Net::HTTPOK
|
data/test/tc_pingexternal.rb
CHANGED
data/test/tc_pinghttp.rb
CHANGED
data/test/tc_pingtcp.rb
CHANGED
@@ -21,7 +21,7 @@ class TC_PingTCP < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_version
|
24
|
-
assert_equal("1.
|
24
|
+
assert_equal("1.1.1", PingTCP::VERSION, "Bad version constant")
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_ping
|
@@ -32,8 +32,9 @@ class TC_PingTCP < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_ping_ecr_false
|
35
|
+
msg = "+this test may fail depending on your network environment+"
|
35
36
|
PingTCP.ecr = false
|
36
|
-
assert_equal(false, @tcp.ping
|
37
|
+
assert_equal(false, @tcp.ping?, msg)
|
37
38
|
assert_equal(false, @tcp.exception.nil?, "Bad exception data")
|
38
39
|
end
|
39
40
|
|
data/test/tc_pingudp.rb
CHANGED
metadata
CHANGED
@@ -3,11 +3,11 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: net-ping
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date:
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2006-06-15 00:00:00 -06:00
|
8
8
|
summary: A ping interface for Ruby
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: djberg96@gmail.com
|
12
12
|
homepage: http://www.rubyforge.org/projects/shards
|
13
13
|
rubyforge_project:
|
@@ -18,35 +18,39 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
29
28
|
authors:
|
30
|
-
|
29
|
+
- Daniel J. Berger
|
31
30
|
files:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
- lib/net/ping.rb
|
32
|
+
- README
|
33
|
+
- CHANGES
|
34
|
+
- MANIFEST
|
35
|
+
- test/tc_pingtcp.rb
|
36
|
+
- test/tc_pingudp.rb
|
37
|
+
- test/tc_pingexternal.rb
|
38
|
+
- test/ts_ping.rb
|
39
|
+
- test/tc_pinghttp.rb
|
40
|
+
- doc/ping.txt
|
42
41
|
test_files:
|
43
|
-
|
42
|
+
- test/ts_ping.rb
|
44
43
|
rdoc_options: []
|
44
|
+
|
45
45
|
extra_rdoc_files:
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
- README
|
47
|
+
- CHANGES
|
48
|
+
- doc/ping.txt
|
49
49
|
executables: []
|
50
|
+
|
50
51
|
extensions: []
|
52
|
+
|
51
53
|
requirements: []
|
52
|
-
|
54
|
+
|
55
|
+
dependencies: []
|
56
|
+
|