net-ping 1.7.7 → 1.7.8

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b64d1fdb2f212bd7212e479b46b84c5b7fb6015
4
+ data.tar.gz: de13dd9eef7ec47b5625e56bf4f562950e6d79ef
5
+ SHA512:
6
+ metadata.gz: 224d9695832c1359e637c946d021c204b86ce94bd652ec3c597b414ea68e1098122c84f9a9bf839a3b91d4e23e2f492e7d4c3231d070051e10091ec6ca72fced
7
+ data.tar.gz: 6635c45ac8bde019c7cf218e6fa96396bc7ee79323618156d3644349b313dad709e9034b970616d3ca20039a617202992aa8502278fbf4cd67a2f0c886d3f399
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- net-ping (1.7.7)
4
+ net-ping (1.7.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  fakeweb (1.3.0)
10
- power_assert (0.2.2)
10
+ power_assert (0.2.4)
11
11
  rake (10.4.2)
12
- test-unit (3.0.9)
12
+ test-unit (3.1.3)
13
13
  power_assert
14
14
 
15
15
  PLATFORMS
@@ -20,3 +20,6 @@ DEPENDENCIES
20
20
  net-ping!
21
21
  rake
22
22
  test-unit
23
+
24
+ BUNDLED WITH
25
+ 1.10.6
@@ -53,6 +53,7 @@ module Net
53
53
 
54
54
  Open3.popen3(*pcmd) do |stdin, stdout, stderr, thread|
55
55
  stdin.close
56
+ @end_time = Time.now
56
57
  err = stderr.gets # Can't chomp yet, might be nil
57
58
 
58
59
  case thread.value.exitstatus
@@ -90,7 +91,88 @@ module Net
90
91
  end
91
92
 
92
93
  # There is no duration if the ping failed
93
- @duration = Time.now - start_time if bool
94
+ @duration = @end_time - start_time if bool
95
+
96
+ bool
97
+ end
98
+
99
+ def ping6(host = @host, count = 1, interval = 1, timeout = @timeout)
100
+
101
+ raise "Count must be an integer" unless count.is_a? Integer
102
+ raise "Timeout must be a number" unless timeout.is_a? Numeric
103
+
104
+ unless interval.is_a?(Numeric) && interval >= 0.2
105
+ raise "Interval must be a decimal greater than or equal to 0.2"
106
+ end
107
+
108
+ super(host)
109
+
110
+ pcmd = ['ping6']
111
+ bool = false
112
+
113
+ case RbConfig::CONFIG['host_os']
114
+ when /linux/i
115
+ pcmd += ['-c', count.to_s, '-W', timeout.to_s, host, '-i', interval.to_s]
116
+ when /aix/i
117
+ pcmd += ['-c', count.to_s, '-w', timeout.to_s, host]
118
+ when /bsd|osx|mach|darwin/i
119
+ pcmd += ['-c', count.to_s, '-t', timeout.to_s, host]
120
+ when /solaris|sunos/i
121
+ pcmd += [host, timeout.to_s]
122
+ when /hpux/i
123
+ pcmd += [host, "-n#{count.to_s}", '-m', timeout.to_s]
124
+ when /win32|windows|msdos|mswin|cygwin|mingw/i
125
+ pcmd += ['-n', count.to_s, '-w', (timeout * 1000).to_s, host]
126
+ else
127
+ pcmd += [host]
128
+ end
129
+
130
+ start_time = Time.now
131
+
132
+ begin
133
+ err = nil
134
+
135
+ Open3.popen3(*pcmd) do |stdin, stdout, stderr, thread|
136
+ stdin.close
137
+ @end_time = Time.now
138
+ err = stderr.gets # Can't chomp yet, might be nil
139
+
140
+ case thread.value.exitstatus
141
+ when 0
142
+ info = stdout.read
143
+ if info =~ /unreachable/ix # Windows
144
+ bool = false
145
+ @exception = "host unreachable"
146
+ else
147
+ bool = true # Success, at least one response.
148
+ end
149
+
150
+ if err & err =~ /warning/i
151
+ @warning = err.chomp
152
+ end
153
+ when 2
154
+ bool = false # Transmission successful, no response.
155
+ @exception = err.chomp if err
156
+ else
157
+ bool = false # An error occurred
158
+ if err
159
+ @exception = err.chomp
160
+ else
161
+ stdout.each_line do |line|
162
+ if line =~ /(timed out|could not find host|packet loss)/i
163
+ @exception = line.chomp
164
+ break
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ rescue Exception => error
171
+ @exception = error.message
172
+ end
173
+
174
+ # There is no duration if the ping failed
175
+ @duration = @end_time - start_time if bool
94
176
 
95
177
  bool
96
178
  end
@@ -83,6 +83,13 @@ module Net
83
83
  @duration = nil
84
84
  end
85
85
 
86
+ def ping6(host = @host)
87
+ raise ArgumentError, 'no host specified' unless host
88
+ @exception = nil
89
+ @warning = nil
90
+ @duration = nil
91
+ end
92
+
86
93
  alias ping? ping
87
94
  alias pingecho ping
88
95
  end
@@ -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.7'
6
+ spec.version = '1.7.8'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.author = 'Chris Chernesky'
9
9
  spec.email = 'chris.netping@tinderglow.com'
metadata CHANGED
@@ -1,66 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.7
5
- prerelease:
4
+ version: 1.7.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Chernesky
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: test-unit
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: fakeweb
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
- description: ! " The net-ping library provides a ping interface for Ruby. It includes\n
63
- \ separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
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.
64
59
  email: chris.netping@tinderglow.com
65
60
  executables: []
66
61
  extensions: []
@@ -70,13 +65,17 @@ extra_rdoc_files:
70
65
  - doc/ping.txt
71
66
  files:
72
67
  - CHANGES
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - MANIFEST
71
+ - README.md
72
+ - Rakefile
73
73
  - doc/ping.txt
74
74
  - examples/example_pingexternal.rb
75
75
  - examples/example_pinghttp.rb
76
76
  - examples/example_pingtcp.rb
77
77
  - examples/example_pingudp.rb
78
- - Gemfile
79
- - Gemfile.lock
78
+ - lib/net/ping.rb
80
79
  - lib/net/ping/external.rb
81
80
  - lib/net/ping/http.rb
82
81
  - lib/net/ping/icmp.rb
@@ -84,11 +83,7 @@ files:
84
83
  - lib/net/ping/tcp.rb
85
84
  - lib/net/ping/udp.rb
86
85
  - lib/net/ping/wmi.rb
87
- - lib/net/ping.rb
88
- - MANIFEST
89
86
  - net-ping.gemspec
90
- - Rakefile
91
- - README.md
92
87
  - test/test_net_ping.rb
93
88
  - test/test_net_ping_external.rb
94
89
  - test/test_net_ping_http.rb
@@ -99,27 +94,26 @@ files:
99
94
  homepage: https://github.com/chernesk/net-ping
100
95
  licenses:
101
96
  - Artistic 2.0
97
+ metadata: {}
102
98
  post_install_message:
103
99
  rdoc_options: []
104
100
  require_paths:
105
101
  - lib
106
102
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
103
  requirements:
109
- - - ! '>='
104
+ - - ">="
110
105
  - !ruby/object:Gem::Version
111
106
  version: 1.9.3
112
107
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
108
  requirements:
115
- - - ! '>='
109
+ - - ">="
116
110
  - !ruby/object:Gem::Version
117
111
  version: '0'
118
112
  requirements: []
119
113
  rubyforge_project:
120
- rubygems_version: 1.8.23.2
114
+ rubygems_version: 2.2.2
121
115
  signing_key:
122
- specification_version: 3
116
+ specification_version: 4
123
117
  summary: A ping interface for Ruby.
124
118
  test_files:
125
119
  - test/test_net_ping.rb