net-ping 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzI5NjJkYzk2MzJmZjlhYzg1NWM1MTU1Y2M2NWIyNDczMDBjZTcwNQ==
4
+ MWEzZmUxOTg3ZmRmY2E1MDA5ZmNmZTdlMzk1ZGQ2NTM1NTkyMTM5Ng==
5
5
  data.tar.gz: !binary |-
6
- ZWNmMzY1MzJkYTk5MmFmMWI0NDQ3Y2NiNTZhYjkwZTIzYjMxYTVmNw==
6
+ YzcwNTFlYzg0MzRlZjJhNjg2ZGMwYzg0ODBlMzQ0NTlhNTNhMjA5YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTBhYTQ3NjgyNWJhZWY0NzdlZThlY2M1YjE0MzIzNjQ0ZTQ2M2Y4OWZhNTY2
10
- MWMzZmYwMTcxYjJmMDFmNjk3YWI0Mzk0NDlkNmUxOGZhZGFhZmFkMzJhZWNk
11
- ZDVjNjNiZTE3OTAxZGQ3NDEyNTRlMjFkM2JmOTg2ZTA1ZmNkMWY=
9
+ MzQ3NDg1MzEzNTJiNDdlMjgxNzZiMDlhZDI5MzM0MzdmMDllOGU3NTBhYjgy
10
+ MDM1ZDU1MWJiMzYwYjZmZGU3NDAxZWQ4YzY1YzBlODkyNWRiMWExOTU4MjA2
11
+ MDkwMmQ0NDk1M2VjYWNlMDZlMGUyODM2NTUzNmFmNDAxYTY1Nzg=
12
12
  data.tar.gz: !binary |-
13
- MjdjMGEzZDM1YzAwMWVmN2M1YWQwYjY3MTMzNjViMGM0Yjc4ZWM4ODk4MzY0
14
- MDc2MzI1NGI2NzU1ODZiMGExMGE3ZTYwY2RjZjEzYzk0MWE4ZWNkM2FkZDBh
15
- MDRlMjIzYTA2ZDU4ZGYyMmU4MDM3ZDM3MWNlN2Y1OWJlZjEyMTU=
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
- A collection of classes that provide different ways to ping computers.
2
+ A collection of classes that provide different ways to ping computers.
3
3
 
4
4
  == Prerequisites
5
- The win32-open3 (1.8.x) and windows-pr libraries are required on
6
- MS Windows when using the Net::Ping::External class unless you're
7
- using JRuby.
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
- JRuby users should use 1.6.7 or later.
11
+ JRuby users should use JRuby 1.6.7 or later.
10
12
 
11
13
  == Installation
12
- gem install net-ping
14
+ gem install net-ping
13
15
 
14
16
  == Notes
15
- Please read the documentation under the 'doc' directory. Especially pay
16
- attention to the documentation pertaining to ECONNREFUSED and TCP pings.
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
- Also note the documentation regarding down hosts.
20
+ Also note the documentation regarding down hosts.
19
21
 
20
- You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
21
- as part of the Ruby standard library should work.
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
- You can do either this:
26
+ You can do either this:
25
27
 
26
- require 'net/ping'
28
+ require 'net/ping'
27
29
 
28
- In which case you will get Net::Ping and all of its subclasses. Or,
29
- you can load individual subclasses like this:
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
- require 'net/ping/tcp'
33
+ require 'net/ping/tcp'
32
34
 
33
- The former has the advantage of being easier to remember and all inclusive,
34
- not to mention backwards compatible. The latter has the advantage of
35
- reducing your memory footprint.
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
- Older versions of Ruby 1.9.x may not work with UDP pings.
40
+ Older versions of Ruby 1.9.x may not work with UDP pings.
39
41
 
40
- Older versions of JRuby will return false positives in UDP pings
41
- because of an incorrect error class being raised. See JRuby-4896.
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
- JRuby 1.6.7 or later is required for external pings because of a bug
44
- in earlier versions with open3 and stream handling.
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
- Artistic 2.0
49
+ Artistic 2.0
48
50
 
49
51
  == More documentation
50
- If you installed this library via Rubygems, you can view the inline
51
- documentation via ri or fire up 'gem server', and point your browser at
52
- http://localhost:8808.
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.
@@ -15,16 +15,18 @@ module Windows
15
15
 
16
16
  private
17
17
 
18
- def LOWORD(l)
19
- l & 0xffff
20
- end
21
-
22
- def LOBYTE(w)
23
- w & 0xff
24
- end
25
-
26
- def HIBYTE(w)
27
- w >> 8
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
@@ -10,7 +10,7 @@ module Net
10
10
  #
11
11
  class Ping
12
12
  # The version of the net-ping library.
13
- VERSION = '1.6.1'
13
+ VERSION = '1.6.2'
14
14
 
15
15
  # The host to ping. In the case of Ping::HTTP, this is the URI.
16
16
  attr_accessor :host
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.1'
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 && RUBY_PLATFORM != 'java'
25
- spec.platform = Gem::Platform::CURRENT
26
- spec.platform.cpu = 'universal'
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 primarily for icmp pings.
30
- spec.add_development_dependency('win32-security', '>= 0.2.0')
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
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  class TC_Net_Ping < Test::Unit::TestCase
30
30
  def test_net_ping_version
31
- assert_equal('1.6.1', Net::Ping::VERSION)
31
+ assert_equal('1.6.2', Net::Ping::VERSION)
32
32
  end
33
33
  end
34
34
 
@@ -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
- if windows_version >= 6 && !Win32::Security.elevated_security?
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
- def test_ping
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
- def test_ping_aliases_basic
39
- assert_respond_to(@icmp, :ping?)
40
- assert_respond_to(@icmp, :pingecho)
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
- def test_ping_returns_boolean
46
- assert_boolean(@icmp.pingecho)
47
- assert_boolean(@icmp.pingecho(@host))
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
- def test_ping_expected_success
51
- assert_true(Ping::ICMP.new(@host).ping?)
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
- def test_ping_expected_failure
55
- assert_false(Ping::ICMP.new('bogus').ping?)
56
- assert_false(Ping::ICMP.new('http://www.asdfhjklasdfhlkj.com').ping?)
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
- def test_bind
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
- def test_duration
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
- def test_host
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
- def test_port
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
- def test_timeout
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
- def test_exception
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
- def test_warning
111
+ test "warning method basic functionality" do
95
112
  assert_respond_to(@icmp, :warning)
96
113
  end
97
114
 
98
- def test_data_size_get
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
- def test_data_size_set
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
- def test_odd_data_size_ok
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.1
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-07-17 00:00:00.000000000 Z
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi