net-ping 2.0.8 → 2.0.9

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
- SHA1:
3
- metadata.gz: e9436106f779445d897726f1fc77636c9a1b4c11
4
- data.tar.gz: f5e7497bb832da92f13a9c042daef2007416dec4
2
+ SHA256:
3
+ metadata.gz: c3139e0db447950138a58ab9e60996ef49a89fc89e157ef1b66bf67ef5557450
4
+ data.tar.gz: 7529e34db8bf6d258a830fd725969af4dd6eee3ee59a500423e1f13256372079
5
5
  SHA512:
6
- metadata.gz: 20d939475ab877628d7b4730054583533e3f148c8e179abe000c743c7f538e381df82d9b76f67be2a98ace8a9f5ee1edc92acae6c2b5a4f050bcdca345efb9da
7
- data.tar.gz: d4b67f90593db6045162d533b73fb520075997ec7db028a1c5c07686b2062cda1e436c71649270d30a4f6510575a92b992d007dac00f4809030752d1d3ef7893
6
+ metadata.gz: '0947a086f3da9bb83a81f16e84d4e5fa761508f6a71109051e2ec315c972c83806085863a67d4cc5299e7c337a8ecef9f4bf8aa4afd907064bbd589dc9ff7966'
7
+ data.tar.gz: d16d032dcea9783d50305592c6dd4242436a1357f73233b2af787fafc68a03c6d408f5c1d3b328b2cc62395a7f7f64acd8ca4915fee647154fbb25b0474f98eb
data/CHANGES CHANGED
@@ -1 +1,12 @@
1
- Updated changes coming soon..
1
+ == 2.0.9 - 25-Jul-2026
2
+ * Add GitHub Actions CI [#33](https://github.com/eitoball/net-ping/pull/33)
3
+ and update its supported Ruby versions [#38](https://github.com/eitoball/net-ping/pull/38).
4
+ * Replace FakeWeb with WebMock and update the test suite for current Ruby
5
+ versions [#38](https://github.com/eitoball/net-ping/pull/38).
6
+ * Skip external-ping tests when the system ping command is unavailable
7
+ [#33](https://github.com/eitoball/net-ping/pull/33).
8
+ * Fix the macOS ping6 interval option
9
+ [#40](https://github.com/eitoball/net-ping/pull/40).
10
+ * Update README wording [#30](https://github.com/eitoball/net-ping/pull/30).
11
+ * Align Net::Ping::VERSION with the gem version
12
+ [#37](https://github.com/eitoball/net-ping/pull/37).
data/Gemfile.lock CHANGED
@@ -1,35 +1,53 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- net-ping (2.0.8)
4
+ net-ping (2.0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- byebug (11.0.1)
10
- coderay (1.1.2)
11
- fakeweb (1.3.0)
12
- method_source (0.9.2)
13
- power_assert (1.1.5)
14
- pry (0.12.2)
15
- coderay (~> 1.1.0)
16
- method_source (~> 0.9.0)
17
- pry-byebug (3.7.0)
18
- byebug (~> 11.0)
19
- pry (~> 0.10)
20
- rake (13.0.1)
21
- test-unit (3.3.5)
9
+ addressable (2.9.0)
10
+ public_suffix (>= 2.0.2, < 8.0)
11
+ bigdecimal (4.1.2)
12
+ byebug (13.0.0)
13
+ reline (>= 0.6.0)
14
+ coderay (1.1.3)
15
+ crack (1.0.1)
16
+ bigdecimal
17
+ rexml
18
+ hashdiff (1.2.1)
19
+ io-console (0.8.2)
20
+ method_source (1.1.0)
21
+ power_assert (3.0.1)
22
+ pry (0.16.0)
23
+ coderay (~> 1.1)
24
+ method_source (~> 1.0)
25
+ reline (>= 0.6.0)
26
+ pry-byebug (3.12.0)
27
+ byebug (~> 13.0)
28
+ pry (>= 0.13, < 0.17)
29
+ public_suffix (7.0.5)
30
+ rake (13.4.2)
31
+ reline (0.6.3)
32
+ io-console (~> 0.5)
33
+ rexml (3.4.4)
34
+ test-unit (3.7.8)
22
35
  power_assert
36
+ webmock (3.26.2)
37
+ addressable (>= 2.8.0)
38
+ crack (>= 0.3.2)
39
+ hashdiff (>= 0.4.0, < 2.0.0)
23
40
 
24
41
  PLATFORMS
25
42
  ruby
43
+ x86_64-darwin-24
26
44
 
27
45
  DEPENDENCIES
28
- fakeweb
29
46
  net-ping!
30
47
  pry-byebug
31
48
  rake
32
49
  test-unit
50
+ webmock
33
51
 
34
52
  BUNDLED WITH
35
- 2.1.4
53
+ 2.5.22
data/README.md CHANGED
@@ -4,7 +4,7 @@ A collection of classes that provide different ways to ping computers.
4
4
  ## Prerequisites
5
5
  * ffi
6
6
  * win32-security (MS Windows only)
7
- * fakeweb (test only)
7
+ * webmock (test only)
8
8
  * test-unit (test only)
9
9
 
10
10
  Ruby users should use Ruby 1.9.3 or later.
@@ -50,7 +50,7 @@ A collection of classes that provide different ways to ping computers.
50
50
 
51
51
  ## Contributions
52
52
  Although this library is free, please consider having your company
53
- setup a gittip if used by your company professionally.
53
+ set up a gittip if used by your company professionally.
54
54
 
55
55
  http://www.gittip.com/djberg96/
56
56
 
@@ -117,7 +117,7 @@ module Net
117
117
  when /aix/i
118
118
  pcmd += ['-c', count.to_s, '-w', timeout.to_s, host]
119
119
  when /bsd|osx|mach|darwin/i
120
- pcmd += ['-c', count.to_s, '-t', timeout.to_s, host]
120
+ pcmd += ['-c', count.to_s, '-i', interval.to_s, host]
121
121
  when /solaris|sunos/i
122
122
  pcmd += [host, timeout.to_s]
123
123
  when /hpux/i
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.6'
13
+ VERSION = '2.0.9'
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
@@ -1,9 +1,8 @@
1
- require 'rubygems'
2
1
  require 'rbconfig'
3
2
 
4
3
  Gem::Specification.new do |spec|
5
4
  spec.name = 'net-ping'
6
- spec.version = '2.0.8'
5
+ spec.version = '2.0.9'
7
6
  spec.license = 'Artistic 2.0'
8
7
  spec.author = 'Chris Chernesky'
9
8
  spec.email = 'chris.netping@tinderglow.com'
@@ -25,7 +24,7 @@ Gem::Specification.new do |spec|
25
24
  spec.required_ruby_version = ">= 1.9.3"
26
25
 
27
26
  spec.add_development_dependency('test-unit', '>= 0')
28
- spec.add_development_dependency('fakeweb', '>= 0')
27
+ spec.add_development_dependency('webmock', '>= 0')
29
28
  spec.add_development_dependency('rake', '>= 0')
30
29
  spec.add_development_dependency('pry-byebug', '>= 0')
31
30
 
@@ -37,8 +36,8 @@ Gem::Specification.new do |spec|
37
36
 
38
37
  # Used for icmp pings.
39
38
  spec.add_dependency('win32-security', '>= 0.2.0')
40
- spec.add_dependency('cap2', '>= 0.2.2')
41
39
  end
40
+ spec.add_dependency('cap2', '>= 0.2.2') if RUBY_PLATFORM =~ /linux/i
42
41
 
43
42
  spec.description = <<-EOF
44
43
  The net-ping library provides a ping interface for Ruby. It includes
@@ -8,7 +8,6 @@ require 'test_net_ping_external'
8
8
  require 'test_net_ping_http'
9
9
  require 'test_net_ping_tcp'
10
10
  require 'test_net_ping_udp'
11
- require 'fakeweb'
12
11
 
13
12
  if File::ALT_SEPARATOR
14
13
  require 'win32/security'
@@ -39,8 +38,6 @@ end
39
38
 
40
39
  class TC_Net_Ping < Test::Unit::TestCase
41
40
  def test_net_ping_version
42
- assert_equal('1.7.6', Net::Ping::VERSION)
41
+ assert_equal('2.0.9', Net::Ping::VERSION)
43
42
  end
44
43
  end
45
-
46
- FakeWeb.allow_net_connect = false
@@ -10,6 +10,8 @@
10
10
  #########################################################################
11
11
  require 'test-unit'
12
12
  require 'net/ping/external'
13
+ require 'mkmf'
14
+ require 'stringio'
13
15
 
14
16
  class TC_Net_Ping_External < Test::Unit::TestCase
15
17
  def setup
@@ -47,6 +49,7 @@ class TC_Net_Ping_External < Test::Unit::TestCase
47
49
  end
48
50
 
49
51
  test "pinging a good host returns true" do
52
+ omit_if(find_executable0('ping').nil?)
50
53
  assert_true(@pe.ping?)
51
54
  end
52
55
 
@@ -55,12 +58,14 @@ class TC_Net_Ping_External < Test::Unit::TestCase
55
58
  end
56
59
 
57
60
  test "duration basic functionality" do
61
+ omit_if(find_executable0('ping').nil?)
58
62
  assert_nothing_raised{ @pe.ping }
59
63
  assert_respond_to(@pe, :duration)
60
64
  assert_kind_of(Float, @pe.duration)
61
65
  end
62
66
 
63
67
  test "duration is unset if a bad ping follows a good ping" do
68
+ omit_if(find_executable0('ping').nil?)
64
69
  assert_nothing_raised{ @pe.ping }
65
70
  assert_not_nil(@pe.duration)
66
71
  assert_false(@pe.ping?(@bogus))
@@ -111,6 +116,7 @@ class TC_Net_Ping_External < Test::Unit::TestCase
111
116
  end
112
117
 
113
118
  test "pinging a good host results in no exception data" do
119
+ omit_if(find_executable0('ping').nil?)
114
120
  assert_nothing_raised{ @pe.ping }
115
121
  assert_nil(@pe.exception)
116
122
  end
@@ -134,6 +140,30 @@ class TC_Net_Ping_External < Test::Unit::TestCase
134
140
  assert_false(@bad.ping?)
135
141
  end
136
142
 
143
+ test "ping6 uses interval for macOS" do
144
+ command = nil
145
+ original_os = RbConfig::CONFIG['host_os']
146
+ original_popen3 = Open3.method(:popen3)
147
+
148
+ RbConfig::CONFIG['host_os'] = 'darwin'
149
+ Open3.define_singleton_method(:popen3) do |*args, &block|
150
+ command = args
151
+ stdin = StringIO.new
152
+ stdout = StringIO.new
153
+ stderr = StringIO.new
154
+ status = Struct.new(:exitstatus).new(0)
155
+ thread = Struct.new(:value).new(status)
156
+ block.call(stdin, stdout, stderr, thread)
157
+ end
158
+
159
+ @pe.ping6('example.test', 2, 3, 4)
160
+
161
+ assert_equal(['ping6', '-c', '2', '-i', '3', 'example.test'], command)
162
+ ensure
163
+ RbConfig::CONFIG['host_os'] = original_os
164
+ Open3.define_singleton_method(:popen3, original_popen3)
165
+ end
166
+
137
167
  def teardown
138
168
  @host = nil
139
169
  @bogus = nil
@@ -5,7 +5,7 @@
5
5
  # 'test:http' Rake task.
6
6
  #################################################################################
7
7
  require 'test-unit'
8
- require 'fakeweb'
8
+ require 'webmock/test_unit'
9
9
  require 'net/ping/http'
10
10
 
11
11
  class TC_Net_Ping_HTTP < Test::Unit::TestCase
@@ -17,27 +17,24 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
17
17
  @uri_http_domain_scheme = 'http://http.com'
18
18
  @uri_http_domain_schemes = 'https://http.com'
19
19
  @proxy = 'http://username:password@proxymoxie:3128'
20
- FakeWeb.allow_net_connect = false
21
-
22
- FakeWeb.register_uri(:get, @uri, :body => "PONG")
23
- FakeWeb.register_uri(:head, @uri, :body => "PONG")
24
- FakeWeb.register_uri(:head, @uri_https, :body => "PONG")
25
- FakeWeb.register_uri(:get, @uri_https, :body => "PONG")
26
- FakeWeb.register_uri(:get, "http://#{@uri_http_domain}", :body => "PONG")
27
- FakeWeb.register_uri(:head, "http://#{@uri_http_domain}", :body => "PONG")
28
- FakeWeb.register_uri(:get, @uri_http_domain_scheme, :body => "PONG")
29
- FakeWeb.register_uri(:head, @uri_http_domain_scheme, :body => "PONG")
30
- FakeWeb.register_uri(:get, @uri_http_domain_schemes, :body => "PONG")
31
- FakeWeb.register_uri(:head, @uri_http_domain_schemes, :body => "PONG")
32
- FakeWeb.register_uri(:head, "http://jigsaw.w3.org/HTTP/300/302.html",
33
- :body => "PONG",
34
- :location => "#{@uri}",
35
- :status => ["302", "Found"])
36
-
37
- FakeWeb.register_uri(:any, 'http://www.blabfoobarurghxxxx.com', :exception => SocketError)
38
- FakeWeb.register_uri(:head, 'http://http502.com',
39
- :body => "",
40
- :status => ["502", "Bad Gateway"])
20
+ WebMock.disable_net_connect!
21
+
22
+ stub_request(:get, @uri).to_return(body: "PONG")
23
+ stub_request(:head, @uri).to_return(body: "PONG")
24
+ stub_request(:head, @uri_https).to_return(body: "PONG")
25
+ stub_request(:get, @uri_https).to_return(body: "PONG")
26
+ stub_request(:get, "http://#{@uri_http_domain}").to_return(body: "PONG")
27
+ stub_request(:head, "http://#{@uri_http_domain}").to_return(body: "PONG")
28
+ stub_request(:get, @uri_http_domain_scheme).to_return(body: "PONG")
29
+ stub_request(:head, @uri_http_domain_scheme).to_return(body: "PONG")
30
+ stub_request(:get, @uri_http_domain_schemes).to_return(body: "PONG")
31
+ stub_request(:head, @uri_http_domain_schemes).to_return(body: "PONG")
32
+
33
+ stub_request(:head, "https://jigsaw.w3.org/HTTP/300/302.html")
34
+ .to_return(body: "PONG", status: ["302", "Found"], headers: { 'location' => "#{@uri}" })
35
+
36
+ stub_request(:any, "http://www.blabfoobarurghxxxx.com").to_raise(SocketError)
37
+ stub_request(:head, "http://http502.com").to_return(body: "", status: ["502", "Bad Gateway"])
41
38
 
42
39
  @http = Net::Ping::HTTP.new(@uri, 80, 30)
43
40
  @http_http_domain = Net::Ping::HTTP.new(@uri_http_domain, 80, 30)
@@ -120,7 +117,7 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
120
117
 
121
118
  test 'port attribute is set to expected value' do
122
119
  assert_equal(80, @http.port)
123
- assert_equal(443, Net::Ping::HTTP.new('https://github.com/path').port)
120
+ assert_equal(443, Net::Ping::HTTP.new('https://github.com/github').port)
124
121
  assert_equal(80, Net::Ping::HTTP.new.port)
125
122
  end
126
123
 
@@ -134,12 +131,12 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
134
131
  assert_equal(5, @bad.timeout)
135
132
  end
136
133
 
137
- # TODO: Figure out how to do this with FakeWeb.
134
+ # TODO: Figure out how to do this with WebMock.
138
135
  test 'ping fails if timeout exceeded' do
139
- FakeWeb.allow_net_connect = true
140
- @http = Net::Ping::HTTP.new('https://github.com/path', 80, 0.01)
136
+ WebMock.allow_net_connect!
137
+ @http = Net::Ping::HTTP.new('https://www.google.com', 443, 0.001)
141
138
  assert_false(@http.ping?)
142
- assert_equal('execution expired', @http.exception)
139
+ assert(['Failed to open TCP connection to www.google.com:443 (execution expired)', 'execution expired', 'Net::OpenTimeout'].include?(@http.exception))
143
140
  end
144
141
 
145
142
  test 'exception attribute basic functionality' do
@@ -179,7 +176,7 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
179
176
  test 'ping with user agent' do
180
177
  @http.user_agent = "KDDI-CA32"
181
178
  assert_true(@http.ping)
182
- assert_equal("KDDI-CA32", FakeWeb.last_request["user-agent"])
179
+ assert_requested(:any, @uri, headers: { "User-Agent" => "KDDI-CA32" }, times: 1)
183
180
  end
184
181
 
185
182
  test 'redirect_limit accessor is defined' do
@@ -192,18 +189,18 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
192
189
  end
193
190
 
194
191
  test 'redirects succeed by default' do
195
- @http = Net::Ping::HTTP.new("http://jigsaw.w3.org/HTTP/300/302.html")
192
+ @http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
196
193
  assert_true(@http.ping)
197
194
  end
198
195
 
199
196
  test 'redirect fail if follow_redirect is set to false' do
200
- @http = Net::Ping::HTTP.new("http://jigsaw.w3.org/HTTP/300/302.html")
197
+ @http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
201
198
  @http.follow_redirect = false
202
199
  assert_false(@http.ping)
203
200
  end
204
201
 
205
202
  test 'ping with redirect limit set to zero fails' do
206
- @http = Net::Ping::HTTP.new("http://jigsaw.w3.org/HTTP/300/302.html")
203
+ @http = Net::Ping::HTTP.new("https://jigsaw.w3.org/HTTP/300/302.html")
207
204
  @http.redirect_limit = 0
208
205
  assert_false(@http.ping)
209
206
  assert_equal("Redirect limit exceeded", @http.exception)
@@ -43,7 +43,7 @@ class TC_PingICMP < Test::Unit::TestCase
43
43
  def setup
44
44
  @host = '127.0.0.1' # 'localhost'
45
45
  @icmp = Net::Ping::ICMP.new(@host)
46
- @concurrency = 3
46
+ @concurrency = 2
47
47
  end
48
48
 
49
49
  test "icmp ping basic functionality" do
@@ -71,7 +71,8 @@ class TC_PingICMP < Test::Unit::TestCase
71
71
 
72
72
  test "threaded icmp ping returns expected results" do
73
73
  omit_if(@@jruby)
74
- ips = ['8.8.4.4', '8.8.9.9', '127.0.0.1', '8.8.8.8', '8.8.8.9']
74
+ # ips = ['8.8.4.4', '8.8.9.9', '127.0.0.1', '8.8.8.8', '8.8.8.9']
75
+ ips = ['127.0.0.1', '8.8.8.9']
75
76
  queue = Queue.new
76
77
  threads = []
77
78
 
@@ -81,10 +82,10 @@ class TC_PingICMP < Test::Unit::TestCase
81
82
  threads << Thread.new(queue) do |q|
82
83
  ip = q.pop
83
84
  icmp = Net::Ping::ICMP.new(ip, nil, 1)
84
- if ip =~ /9/
85
- assert_false(icmp.ping?)
85
+ if ip =~ /\.9$/
86
+ assert_false(icmp.ping?, "#{ip} should not be pingable")
86
87
  else
87
- assert_true(icmp.ping?)
88
+ assert_true(icmp.ping?, "#{ip} should be pingable")
88
89
  end
89
90
  end
90
91
  }
@@ -91,7 +91,8 @@ class TC_PingTCP < Test::Unit::TestCase
91
91
  msg = "+this test may fail depending on your network environment+"
92
92
  assert_respond_to(@tcp, :exception)
93
93
  assert_nothing_raised{ @tcp.ping }
94
- assert_nil(@tcp.exception, msg)
94
+ # XXX: In some environment, it will get some execption
95
+ assert(@tcp.exception.nil? || @tcp.exception == Errno::ECONNREFUSED, msg)
95
96
  end
96
97
 
97
98
  def test_warning
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: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Chernesky
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2026-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: fakeweb
28
+ name: webmock
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -115,7 +115,7 @@ metadata:
115
115
  documentation_uri: https://www.rubydoc.info/gems/net-ping
116
116
  homepage_uri: https://github.com/chernesk/net-ping
117
117
  source_code_uri: https://github.com/chernesk/net-ping
118
- post_install_message:
118
+ post_install_message:
119
119
  rdoc_options: []
120
120
  require_paths:
121
121
  - lib
@@ -130,9 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.5.2.3
135
- signing_key:
133
+ rubygems_version: 3.5.22
134
+ signing_key:
136
135
  specification_version: 4
137
136
  summary: A ping interface for Ruby.
138
137
  test_files: