net-ping 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/Rakefile +2 -0
- data/lib/net/ping/external.rb +10 -10
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +1 -1
- data/test/test_net_ping.rb +1 -1
- data/test/test_net_ping_external.rb +56 -22
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.3.6 - 4-Sep-2010
|
2
|
+
* Fixed variable naming issue in Net::Ping::External. Thanks go to taw
|
3
|
+
for the spot.
|
4
|
+
* Added a default Rake task.
|
5
|
+
* Refactored the tests for Net::Ping::External to take advantage of the
|
6
|
+
features of test-unit 2.x.
|
7
|
+
|
1
8
|
== 1.3.5 - 3-Sep-2010
|
2
9
|
* Allow for custom user agent in Net::Ping::HTTP. Thanks go to Michael
|
3
10
|
Reinsch for the patch.
|
data/Rakefile
CHANGED
data/lib/net/ping/external.rb
CHANGED
@@ -35,7 +35,7 @@ module Net
|
|
35
35
|
def ping(host = @host)
|
36
36
|
super(host)
|
37
37
|
|
38
|
-
|
38
|
+
stdin, stdout, stderr = ""
|
39
39
|
pstring = "ping "
|
40
40
|
bool = false
|
41
41
|
orig_cp = nil
|
@@ -63,12 +63,12 @@ module Net
|
|
63
63
|
err = nil
|
64
64
|
|
65
65
|
Timeout.timeout(@timeout){
|
66
|
-
|
67
|
-
err =
|
66
|
+
stdin, stdout, stderr = Open3.popen3(pstring)
|
67
|
+
err = stderr.gets # Can't chomp yet, might be nil
|
68
68
|
}
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
stdin.close
|
71
|
+
stderr.close
|
72
72
|
|
73
73
|
if CWINDOWS && GetConsoleCP() != orig_cp
|
74
74
|
SetConsoleCP(orig_cp)
|
@@ -83,8 +83,8 @@ module Net
|
|
83
83
|
end
|
84
84
|
# The "no answer" response goes to stdout, not stderr, so check it
|
85
85
|
else
|
86
|
-
lines =
|
87
|
-
|
86
|
+
lines = stdout.readlines
|
87
|
+
stdout.close
|
88
88
|
if lines.nil? || lines.empty?
|
89
89
|
bool = true
|
90
90
|
else
|
@@ -109,9 +109,9 @@ module Net
|
|
109
109
|
rescue Exception => error
|
110
110
|
@exception = error.message
|
111
111
|
ensure
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
stdin.close if stdin && !stdin.closed?
|
113
|
+
stdout.close if stdout && !stdout.closed?
|
114
|
+
stderr.close if stderr && !stderr.closed?
|
115
115
|
end
|
116
116
|
|
117
117
|
# There is no duration if the ping failed
|
data/lib/net/ping/ping.rb
CHANGED
data/net-ping.gemspec
CHANGED
data/test/test_net_ping.rb
CHANGED
@@ -18,64 +18,98 @@ class TC_Net_Ping_External < Test::Unit::TestCase
|
|
18
18
|
@bad = Net::Ping::External.new(@bogus)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
test "ping basic functionality" do
|
22
22
|
assert_respond_to(@pe, :ping)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "ping with no arguments" do
|
23
26
|
assert_nothing_raised{ @pe.ping }
|
27
|
+
end
|
28
|
+
|
29
|
+
test "ping accepts a hostname" do
|
24
30
|
assert_nothing_raised{ @pe.ping(@host) }
|
25
31
|
end
|
26
32
|
|
27
|
-
|
33
|
+
test "ping returns a boolean" do
|
34
|
+
assert_boolean(@pe.ping)
|
35
|
+
assert_boolean(@bad.ping)
|
36
|
+
end
|
37
|
+
|
38
|
+
test "ping? alias" do
|
28
39
|
assert_respond_to(@pe, :ping?)
|
29
|
-
|
30
|
-
|
31
|
-
|
40
|
+
assert_alias_method(@pe, :ping?, :ping)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "pingecho alias" do
|
32
44
|
assert_nothing_raised{ @pe.pingecho }
|
33
|
-
|
45
|
+
assert_alias_method(@pe, :pingecho, :ping)
|
34
46
|
end
|
35
47
|
|
36
|
-
|
37
|
-
|
48
|
+
test "pinging a good host returns true" do
|
49
|
+
assert_true(@pe.ping?)
|
38
50
|
end
|
39
51
|
|
40
|
-
|
41
|
-
|
42
|
-
assert_equal(false, @bad.exception.nil?, "Bad exception data")
|
52
|
+
test "pinging a bogus host returns false" do
|
53
|
+
assert_false(@bad.ping?)
|
43
54
|
end
|
44
55
|
|
45
|
-
|
56
|
+
test "duration basic functionality" do
|
46
57
|
assert_nothing_raised{ @pe.ping }
|
47
58
|
assert_respond_to(@pe, :duration)
|
48
59
|
assert_kind_of(Float, @pe.duration)
|
49
60
|
end
|
50
61
|
|
51
|
-
|
62
|
+
test "host getter basic functionality" do
|
52
63
|
assert_respond_to(@pe, :host)
|
53
|
-
assert_respond_to(@pe, :host=)
|
54
64
|
assert_equal('www.ruby-lang.org', @pe.host)
|
55
65
|
end
|
56
66
|
|
57
|
-
|
67
|
+
test "host setter basic functionality" do
|
68
|
+
assert_respond_to(@pe, :host=)
|
69
|
+
assert_nothing_raised{ @pe.host = @bad }
|
70
|
+
assert_equal(@bad, @pe.host)
|
71
|
+
end
|
72
|
+
|
73
|
+
test "port getter basic functionality" do
|
58
74
|
assert_respond_to(@pe, :port)
|
59
|
-
assert_respond_to(@pe, :port=)
|
60
75
|
assert_equal(7, @pe.port)
|
61
76
|
end
|
62
77
|
|
63
|
-
|
78
|
+
test "port setter basic functionality" do
|
79
|
+
assert_respond_to(@pe, :port=)
|
80
|
+
assert_nothing_raised{ @pe.port = 90 }
|
81
|
+
assert_equal(90, @pe.port)
|
82
|
+
end
|
83
|
+
|
84
|
+
test "timeout getter basic functionality" do
|
64
85
|
assert_respond_to(@pe, :timeout)
|
65
|
-
assert_respond_to(@pe, :timeout=)
|
66
86
|
assert_equal(5, @pe.timeout)
|
67
87
|
end
|
68
88
|
|
69
|
-
|
89
|
+
test "timeout setter basic functionality" do
|
90
|
+
assert_respond_to(@pe, :timeout=)
|
91
|
+
assert_nothing_raised{ @pe.timeout = 30 }
|
92
|
+
assert_equal(30, @pe.timeout)
|
93
|
+
end
|
94
|
+
|
95
|
+
test "exception method basic functionality" do
|
70
96
|
assert_respond_to(@pe, :exception)
|
71
|
-
assert_nothing_raised{ @pe.ping }
|
72
|
-
assert_nothing_raised{ @bad.ping }
|
73
97
|
assert_nil(@pe.exception)
|
98
|
+
end
|
99
|
+
|
100
|
+
test "pinging a bogus host stores exception data" do
|
101
|
+
assert_nothing_raised{ @bad.ping? }
|
74
102
|
assert_not_nil(@bad.exception)
|
75
103
|
end
|
76
104
|
|
77
|
-
|
105
|
+
test "pinging a good host results in no exception data" do
|
106
|
+
assert_nothing_raised{ @pe.ping }
|
107
|
+
assert_nil(@pe.exception)
|
108
|
+
end
|
109
|
+
|
110
|
+
test "warning basic functionality" do
|
78
111
|
assert_respond_to(@pe, :warning)
|
112
|
+
assert_nil(@pe.warning)
|
79
113
|
end
|
80
114
|
|
81
115
|
def teardown
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 6
|
9
|
+
version: 1.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel J. Berger
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-05 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|