net-ping 1.7.4 → 1.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 361926b3f3ac0c0f3bceb71cffe723bf10e70503
4
- data.tar.gz: 6a0b1f3e9269a1b76ca3d5ba111178295a2ffd91
3
+ metadata.gz: 6c09b778ab3eddc24d819fc4855f648350760930
4
+ data.tar.gz: 209507d7dafc6ebe9b8229c27c4f9be27aa54e70
5
5
  SHA512:
6
- metadata.gz: d445f63c02d900806db92f9e6a88afa463503865332d1a56629d8775b3d7f5916aa3697320da631093861d4256d884bf84c806270be3e4309d7c5e8142774131
7
- data.tar.gz: 6aa45f6d23a07235f5ff7f1fef3c72efdc82a5b4943b70da3830e5916e3299fc363f8d53e4ff9674c2247e4696ccd04c470fb6555cf3fa118a693aab6cb26df0
6
+ metadata.gz: a06111adfb673c48c85f6fc4ff993c3fce368cdcee0f7cc47fb9a651a198cf550847fade4df2dfcb57c071240690ac05db1c8ec7a6189c1226a124265703781f
7
+ data.tar.gz: 1c2e9622a0a092ded3f1cd6bae7b15cdb382183eadcafcbfa73e4dc4bedcb3e09d5247e2bf752c3fe40f76eadfba3c2463c4ae4e6fc2fe48072be37bfffa9b3a
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.7.5 - 2-Nov-2014
2
+ * Added packet count and intervals for external pings. Thanks go to Jack Hayter
3
+ for the patch.
4
+ * No longer report closed TCP port as active. Thanks go to Joshua Yanovski for
5
+ the spot and patch.
6
+
1
7
  == 1.7.4 - 16-Apr-2014
2
8
  * Remove the Timeout block for the Ping::HTTP class because it wasn't working
3
9
  with JRuby. Instead, we use the builtin open_timeout and read_timeout
data/MANIFEST CHANGED
@@ -1,5 +1,6 @@
1
- * MANIFEST
2
1
  * CHANGES
2
+ * Gemfile
3
+ * MANIFEST
3
4
  * Rakefile
4
5
  * README
5
6
  * net-ping.gemspec
data/README CHANGED
@@ -13,6 +13,10 @@
13
13
  == Installation
14
14
  gem install net-ping
15
15
 
16
+ == Maintainer Wanted!
17
+ I would very much like to turn this gem over to someone who is using it
18
+ more actively than I am. Please let me know if you are interested!
19
+
16
20
  == Notes
17
21
  Please read the documentation under the 'doc' directory. Especially pay
18
22
  attention to the documentation pertaining to ECONNREFUSED and TCP pings.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ namespace 'gem' do
20
20
  desc 'Install the net-ping gem'
21
21
  task :install => [:create] do
22
22
  gem_file = Dir["*.gem"].first
23
- sh "gem install #{gem_file}"
23
+ sh "gem install -l #{gem_file}"
24
24
  end
25
25
  end
26
26
 
@@ -15,7 +15,15 @@ module Net
15
15
  # contain a string indicating what went wrong. If the ping succeeded then
16
16
  # the Ping::External#warning method may or may not contain a value.
17
17
  #
18
- def ping(host = @host)
18
+ def ping(host = @host, count = 1, interval = 1, timeout = @timeout)
19
+
20
+ raise "Count must be an integer" unless count.is_a? Integer
21
+ raise "Timeout must be a number" unless timeout.is_a? Numeric
22
+
23
+ unless interval.is_a?(Numeric) && interval >= 0.2
24
+ raise "Interval must be a decimal greater than or equal to 0.2"
25
+ end
26
+
19
27
  super(host)
20
28
 
21
29
  pcmd = ['ping']
@@ -23,17 +31,17 @@ module Net
23
31
 
24
32
  case RbConfig::CONFIG['host_os']
25
33
  when /linux/i
26
- pcmd += ['-c', '1', '-W', @timeout.to_s, host]
34
+ pcmd += ['-c', count.to_s, '-W', timeout.to_s, host, '-i', interval.to_s]
27
35
  when /aix/i
28
- pcmd += ['-c', '1', '-w', @timeout.to_s, host]
36
+ pcmd += ['-c', count.to_s, '-w', timeout.to_s, host]
29
37
  when /bsd|osx|mach|darwin/i
30
- pcmd += ['-c', '1', '-t', @timeout.to_s, host]
38
+ pcmd += ['-c', count.to_s, '-t', timeout.to_s, host]
31
39
  when /solaris|sunos/i
32
- pcmd += [host, @timeout.to_s]
40
+ pcmd += [host, timeout.to_s]
33
41
  when /hpux/i
34
- pcmd += [host, '-n1', '-m', @timeout.to_s]
42
+ pcmd += [host, "-n#{count.to_s}", '-m', timeout.to_s]
35
43
  when /win32|windows|msdos|mswin|cygwin|mingw/i
36
- pcmd += ['-n', '1', '-w', (@timeout * 1000).to_s, host]
44
+ pcmd += ['-n', count.to_s, '-w', (timeout * 1000).to_s, host]
37
45
  else
38
46
  pcmd += [host]
39
47
  end
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.7.4'
13
+ VERSION = '1.7.5'
14
14
 
15
15
  # The host to ping. In the case of Ping::HTTP, this is the URI.
16
16
  attr_accessor :host
data/lib/net/ping/tcp.rb CHANGED
@@ -68,15 +68,20 @@ module Net
68
68
 
69
69
  resp = IO.select(nil, [sock], nil, timeout)
70
70
 
71
- # Assume ECONNREFUSED at this point
72
- if resp.nil?
73
- if @@service_check
74
- bool = true
75
- else
71
+ if @@service_check
72
+ bool = true
73
+ elsif resp.nil?
74
+ # Assume ECONNREFUSED at this point
75
+ @exception = Errno::ECONNREFUSED
76
+ else
77
+ sockopt = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
78
+
79
+ # Check to see if ECONNREFUSED actually occurred.
80
+ if sockopt.int == Errno::ECONNREFUSED::Errno
76
81
  @exception = Errno::ECONNREFUSED
82
+ else
83
+ bool = true
77
84
  end
78
- else
79
- bool = true
80
85
  end
81
86
  ensure
82
87
  sock.close if sock
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.4'
6
+ spec.version = '1.7.5'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.author = 'Daniel J. Berger'
9
9
  spec.email = 'djberg96@gmail.com'
@@ -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.7.4', Net::Ping::VERSION)
31
+ assert_equal('1.7.5', Net::Ping::VERSION)
32
32
  end
33
33
  end
34
34
 
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.7.4
4
+ version: 1.7.5
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: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit