net-ping 1.7.1 → 1.7.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 +6 -14
- data/CHANGES +11 -0
- data/MANIFEST +0 -1
- data/README +6 -1
- data/lib/net/ping/external.rb +25 -73
- data/lib/net/ping/http.rb +16 -4
- data/lib/net/ping/icmp.rb +1 -2
- data/lib/net/ping/ping.rb +1 -1
- data/net-ping.gemspec +3 -9
- data/test/test_net_ping.rb +1 -1
- data/test/test_net_ping_http.rb +20 -0
- metadata +24 -37
- data/lib/net/ping/helper.rb +0 -33
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MTg3NWJmNTk5OGUzZGUxNzYxN2YzYzhjNWIwN2UxNzlhMzVkYTQ4YjdkMTgz
|
10
|
-
YjQxM2IxZGQxYjE4ODZmYzExMzRiNTBjNjczYTVhNDMxYzc1NjU0M2Y1NTNi
|
11
|
-
NzkxZmI3M2ExMWI4MzhjYTQ3YWQ1NzRhMGM1NDNkZmY1MDUzYjM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MzdmOTc4ODBhZTQzMzM0NTM3YmQ5MWI2NjkwNTI5YWEwMWViNTk2ZmVjMWFi
|
14
|
-
OTkzZjlhMTdhZWRlNGQ4ZWM3MGVjZjhlMjU4MTc3ZGRkMTA0OWJiOTMzYTY3
|
15
|
-
OWI3NTY2YzA5ZTExZGU4ZDNiYmNmMzMzMjg4NGYwNGRjOTM1NzE=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66ef8ec8a4d85b94397739115722bcb52e8b287b
|
4
|
+
data.tar.gz: 9b530dc0bdc258e6c3daef1c6c48677f09093661
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d57ad9937a32293703c097322bc1f24d6f031c4d910b5a4131616226a46320ddfbcf1072a7f40b39b2c1879c421717a6a9389b443254e9419513d7dfbfa307e3
|
7
|
+
data.tar.gz: 9016ac5f9fa70b60b89e0bcca798b516336fb9002cba9f21d6c17ed5dada65c8bd6d761aeb3e227f5dd65675e02984ab31dc3ef1ed290528385e3bf0ad105cf9
|
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.7.2 - 21-Jan-2014
|
2
|
+
* Fixed a bug in the Ping::HTTP constructor where it was not honoring the
|
3
|
+
port if provided as the second argument. Thanks go to Florian Anderiasch
|
4
|
+
for the spot.
|
5
|
+
* Removed win32-open3 require in the Ping::External class since it isn't
|
6
|
+
needed in Ruby 1.9.x or later.
|
7
|
+
* Refactored the Ping::External class so that it checks the exit status rather
|
8
|
+
than try to parse output. Thanks go to Miguel Tubia for the suggestion.
|
9
|
+
* Dropped explicit support for Windows XP.
|
10
|
+
* Removed reference to win32-open3 in README.
|
11
|
+
|
1
12
|
== 1.7.1 - 26-Sep-2013
|
2
13
|
* Fixed a bug in the Ping::TCP class where it could return nil instead
|
3
14
|
of false. Thanks go to Grandy Nguyen for the patch.
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
== Prerequisites
|
5
5
|
* ffi
|
6
6
|
* win32-security (MS Windows only)
|
7
|
-
* win32-open3 (Ruby 1.8.x on MS Windows only. Not required for JRuby)
|
8
7
|
* fakeweb (test only)
|
9
8
|
* test-unit (test only)
|
10
9
|
|
@@ -50,6 +49,12 @@
|
|
50
49
|
|
51
50
|
== License
|
52
51
|
Artistic 2.0
|
52
|
+
|
53
|
+
== Contributions
|
54
|
+
Although this library is free, please consider having your company
|
55
|
+
setup a gittip if used by your company professionally.
|
56
|
+
|
57
|
+
http://www.gittip.com/djberg96/
|
53
58
|
|
54
59
|
== More documentation
|
55
60
|
If you installed this library via Rubygems, you can view the inline
|
data/lib/net/ping/external.rb
CHANGED
@@ -1,28 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'open3'
|
2
2
|
require 'rbconfig'
|
3
3
|
|
4
4
|
require File.join(File.dirname(__FILE__), 'ping')
|
5
5
|
|
6
|
-
if File::ALT_SEPARATOR && RUBY_VERSION.to_f < 1.9 && RUBY_PLATFORM != 'java'
|
7
|
-
require 'win32/open3'
|
8
|
-
else
|
9
|
-
require 'open3'
|
10
|
-
end
|
11
|
-
|
12
6
|
# The Net module serves as a namespace only.
|
13
7
|
module Net
|
14
8
|
|
15
9
|
# The Ping::External class encapsulates methods for external (system) pings.
|
16
10
|
class Ping::External < Ping
|
17
|
-
|
18
|
-
if File::ALT_SEPARATOR
|
19
|
-
extend FFI::Library
|
20
|
-
ffi_lib 'kernel32'
|
21
|
-
|
22
|
-
attach_function :SetConsoleCP, [:uint], :bool
|
23
|
-
attach_function :GetConsoleCP, [], :uint
|
24
|
-
end
|
25
|
-
|
26
11
|
# Pings the host using your system's ping utility and checks for any
|
27
12
|
# errors or warnings. Returns true if successful, or false if not.
|
28
13
|
#
|
@@ -33,24 +18,20 @@ module Net
|
|
33
18
|
def ping(host = @host)
|
34
19
|
super(host)
|
35
20
|
|
36
|
-
|
37
|
-
|
38
|
-
bool = false
|
39
|
-
orig_cp = nil
|
21
|
+
pcmd = ['ping']
|
22
|
+
bool = false
|
40
23
|
|
41
24
|
case RbConfig::CONFIG['host_os']
|
42
25
|
when /linux|bsd|osx|mach|darwin/i
|
43
|
-
|
26
|
+
pcmd += ['-c1', host]
|
44
27
|
when /solaris|sunos/i
|
45
|
-
|
28
|
+
pcmd += [host, '1']
|
46
29
|
when /hpux/i
|
47
|
-
|
30
|
+
pcmd += [host, '-n1']
|
48
31
|
when /win32|windows|msdos|mswin|cygwin|mingw/i
|
49
|
-
|
50
|
-
SetConsoleCP(437) if orig_cp != 437 # United States
|
51
|
-
pstring += "-n 1 #{host}"
|
32
|
+
pcmd += ['-n', '1', host]
|
52
33
|
else
|
53
|
-
|
34
|
+
pcmd += [host]
|
54
35
|
end
|
55
36
|
|
56
37
|
start_time = Time.now
|
@@ -59,55 +40,26 @@ module Net
|
|
59
40
|
err = nil
|
60
41
|
|
61
42
|
Timeout.timeout(@timeout){
|
62
|
-
stdin, stdout, stderr
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@exception = err.chomp
|
43
|
+
Open3.popen3(*pcmd) do |stdin, stdout, stderr, thread|
|
44
|
+
err = stderr.gets # Can't chomp yet, might be nil
|
45
|
+
|
46
|
+
case thread.value.exitstatus
|
47
|
+
when 0
|
48
|
+
bool = true # Success, at least one response.
|
49
|
+
if err & err =~ /warning/i
|
50
|
+
@warning = err.chomp
|
51
|
+
end
|
52
|
+
when 2
|
53
|
+
bool = false # Transmission successful, no response.
|
54
|
+
@exception = err.chomp
|
55
|
+
else
|
56
|
+
bool = false # An error occurred
|
57
|
+
@exception = err.chomp
|
58
|
+
end
|
79
59
|
end
|
80
|
-
|
81
|
-
else
|
82
|
-
lines = stdout.readlines
|
83
|
-
stdout.close
|
84
|
-
if lines.nil? || lines.empty?
|
85
|
-
bool = true
|
86
|
-
else
|
87
|
-
regexp = /
|
88
|
-
no\ answer|
|
89
|
-
host\ unreachable|
|
90
|
-
could\ not\ find\ host|
|
91
|
-
request\ timed\ out|
|
92
|
-
100%\ packet\ loss
|
93
|
-
/ix
|
94
|
-
|
95
|
-
lines.each{ |line|
|
96
|
-
if regexp.match(line)
|
97
|
-
@exception = line.chomp
|
98
|
-
break
|
99
|
-
end
|
100
|
-
}
|
101
|
-
|
102
|
-
bool = true unless @exception
|
103
|
-
end
|
104
|
-
end
|
60
|
+
}
|
105
61
|
rescue Exception => error
|
106
62
|
@exception = error.message
|
107
|
-
ensure
|
108
|
-
stdin.close if stdin && !stdin.closed?
|
109
|
-
stdout.close if stdout && !stdout.closed?
|
110
|
-
stderr.close if stderr && !stderr.closed?
|
111
63
|
end
|
112
64
|
|
113
65
|
# There is no duration if the ping failed
|
data/lib/net/ping/http.rb
CHANGED
@@ -37,6 +37,10 @@ module Net
|
|
37
37
|
# was this ping proxied?
|
38
38
|
attr_accessor :proxied
|
39
39
|
|
40
|
+
# For unsuccessful requests that return a server error, it is
|
41
|
+
# useful to know the HTTP status code of the response.
|
42
|
+
attr_reader :code
|
43
|
+
|
40
44
|
# Creates and returns a new Ping::HTTP object. The default port is the
|
41
45
|
# port associated with the URI. The default timeout is 5 seconds.
|
42
46
|
#
|
@@ -45,6 +49,7 @@ module Net
|
|
45
49
|
@redirect_limit = 5
|
46
50
|
@ssl_verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
51
|
@get_request = false
|
52
|
+
@code = nil
|
48
53
|
|
49
54
|
port ||= URI.parse(uri).port if uri
|
50
55
|
|
@@ -75,9 +80,13 @@ module Net
|
|
75
80
|
|
76
81
|
uri = URI.parse(host)
|
77
82
|
|
83
|
+
# A port provided here overrides anything provided in constructor
|
84
|
+
port = URI.split(host)[3] || @port
|
85
|
+
port = port.to_i
|
86
|
+
|
78
87
|
start_time = Time.now
|
79
88
|
|
80
|
-
response = do_ping(uri)
|
89
|
+
response = do_ping(uri, port)
|
81
90
|
|
82
91
|
if response.is_a?(Net::HTTPSuccess)
|
83
92
|
bool = true
|
@@ -93,7 +102,7 @@ module Net
|
|
93
102
|
end
|
94
103
|
redirect = URI.parse(response['location'])
|
95
104
|
redirect = uri + redirect if redirect.relative?
|
96
|
-
response = do_ping(redirect)
|
105
|
+
response = do_ping(redirect, port)
|
97
106
|
rlimit += 1
|
98
107
|
end
|
99
108
|
|
@@ -107,6 +116,8 @@ module Net
|
|
107
116
|
else
|
108
117
|
@exception = response.message
|
109
118
|
end
|
119
|
+
else
|
120
|
+
@exception ||= response.message
|
110
121
|
end
|
111
122
|
|
112
123
|
# There is no duration if the ping failed
|
@@ -127,7 +138,7 @@ module Net
|
|
127
138
|
response && response.code.to_i >= 300 && response.code.to_i < 400
|
128
139
|
end
|
129
140
|
|
130
|
-
def do_ping(uri)
|
141
|
+
def do_ping(uri, port)
|
131
142
|
response = nil
|
132
143
|
proxy = uri.find_proxy || URI.parse("")
|
133
144
|
begin
|
@@ -135,7 +146,7 @@ module Net
|
|
135
146
|
headers = { }
|
136
147
|
headers["User-Agent"] = user_agent unless user_agent.nil?
|
137
148
|
Timeout.timeout(@timeout) do
|
138
|
-
http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new(uri.host,
|
149
|
+
http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new(uri.host, port)
|
139
150
|
@proxied = http.proxy?
|
140
151
|
if @get_request == true
|
141
152
|
request = Net::HTTP::Get.new(uri_path)
|
@@ -153,6 +164,7 @@ module Net
|
|
153
164
|
rescue Exception => err
|
154
165
|
@exception = err.message
|
155
166
|
end
|
167
|
+
@code = response.code if response
|
156
168
|
response
|
157
169
|
end
|
158
170
|
end
|
data/lib/net/ping/icmp.rb
CHANGED
@@ -2,7 +2,6 @@ require File.join(File.dirname(__FILE__), 'ping')
|
|
2
2
|
|
3
3
|
if File::ALT_SEPARATOR
|
4
4
|
require 'win32/security'
|
5
|
-
require File.join(File.dirname(__FILE__), 'helper')
|
6
5
|
end
|
7
6
|
|
8
7
|
# The Net module serves as a namespace only.
|
@@ -31,7 +30,7 @@ module Net
|
|
31
30
|
def initialize(host=nil, port=nil, timeout=5)
|
32
31
|
raise 'requires root privileges' if Process.euid > 0
|
33
32
|
|
34
|
-
if File::ALT_SEPARATOR
|
33
|
+
if File::ALT_SEPARATOR
|
35
34
|
unless Win32::Security.elevated_security?
|
36
35
|
raise 'requires elevated security'
|
37
36
|
end
|
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.7.
|
6
|
+
spec.version = '1.7.2'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.author = 'Daniel J. Berger'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
@@ -18,10 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# The TCP Ping class requires this for non-blocking sockets.
|
19
19
|
spec.required_ruby_version = ">= 1.9.1"
|
20
20
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_development_dependency('test-unit', '>= 2.5.0')
|
24
|
-
spec.add_development_dependency('fakeweb', '>= 1.3.0')
|
21
|
+
spec.add_development_dependency('test-unit')
|
22
|
+
spec.add_development_dependency('fakeweb')
|
25
23
|
spec.add_development_dependency('rake')
|
26
24
|
|
27
25
|
if File::ALT_SEPARATOR
|
@@ -32,10 +30,6 @@ Gem::Specification.new do |spec|
|
|
32
30
|
|
33
31
|
# Used for icmp pings.
|
34
32
|
spec.add_dependency('win32-security', '>= 0.2.0')
|
35
|
-
|
36
|
-
if RUBY_VERSION.to_f < 1.9 && RUBY_PLATFORM != 'java'
|
37
|
-
spec.add_dependency('win32-open3', '>= 0.3.1')
|
38
|
-
end
|
39
33
|
end
|
40
34
|
|
41
35
|
spec.description = <<-EOF
|
data/test/test_net_ping.rb
CHANGED
data/test/test_net_ping_http.rb
CHANGED
@@ -26,6 +26,9 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
26
26
|
:status => ["302", "Found"])
|
27
27
|
|
28
28
|
FakeWeb.register_uri(:any, 'http://www.blabfoobarurghxxxx.com', :exception => SocketError)
|
29
|
+
FakeWeb.register_uri(:head, 'http://http502.com',
|
30
|
+
:body => "",
|
31
|
+
:status => ["502", "Bad Gateway"])
|
29
32
|
|
30
33
|
@http = Net::Ping::HTTP.new(@uri, 80, 30)
|
31
34
|
@bad = Net::Ping::HTTP.new('http://www.blabfoobarurghxxxx.com') # One hopes not
|
@@ -122,6 +125,11 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
122
125
|
assert_nil(@http.warning)
|
123
126
|
end
|
124
127
|
|
128
|
+
test 'code attribute is set' do
|
129
|
+
assert_true(@http.ping)
|
130
|
+
assert_equal('200', @http.code)
|
131
|
+
end
|
132
|
+
|
125
133
|
test 'user_agent accessor is defined' do
|
126
134
|
assert_respond_to(@http, :user_agent)
|
127
135
|
assert_respond_to(@http, :user_agent=)
|
@@ -163,6 +171,18 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
|
|
163
171
|
assert_equal("Redirect limit exceeded", @http.exception)
|
164
172
|
end
|
165
173
|
|
174
|
+
test 'http 502 sets exception' do
|
175
|
+
@http = Net::Ping::HTTP.new("http://http502.com")
|
176
|
+
assert_false(@http.ping)
|
177
|
+
assert_equal('Bad Gateway', @http.exception)
|
178
|
+
end
|
179
|
+
|
180
|
+
test 'http 502 sets code' do
|
181
|
+
@http = Net::Ping::HTTP.new("http://http502.com")
|
182
|
+
assert_false(@http.ping)
|
183
|
+
assert_equal('502', @http.code)
|
184
|
+
end
|
185
|
+
|
166
186
|
test 'ping against https site defaults to port 443' do
|
167
187
|
@http = Net::Ping::HTTP.new(@uri_https)
|
168
188
|
assert_equal(443, @http.port)
|
metadata
CHANGED
@@ -1,73 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.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:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ffi
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: test-unit
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- -
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
19
|
+
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
26
|
+
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: fakeweb
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: '0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
40
|
+
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- -
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
55
|
+
description: |2
|
56
|
+
The net-ping library provides a ping interface for Ruby. It includes
|
57
|
+
separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping
|
58
|
+
classes.
|
71
59
|
email: djberg96@gmail.com
|
72
60
|
executables: []
|
73
61
|
extensions: []
|
@@ -77,25 +65,24 @@ extra_rdoc_files:
|
|
77
65
|
- doc/ping.txt
|
78
66
|
files:
|
79
67
|
- CHANGES
|
68
|
+
- Gemfile
|
69
|
+
- MANIFEST
|
70
|
+
- README
|
71
|
+
- Rakefile
|
80
72
|
- doc/ping.txt
|
81
73
|
- examples/example_pingexternal.rb
|
82
74
|
- examples/example_pinghttp.rb
|
83
75
|
- examples/example_pingtcp.rb
|
84
76
|
- examples/example_pingudp.rb
|
85
|
-
-
|
77
|
+
- lib/net/ping.rb
|
86
78
|
- lib/net/ping/external.rb
|
87
|
-
- lib/net/ping/helper.rb
|
88
79
|
- lib/net/ping/http.rb
|
89
80
|
- lib/net/ping/icmp.rb
|
90
81
|
- lib/net/ping/ping.rb
|
91
82
|
- lib/net/ping/tcp.rb
|
92
83
|
- lib/net/ping/udp.rb
|
93
84
|
- lib/net/ping/wmi.rb
|
94
|
-
- lib/net/ping.rb
|
95
|
-
- MANIFEST
|
96
85
|
- net-ping.gemspec
|
97
|
-
- Rakefile
|
98
|
-
- README
|
99
86
|
- test/test_net_ping.rb
|
100
87
|
- test/test_net_ping_external.rb
|
101
88
|
- test/test_net_ping_http.rb
|
@@ -113,17 +100,17 @@ require_paths:
|
|
113
100
|
- lib
|
114
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
102
|
requirements:
|
116
|
-
- -
|
103
|
+
- - ">="
|
117
104
|
- !ruby/object:Gem::Version
|
118
105
|
version: 1.9.1
|
119
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
107
|
requirements:
|
121
|
-
- -
|
108
|
+
- - ">="
|
122
109
|
- !ruby/object:Gem::Version
|
123
110
|
version: '0'
|
124
111
|
requirements: []
|
125
112
|
rubyforge_project: shards
|
126
|
-
rubygems_version: 2.0
|
113
|
+
rubygems_version: 2.2.0
|
127
114
|
signing_key:
|
128
115
|
specification_version: 4
|
129
116
|
summary: A ping interface for Ruby.
|
data/lib/net/ping/helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'ffi'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
extend FFI::Library
|
5
|
-
ffi_lib :kernel32
|
6
|
-
|
7
|
-
attach_function :GetVersion, [], :ulong
|
8
|
-
|
9
|
-
def version
|
10
|
-
version = GetVersion()
|
11
|
-
major = LOBYTE(LOWORD(version))
|
12
|
-
minor = HIBYTE(LOWORD(version))
|
13
|
-
eval("Float(#{major}.#{minor})")
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
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
|
30
|
-
end
|
31
|
-
|
32
|
-
module_function :version
|
33
|
-
end
|