net-ping 1.6.1 → 1.6.2
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 +8 -8
- data/CHANGES +8 -0
- data/README +30 -28
- data/lib/net/ping/helper.rb +12 -10
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +8 -7
- data/test/test_net_ping.rb +1 -1
- data/test/test_net_ping_icmp.rb +53 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWEzZmUxOTg3ZmRmY2E1MDA5ZmNmZTdlMzk1ZGQ2NTM1NTkyMTM5Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzcwNTFlYzg0MzRlZjJhNjg2ZGMwYzg0ODBlMzQ0NTlhNTNhMjA5YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzQ3NDg1MzEzNTJiNDdlMjgxNzZiMDlhZDI5MzM0MzdmMDllOGU3NTBhYjgy
|
10
|
+
MDM1ZDU1MWJiMzYwYjZmZGU3NDAxZWQ4YzY1YzBlODkyNWRiMWExOTU4MjA2
|
11
|
+
MDkwMmQ0NDk1M2VjYWNlMDZlMGUyODM2NTUzNmFmNDAxYTY1Nzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGMxYjU3MjI3ZjM1OGNmMzc2NTg4NGI0YWI4MTEzNzU2YWJlOWI3OThjN2Zi
|
14
|
+
OWEyYTEyNTdlM2I4NjFiYmUwYWJjZWNmYTE3ZmNhMThlMmViNDY5NjIxZGNl
|
15
|
+
MTJmYjc0YjU5MTBhNjlhN2QwOWM1NDYwM2VhNjg1MzBkZjc0YTI=
|
data/CHANGES
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.6.2 - 8-Aug-2013
|
2
|
+
* Fixed a bug in the ICMP ping helper module. Thanks go to Yuichi
|
3
|
+
Tsunematsu for the spot.
|
4
|
+
* The win32-security library is not just a development dependency. Thanks
|
5
|
+
again go to Yuichi Tsunematsu for the spot.
|
6
|
+
* Updated the icmp ping tests.
|
7
|
+
* Updated the gemspec for MS Windows.
|
8
|
+
|
1
9
|
== 1.6.1 - 17-Jul-2013
|
2
10
|
* Automatically set the scheme to "http" if not present when performing
|
3
11
|
HTTP pings. See https://bugs.ruby-lang.org/issues/8645 for an issue
|
data/README
CHANGED
@@ -1,52 +1,54 @@
|
|
1
1
|
== Description
|
2
|
-
|
2
|
+
A collection of classes that provide different ways to ping computers.
|
3
3
|
|
4
4
|
== Prerequisites
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
* ffi
|
6
|
+
* win32-security (MS Windows only)
|
7
|
+
* win32-open3 (Ruby 1.8.x on MS Windows only. Not required for JRuby)
|
8
|
+
* fakeweb (test only)
|
9
|
+
* test-unit (test only)
|
8
10
|
|
9
|
-
|
11
|
+
JRuby users should use JRuby 1.6.7 or later.
|
10
12
|
|
11
13
|
== Installation
|
12
|
-
|
14
|
+
gem install net-ping
|
13
15
|
|
14
16
|
== Notes
|
15
|
-
|
16
|
-
|
17
|
+
Please read the documentation under the 'doc' directory. Especially pay
|
18
|
+
attention to the documentation pertaining to ECONNREFUSED and TCP pings.
|
17
19
|
|
18
|
-
|
20
|
+
Also note the documentation regarding down hosts.
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
|
23
|
+
as part of the Ruby standard library should work.
|
22
24
|
|
23
25
|
== How to require net-ping
|
24
|
-
|
26
|
+
You can do either this:
|
25
27
|
|
26
|
-
|
28
|
+
require 'net/ping'
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
In which case you will get Net::Ping and all of its subclasses. Or,
|
31
|
+
you can load individual subclasses like this:
|
30
32
|
|
31
|
-
|
33
|
+
require 'net/ping/tcp'
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
The former has the advantage of being easier to remember and all inclusive,
|
36
|
+
not to mention backwards compatible. The latter has the advantage of
|
37
|
+
reducing your memory footprint.
|
36
38
|
|
37
39
|
== Known Issues
|
38
|
-
|
40
|
+
Older versions of Ruby 1.9.x may not work with UDP pings.
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
Older versions of JRuby will return false positives in UDP pings
|
43
|
+
because of an incorrect error class being raised. See JRuby-4896.
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
+
JRuby 1.6.7 or later is required for external pings because of a bug
|
46
|
+
in earlier versions with open3 and stream handling.
|
45
47
|
|
46
48
|
== License
|
47
|
-
|
49
|
+
Artistic 2.0
|
48
50
|
|
49
51
|
== More documentation
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
If you installed this library via Rubygems, you can view the inline
|
53
|
+
documentation via ri or fire up 'gem server', and point your browser at
|
54
|
+
http://localhost:8808.
|
data/lib/net/ping/helper.rb
CHANGED
@@ -15,16 +15,18 @@ module Windows
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
|
19
|
-
l
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
w
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
w
|
18
|
+
class << self
|
19
|
+
def LOWORD(l)
|
20
|
+
l & 0xffff
|
21
|
+
end
|
22
|
+
|
23
|
+
def LOBYTE(w)
|
24
|
+
w & 0xff
|
25
|
+
end
|
26
|
+
|
27
|
+
def HIBYTE(w)
|
28
|
+
w >> 8
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
module_function :version
|
data/lib/net/ping/ping.rb
CHANGED
data/net-ping.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'net-ping'
|
6
|
-
spec.version = '1.6.
|
6
|
+
spec.version = '1.6.2'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.author = 'Daniel J. Berger'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
@@ -21,15 +21,16 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency('fakeweb', '>= 1.3.0')
|
22
22
|
spec.add_development_dependency('rake')
|
23
23
|
|
24
|
-
if File::ALT_SEPARATOR
|
25
|
-
|
26
|
-
|
24
|
+
if File::ALT_SEPARATOR
|
25
|
+
require 'rbconfig'
|
26
|
+
arch = RbConfig::CONFIG['build_os']
|
27
|
+
spec.platform = Gem::Platform.new(['universal', arch])
|
27
28
|
spec.platform.version = nil
|
28
29
|
|
29
|
-
# Used
|
30
|
-
spec.
|
30
|
+
# Used for icmp pings.
|
31
|
+
spec.add_dependency('win32-security', '>= 0.2.0')
|
31
32
|
|
32
|
-
if RUBY_VERSION.to_f < 1.9
|
33
|
+
if RUBY_VERSION.to_f < 1.9 && RUBY_PLATFORM != 'java'
|
33
34
|
spec.add_dependency('win32-open3', '>= 0.3.1')
|
34
35
|
end
|
35
36
|
end
|
data/test/test_net_ping.rb
CHANGED
data/test/test_net_ping_icmp.rb
CHANGED
@@ -7,14 +7,11 @@
|
|
7
7
|
#######################################################################
|
8
8
|
require 'test-unit'
|
9
9
|
require 'net/ping/icmp'
|
10
|
-
include Net
|
11
10
|
|
12
11
|
if File::ALT_SEPARATOR
|
13
12
|
require 'win32/security'
|
14
|
-
require 'windows/system_info'
|
15
|
-
include Windows::SystemInfo
|
16
13
|
|
17
|
-
|
14
|
+
unless Win32::Security.elevated_security?
|
18
15
|
raise "The test:icmp task must be run with elevated security rights"
|
19
16
|
end
|
20
17
|
else
|
@@ -26,86 +23,111 @@ end
|
|
26
23
|
class TC_PingICMP < Test::Unit::TestCase
|
27
24
|
def setup
|
28
25
|
@host = '127.0.0.1' # 'localhost'
|
29
|
-
@icmp = Ping::ICMP.new(@host)
|
26
|
+
@icmp = Net::Ping::ICMP.new(@host)
|
30
27
|
end
|
31
28
|
|
32
|
-
|
29
|
+
test "icmp ping basic functionality" do
|
33
30
|
assert_respond_to(@icmp, :ping)
|
34
31
|
assert_nothing_raised{ @icmp.ping }
|
32
|
+
end
|
33
|
+
|
34
|
+
test "icmp ping accepts a host" do
|
35
35
|
assert_nothing_raised{ @icmp.ping(@host) }
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assert_nothing_raised{ @icmp.ping? }
|
42
|
-
assert_nothing_raised{ @icmp.ping?(@host) }
|
38
|
+
test "icmp ping returns a boolean" do
|
39
|
+
assert_boolean(@icmp.ping)
|
40
|
+
assert_boolean(@icmp.ping(@host))
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
test "icmp ping of local host is successful" do
|
44
|
+
assert_true(Net::Ping::ICMP.new(@host).ping?)
|
45
|
+
assert_true(Net::Ping::ICMP.new('192.168.0.1').ping?)
|
48
46
|
end
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
test "ping? is an alias for ping" do
|
49
|
+
assert_respond_to(@icmp, :ping?)
|
50
|
+
assert_alias_method(@icmp, :ping?, :ping)
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
test "pingecho is an alias for ping" do
|
54
|
+
assert_respond_to(@icmp, :pingecho)
|
55
|
+
assert_alias_method(@icmp, :pingecho, :ping)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "icmp ping fails if host is invalid" do
|
59
|
+
assert_false(Net::Ping::ICMP.new('bogus').ping?)
|
60
|
+
assert_false(Net::Ping::ICMP.new('http://www.asdfhjklasdfhlkj.com').ping?)
|
57
61
|
end
|
58
62
|
|
59
|
-
|
63
|
+
test "bind method basic functionality" do
|
60
64
|
assert_respond_to(@icmp, :bind)
|
61
65
|
assert_nothing_raised{ @icmp.bind(Socket.gethostname) }
|
62
66
|
assert_nothing_raised{ @icmp.bind(Socket.gethostname, 80) }
|
63
67
|
end
|
64
68
|
|
65
|
-
|
69
|
+
test "duration method basic functionality" do
|
66
70
|
assert_nothing_raised{ @icmp.ping }
|
67
71
|
assert_respond_to(@icmp, :duration)
|
68
72
|
assert_kind_of(Float, @icmp.duration)
|
69
73
|
end
|
70
74
|
|
71
|
-
|
75
|
+
test "host getter method basic functionality" do
|
72
76
|
assert_respond_to(@icmp, :host)
|
73
|
-
assert_respond_to(@icmp, :host=)
|
74
77
|
assert_equal(@host, @icmp.host)
|
75
78
|
end
|
76
79
|
|
77
|
-
|
80
|
+
test "host setter method basic functionality" do
|
81
|
+
assert_respond_to(@icmp, :host=)
|
82
|
+
assert_nothing_raised{ @icmp.host = '192.168.0.1' }
|
83
|
+
assert_equal(@icmp.host, '192.168.0.1')
|
84
|
+
end
|
85
|
+
|
86
|
+
test "port method basic functionality" do
|
78
87
|
assert_respond_to(@icmp, :port)
|
79
88
|
assert_equal(nil, @icmp.port)
|
80
89
|
end
|
81
90
|
|
82
|
-
|
91
|
+
test "timeout getter method basic functionality" do
|
83
92
|
assert_respond_to(@icmp, :timeout)
|
84
|
-
assert_respond_to(@icmp, :timeout=)
|
85
93
|
assert_equal(5, @icmp.timeout)
|
86
94
|
end
|
87
95
|
|
88
|
-
|
96
|
+
test "timeout setter method basic functionality" do
|
97
|
+
assert_respond_to(@icmp, :timeout=)
|
98
|
+
assert_nothing_raised{ @icmp.timeout = 7 }
|
99
|
+
assert_equal(7, @icmp.timeout)
|
100
|
+
end
|
101
|
+
|
102
|
+
test "exception method basic functionality" do
|
89
103
|
assert_respond_to(@icmp, :exception)
|
90
104
|
assert_nothing_raised{ @icmp.ping }
|
105
|
+
end
|
106
|
+
|
107
|
+
test "exception method returns nil if no ping has happened yet" do
|
91
108
|
assert_nil(@icmp.exception)
|
92
109
|
end
|
93
110
|
|
94
|
-
|
111
|
+
test "warning method basic functionality" do
|
95
112
|
assert_respond_to(@icmp, :warning)
|
96
113
|
end
|
97
114
|
|
98
|
-
|
115
|
+
test "data_size getter method basic functionality" do
|
99
116
|
assert_respond_to(@icmp, :data_size)
|
117
|
+
assert_nothing_raised{ @icmp.data_size }
|
118
|
+
assert_kind_of(Numeric, @icmp.data_size)
|
119
|
+
end
|
120
|
+
|
121
|
+
test "data_size returns expected value" do
|
100
122
|
assert_equal(56, @icmp.data_size)
|
101
123
|
end
|
102
124
|
|
103
|
-
|
125
|
+
test "data_size setter method basic functionality" do
|
104
126
|
assert_respond_to(@icmp, :data_size=)
|
105
127
|
assert_nothing_raised{ @icmp.data_size = 22 }
|
106
128
|
end
|
107
129
|
|
108
|
-
|
130
|
+
test "setting an odd data_size is valid" do
|
109
131
|
assert_nothing_raised{ @icmp.data_size = 57 }
|
110
132
|
assert_boolean(@icmp.ping)
|
111
133
|
end
|
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: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|