pingly 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pingly.rb +12 -3
  2. metadata +2 -2
data/lib/pingly.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'open3'
2
2
 
3
3
  class Pingly
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
 
6
6
  attr_accessor :host, :timeout
7
7
 
@@ -41,7 +41,7 @@ class Pingly
41
41
  end
42
42
 
43
43
  def packets_received
44
- response_regex(/, (\d+) packets received/).to_i
44
+ response_regex(/, (\d+)(?: packets)? received/).to_i
45
45
  end
46
46
 
47
47
  def response
@@ -82,7 +82,16 @@ class Pingly
82
82
  end
83
83
 
84
84
  def build_ping_string
85
- "ping -t #{timeout} -q #{host}"
85
+ command = ["ping"]
86
+ command += case RbConfig::CONFIG['host_os']
87
+ when /bsd|osx|darwin/i
88
+ %W[-t #{timeout}]
89
+ when /linux/i
90
+ %W[-w #{timeout}]
91
+ end
92
+ command << host
93
+
94
+ command.join(' ')
86
95
  end
87
96
  end
88
97
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pingly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-04 00:00:00.000000000 Z
13
+ date: 2013-01-07 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Ping a specified host, logs the output, and calls a block on packet loss.
16
16
  email: