net-ping 1.7.8 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b64d1fdb2f212bd7212e479b46b84c5b7fb6015
4
- data.tar.gz: de13dd9eef7ec47b5625e56bf4f562950e6d79ef
3
+ metadata.gz: 17e2c148e3e4f0ac06b324b666351eb4f485e44c
4
+ data.tar.gz: b19d20fd8a675c101df2b4bffa9664800e60a7bb
5
5
  SHA512:
6
- metadata.gz: 224d9695832c1359e637c946d021c204b86ce94bd652ec3c597b414ea68e1098122c84f9a9bf839a3b91d4e23e2f492e7d4c3231d070051e10091ec6ca72fced
7
- data.tar.gz: 6635c45ac8bde019c7cf218e6fa96396bc7ee79323618156d3644349b313dad709e9034b970616d3ca20039a617202992aa8502278fbf4cd67a2f0c886d3f399
6
+ metadata.gz: 226c87f3679a0e5b22a164acc01f552c43734c215a675f54cf36754149ce400c8e23fc44559cf0f902c967850ab602ed1d0ee29f43727cc0f158cddedb9f804a
7
+ data.tar.gz: 236d2377a2419d400f78260337c0e892fa7a42d4599a9d5ca3c9534a9cec0ae45865c39bc6c184667e068edff2c3274ebbbd639b8c465b241abe9b4cb57df6a9
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- net-ping (1.7.8)
4
+ net-ping (1.7.7)
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.4)
11
- rake (10.4.2)
12
- test-unit (3.1.3)
10
+ power_assert (0.3.0)
11
+ rake (11.2.2)
12
+ test-unit (3.2.1)
13
13
  power_assert
14
14
 
15
15
  PLATFORMS
@@ -22,4 +22,4 @@ DEPENDENCIES
22
22
  test-unit
23
23
 
24
24
  BUNDLED WITH
25
- 1.10.6
25
+ 1.11.2
@@ -53,7 +53,6 @@ module Net
53
53
 
54
54
  Open3.popen3(*pcmd) do |stdin, stdout, stderr, thread|
55
55
  stdin.close
56
- @end_time = Time.now
57
56
  err = stderr.gets # Can't chomp yet, might be nil
58
57
 
59
58
  case thread.value.exitstatus
@@ -91,7 +90,7 @@ module Net
91
90
  end
92
91
 
93
92
  # There is no duration if the ping failed
94
- @duration = @end_time - start_time if bool
93
+ @duration = Time.now - start_time if bool
95
94
 
96
95
  bool
97
96
  end
@@ -134,7 +133,6 @@ module Net
134
133
 
135
134
  Open3.popen3(*pcmd) do |stdin, stdout, stderr, thread|
136
135
  stdin.close
137
- @end_time = Time.now
138
136
  err = stderr.gets # Can't chomp yet, might be nil
139
137
 
140
138
  case thread.value.exitstatus
@@ -172,7 +170,7 @@ module Net
172
170
  end
173
171
 
174
172
  # There is no duration if the ping failed
175
- @duration = @end_time - start_time if bool
173
+ @duration = Time.now - start_time if bool
176
174
 
177
175
  bool
178
176
  end
@@ -131,8 +131,6 @@ module Net
131
131
  bool
132
132
  end
133
133
 
134
- alias ping? ping
135
- alias pingecho ping
136
134
  alias follow_redirect? follow_redirect
137
135
  alias uri host
138
136
  alias uri= host=
@@ -147,13 +147,8 @@ module Net
147
147
 
148
148
  # There is no duration if the ping failed
149
149
  @duration = Time.now - start_time if bool
150
-
151
- return bool
152
150
  end
153
151
 
154
- alias ping? ping
155
- alias pingecho ping
156
-
157
152
  private
158
153
 
159
154
  # Perform a checksum on the message. This is the sum of all the short
@@ -89,8 +89,12 @@ module Net
89
89
  @warning = nil
90
90
  @duration = nil
91
91
  end
92
-
93
- alias ping? ping
92
+
93
+ def ping?(host = @host)
94
+ !!ping(host)
95
+ end
96
+
94
97
  alias pingecho ping
98
+
95
99
  end
96
100
  end
@@ -38,7 +38,6 @@ module Net
38
38
  super(host)
39
39
 
40
40
  bool = false
41
- start_time = Time.now
42
41
 
43
42
  # Failure here most likely means bad host, so just bail.
44
43
  begin
@@ -55,6 +54,8 @@ module Net
55
54
  # This may not be entirely necessary
56
55
  sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
57
56
 
57
+ start_time = Time.now
58
+
58
59
  begin
59
60
  # Where addr[0][3] is an IP address
60
61
  sock.connect_nonblock(Socket.pack_sockaddr_in(port, addr[0][3]))
@@ -95,13 +96,9 @@ module Net
95
96
 
96
97
  # There is no duration if the ping failed
97
98
  @duration = Time.now - start_time if bool
98
-
99
- bool
100
99
  end
101
100
 
102
- alias ping? ping
103
- alias pingecho ping
104
-
101
+
105
102
  # Class method aliases. DEPRECATED.
106
103
  class << self
107
104
  alias econnrefused service_check
@@ -113,7 +113,5 @@ module Net
113
113
  bool
114
114
  end
115
115
 
116
- alias ping? ping
117
- alias pingecho ping
118
116
  end
119
117
  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.8'
6
+ spec.version = '2.0.1'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.author = 'Chris Chernesky'
9
9
  spec.email = 'chris.netping@tinderglow.com'
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
17
17
  # The TCP Ping class requires this for non-blocking sockets.
18
18
  spec.required_ruby_version = ">= 1.9.3"
19
19
 
20
- spec.add_development_dependency('test-unit')
21
- spec.add_development_dependency('fakeweb')
22
- spec.add_development_dependency('rake')
20
+ spec.add_development_dependency('test-unit', '~> 0')
21
+ spec.add_development_dependency('fakeweb', '~> 0')
22
+ spec.add_development_dependency('rake', '~> 0')
23
23
 
24
24
  if File::ALT_SEPARATOR
25
25
  require 'rbconfig'
@@ -71,12 +71,12 @@ class TC_Net_Ping_HTTP < Test::Unit::TestCase
71
71
  assert_boolean(@bad.ping?)
72
72
  end
73
73
 
74
- test 'ping? is an alias for ping' do
75
- assert_alias_method(@http, :ping?, :ping)
74
+ test "ping? is inherited" do
75
+ assert_respond_to(@http, :ping?)
76
76
  end
77
77
 
78
- test 'pingecho is an alias for ping' do
79
- assert_alias_method(@http, :pingecho, :ping)
78
+ test "pingecho is inherited" do
79
+ assert_respond_to(@http, :pingecho)
80
80
  end
81
81
 
82
82
  test 'ping should succeed for a valid website' do
@@ -43,16 +43,16 @@ class TC_PingICMP < Test::Unit::TestCase
43
43
  assert_nothing_raised{ @icmp.ping(@host) }
44
44
  end
45
45
 
46
- test "icmp ping returns a boolean" do
46
+ test "icmp ping returns a float" do
47
47
  omit_if(@@jruby)
48
- assert_boolean(@icmp.ping)
49
- assert_boolean(@icmp.ping(@host))
48
+ assert_kind_of(Float, @icmp.ping)
49
+ assert_kind_of(Float, @icmp.ping(@host))
50
50
  end
51
51
 
52
52
  test "icmp ping of local host is successful" do
53
53
  omit_if(@@jruby)
54
54
  assert_true(Net::Ping::ICMP.new(@host).ping?)
55
- assert_true(Net::Ping::ICMP.new('192.168.0.1').ping?)
55
+ assert_true(Net::Ping::ICMP.new('127.0.0.1').ping?)
56
56
  end
57
57
 
58
58
  test "threaded icmp ping returns expected results" do
@@ -78,14 +78,12 @@ class TC_PingICMP < Test::Unit::TestCase
78
78
  threads.each{ |t| t.join }
79
79
  end
80
80
 
81
- test "ping? is an alias for ping" do
81
+ test "ping? is inherited" do
82
82
  assert_respond_to(@icmp, :ping?)
83
- assert_alias_method(@icmp, :ping?, :ping)
84
83
  end
85
84
 
86
- test "pingecho is an alias for ping" do
85
+ test "pingecho is inherited" do
87
86
  assert_respond_to(@icmp, :pingecho)
88
- assert_alias_method(@icmp, :pingecho, :ping)
89
87
  end
90
88
 
91
89
  test "icmp ping fails if host is invalid" do
@@ -171,7 +169,7 @@ class TC_PingICMP < Test::Unit::TestCase
171
169
  test "setting an odd data_size is valid" do
172
170
  omit_if(@@jruby)
173
171
  assert_nothing_raised{ @icmp.data_size = 57 }
174
- assert_boolean(@icmp.ping)
172
+ assert_kind_of(Float, @icmp.ping)
175
173
  end
176
174
 
177
175
  def teardown
@@ -26,14 +26,12 @@ class TC_Net_Ping_UDP < Test::Unit::TestCase
26
26
  assert_nothing_raised{ @udp.ping(@host) }
27
27
  end
28
28
 
29
- test "ping? is an alias for ping" do
29
+ test "ping? is inherited" do
30
30
  assert_respond_to(@udp, :ping?)
31
- assert_alias_method(@udp, :ping?, :ping)
32
31
  end
33
32
 
34
- test "pingecho is an alias for ping" do
33
+ test "pingecho is inherited" do
35
34
  assert_respond_to(@udp, :pingecho)
36
- assert_alias_method(@udp, :pingecho, :ping)
37
35
  end
38
36
 
39
37
  test "a successful udp ping returns true" do
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.8
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Chernesky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fakeweb
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: |2
@@ -111,9 +111,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.2.2
114
+ rubygems_version: 2.4.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: A ping interface for Ruby.
118
118
  test_files:
119
119
  - test/test_net_ping.rb
120
+ has_rdoc: