lsof 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/lsof.rb +6 -0
  3. data/spec/lsof_spec.rb +15 -0
  4. metadata +6 -6
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "lsof"
29
- PKG_VERSION = "0.2.0"
29
+ PKG_VERSION = "0.3.0"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -8,6 +8,12 @@ class Lsof
8
8
  def running?(port)
9
9
  listener_pids(port).empty? ? false : true
10
10
  end
11
+
12
+ # this isn't really lsof, but it's solving the same problem
13
+ def running_remotely?(server, port)
14
+ TCPSocket.new(server, port).close rescue return false
15
+ return true
16
+ end
11
17
 
12
18
  def listener_pids(port)
13
19
  output = `#{find_pids_cmd(port)}`
@@ -66,9 +66,24 @@ describe Lsof do
66
66
  end
67
67
 
68
68
  it "when there is no process using the port, returns false" do
69
+ sleep 1
69
70
  Lsof.running?(port).should be_false
70
71
  end
71
72
  end
73
+
74
+ describe ".running_remotely?" do
75
+ it "should return true when there is a process on the port" do
76
+ start_process_using_port
77
+ Lsof.running_remotely?("localhost", port).should be_true
78
+ end
79
+
80
+ it "should return false when there is no process on the port" do
81
+ wait_for do
82
+ !Lsof.running_remotely?("localhost", port)
83
+ end
84
+ Lsof.running_remotely?("localhost", port).should be_false
85
+ end
86
+ end
72
87
 
73
88
  describe ".listener_pids" do
74
89
  it "when there is a process listening on a port, returns the process id in an Array" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Innis + Brian Takita
@@ -9,7 +9,7 @@ autorequire: lsof
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-22 00:00:00 -07:00
12
+ date: 2008-07-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,14 +23,14 @@ extra_rdoc_files:
23
23
  - README
24
24
  - CHANGES
25
25
  files:
26
- - Rakefile
27
26
  - CHANGES
27
+ - Rakefile
28
28
  - README
29
29
  - lib/lsof.rb
30
- - spec/spec_suite.rb
31
- - spec/spec_helper.rb
32
30
  - spec/fixtures/test_server.rb
33
31
  - spec/lsof_spec.rb
32
+ - spec/spec_helper.rb
33
+ - spec/spec_suite.rb
34
34
  has_rdoc: true
35
35
  homepage: http://pivotallabs.com
36
36
  post_install_message:
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements: []
57
57
 
58
58
  rubyforge_project: pivotalrb
59
- rubygems_version: 1.1.0
59
+ rubygems_version: 1.2.0
60
60
  signing_key:
61
61
  specification_version: 2
62
62
  summary: A library utilizing the lsof unix command for process management.