sys-proctree 0.0.6 → 0.0.7

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: 9f2fd67d73341b9078472eb29a51cf33e9317788
4
- data.tar.gz: 91854c83180d40be068a690a02efde7928f4e2bd
3
+ metadata.gz: df1c8486d02bbbe9244591fb6e80b3bba302fb98
4
+ data.tar.gz: d7d747fc7f315e3b3dc89ee426ec72db42404f42
5
5
  SHA512:
6
- metadata.gz: a4294ca6c6c9e1d2c585b7faf7523a036a6c6f13317741075bf2be5208ab59de9f20226289401a955ca33bdb23d7eaaa49f816c2e73ae1caec34f0905c05a6f5
7
- data.tar.gz: 32d65affe8bc96577cfab63e48d762fad934e23d6837ab854668e6d319d741a1f02baa4cb8e3325c8935234a072d599c75422adeeaeb9734b7bc4b79db3ec0cd
6
+ metadata.gz: 845c50ea5351baf0da3fa57d8ade1d4206ccc8cd3a6c589decde5fa435e27df54ed7aa4568c8a6d6d3895113b0b9168ee771c9e3bf317e79592abfdb72c05848
7
+ data.tar.gz: 4e6f5d069516106cfc1de331144aa40ca3e314b6350b3b9b7d5b91edefb8e944520648d7606abef1babd30d91b9215c80c031158003e19a95686b923ce55c1a4
@@ -5,12 +5,12 @@ module Sys
5
5
 
6
6
  def kill_tree(signal, pid)
7
7
  pids = ::Sys::ProcTree::Tree.find(pid)
8
- pids.collect do |pid|
8
+ pids.map do |pid|
9
9
  begin
10
10
  ::Process.kill(signal, pid)
11
11
  ::Process.wait(pid)
12
12
  rescue
13
- [pid, nil]
13
+ [ pid, nil ]
14
14
  end
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module Sys
6
6
  class << self
7
7
 
8
8
  def find(pid)
9
- ::Sys::ProcTree::Tree.new(pid).pids
9
+ self.new(pid).pids
10
10
  end
11
11
 
12
12
  end
@@ -1,5 +1,5 @@
1
1
  module Sys
2
2
  module ProcTree
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -9,57 +9,57 @@ describe ::Sys::ProcTree::Process do
9
9
  let(:kill_signal) { 7 }
10
10
  let(:tree_pids) { [2, 6, 8] }
11
11
 
12
- before(:each) do
13
- ::Sys::ProcTree::Tree.stub(:find).and_return([2, 6, 8])
14
- ::Process.stub(:kill)
15
- ::Process.stub(:wait)
12
+ before(:example) do
13
+ allow(::Sys::ProcTree::Tree).to receive(:find).and_return([2, 6, 8])
14
+ allow(::Process).to receive(:kill)
15
+ allow(::Process).to receive(:wait)
16
16
  end
17
17
 
18
18
  it "should discover the pids of the process tree" do
19
- ::Sys::ProcTree::Tree.should_receive(:find).with(8).and_return(tree_pids)
19
+ expect(::Sys::ProcTree::Tree).to receive(:find).with(8).and_return(tree_pids)
20
20
 
21
21
  TestableProcess.kill_tree(kill_signal, 8)
22
22
  end
23
23
 
24
24
  it "should attempt to kill each process with the provided kill signal in tree order" do
25
- tree_pids.each { |pid| ::Process.should_receive(:kill).with(kill_signal, pid) }
25
+ tree_pids.each { |pid| expect(::Process).to receive(:kill).with(kill_signal, pid) }
26
26
 
27
27
  TestableProcess.kill_tree(kill_signal, 8)
28
28
  end
29
29
 
30
30
 
31
31
  it "should wait for all processes to complete" do
32
- tree_pids.each { |pid| ::Process.should_receive(:wait).with(pid) }
32
+ tree_pids.each { |pid| expect(::Process).to receive(:wait).with(pid) }
33
33
 
34
34
  TestableProcess.kill_tree(kill_signal, 8)
35
35
  end
36
36
 
37
37
  it "should return the exit status of all killed processes" do
38
38
  wait_results = tree_pids.map do |pid|
39
- [pid, double(Process::Status)].tap { |result| ::Process.stub(:wait).with(pid).and_return(result) }
39
+ [pid, double(::Process::Status)].tap { |result| allow(::Process).to receive(:wait).with(pid).and_return(result) }
40
40
  end
41
41
 
42
- TestableProcess.kill_tree(kill_signal, 8).should eql(wait_results)
42
+ expect(TestableProcess.kill_tree(kill_signal, 8)).to eql(wait_results)
43
43
  end
44
44
 
45
45
  describe "when a process has already been killed" do
46
46
 
47
47
  let(:kill_signal) { 9 }
48
48
 
49
- before(:each) { ::Process.stub(:kill).with(kill_signal, 6).and_raise("No such process") }
49
+ before(:example) { allow(::Process).to receive(:kill).with(kill_signal, 6).and_raise("No such process") }
50
50
 
51
51
  it "should continue to kill subsequent processes" do
52
- [2, 8].each { |pid| ::Process.should_receive(:kill).with(kill_signal, pid) }
52
+ [2, 8].each { |pid| expect(::Process).to receive(:kill).with(kill_signal, pid) }
53
53
 
54
54
  TestableProcess.kill_tree(kill_signal, 8)
55
55
  end
56
56
 
57
57
  it "should return an exit status of nil" do
58
- wait_results = [[2, double(Process::Status)], [6, nil], [8, double(Process::Status)]]
59
- ::Process.stub(:wait).with(2).and_return(wait_results[0])
60
- ::Process.stub(:wait).with(8).and_return(wait_results[2])
58
+ wait_results = [[2, double(::Process::Status)], [6, nil], [8, double(::Process::Status)]]
59
+ allow(::Process).to receive(:wait).with(2).and_return(wait_results[0])
60
+ allow(::Process).to receive(:wait).with(8).and_return(wait_results[2])
61
61
 
62
- TestableProcess.kill_tree(kill_signal, 8).should eql(wait_results)
62
+ expect(TestableProcess.kill_tree(kill_signal, 8)).to eql(wait_results)
63
63
  end
64
64
 
65
65
  end
@@ -1,6 +1,6 @@
1
1
  describe ::Sys::ProcTree::ProcessStatusList do
2
2
 
3
- before(:each) { ::Sys::ProcTable.stub(:ps).and_return(proc_list) }
3
+ before(:example) { allow(::Sys::ProcTable).to receive(:ps).and_return(proc_list) }
4
4
 
5
5
  let(:proc_list) do
6
6
  [double("ProcTableStruct", pid: 1, ppid: 2),
@@ -11,13 +11,13 @@ describe ::Sys::ProcTree::ProcessStatusList do
11
11
  let(:list) { ::Sys::ProcTree::ProcessStatusList.new }
12
12
 
13
13
  it "should be an array" do
14
- list.should be_an(Array)
14
+ expect(list).to be_an(Array)
15
15
  end
16
16
 
17
17
  it "should contain proc table process status results" do
18
- ::Sys::ProcTable.should_receive(:ps).and_return(proc_list)
18
+ expect(::Sys::ProcTable).to receive(:ps).and_return(proc_list)
19
19
 
20
- list.should eql(proc_list)
20
+ expect(list).to eql(proc_list)
21
21
  end
22
22
 
23
23
  describe "exists?" do
@@ -27,7 +27,7 @@ describe ::Sys::ProcTree::ProcessStatusList do
27
27
  let(:pid) { 2 }
28
28
 
29
29
  it "should return true" do
30
- list.exists?(pid).should be_true
30
+ expect(list.exists?(pid)).to be(true)
31
31
  end
32
32
 
33
33
  end
@@ -37,7 +37,7 @@ describe ::Sys::ProcTree::ProcessStatusList do
37
37
  let(:pid) { -1 }
38
38
 
39
39
  it "should return false" do
40
- list.exists?(pid).should be_false
40
+ expect(list.exists?(pid)).to be(false)
41
41
  end
42
42
 
43
43
  end
@@ -4,9 +4,7 @@ describe ::Sys::ProcTree::Tree do
4
4
 
5
5
  describe "#find" do
6
6
 
7
- before(:each) do
8
- ::Sys::ProcTree::ProcessStatusList.should_receive(:new).and_return(process_status_list)
9
- end
7
+ before(:example) { allow(::Sys::ProcTree::ProcessStatusList).to receive(:new).and_return(process_status_list) }
10
8
 
11
9
  let(:process_status_list) do
12
10
  create_proc_table_entries([{ pid: 2, ppid: 1 },
@@ -21,7 +19,7 @@ describe ::Sys::ProcTree::Tree do
21
19
 
22
20
  describe "when the provided process exists" do
23
21
 
24
- before(:each) { process_status_list.stub(:exists?).with(pid).and_return(true) }
22
+ before(:example) { allow(process_status_list).to receive(:exists?).with(pid).and_return(true) }
25
23
 
26
24
  describe "when the tree is more than one level deep" do
27
25
 
@@ -29,8 +27,8 @@ describe ::Sys::ProcTree::Tree do
29
27
 
30
28
  let(:pid) { 1 }
31
29
 
32
- it "should return an array representing the tree in order from child first to parent last" do
33
- tree.find(pid).should eql([3, 2, 1])
30
+ it "returns an array representing the tree in order from child first to parent last" do
31
+ expect(tree.find(pid)).to eql([3, 2, 1])
34
32
  end
35
33
 
36
34
  end
@@ -39,8 +37,8 @@ describe ::Sys::ProcTree::Tree do
39
37
 
40
38
  let(:pid) { 6 }
41
39
 
42
- it "should return an array containing processes order from child to parent, then as they appear in the underlying process table" do
43
- tree.find(pid).should eql([5, 7, 8, 6])
40
+ it "returns an array containing processes order from child to parent, then as they appear in the underlying process table" do
41
+ expect(tree.find(pid)).to eql([5, 7, 8, 6])
44
42
  end
45
43
 
46
44
  end
@@ -51,10 +49,10 @@ describe ::Sys::ProcTree::Tree do
51
49
 
52
50
  describe "when the provided process does not exist" do
53
51
 
54
- before(:each) { process_status_list.stub(:exists?).and_return(false) }
52
+ before(:example) { allow(process_status_list).to receive(:exists?).and_return(false) }
55
53
 
56
- it "should return an empty array" do
57
- tree.find(0).should be_empty
54
+ it "returns an empty array" do
55
+ expect(tree.find(0)).to be_empty
58
56
  end
59
57
 
60
58
  end
@@ -2,10 +2,10 @@ describe ::Sys::ProcTree do
2
2
 
3
3
  describe "#find" do
4
4
 
5
- it "should find a tree via a Sys::ProcTree::Tree" do
6
- ::Sys::ProcTree::Tree.should_receive(:find).with(7).and_return([1, 3, 7])
5
+ it "finds a tree via a Sys::ProcTree::Tree" do
6
+ allow(::Sys::ProcTree::Tree).to receive(:find).with(7).and_return([1, 3, 7])
7
7
 
8
- ::Sys::ProcTree.find(7).should eql([1, 3, 7])
8
+ expect(::Sys::ProcTree.find(7)).to eql([1, 3, 7])
9
9
  end
10
10
 
11
11
  end
@@ -10,7 +10,7 @@ describe ::Process, "integrating with real processes" do
10
10
 
11
11
  let(:pid) { ::Process.spawn("irb") }
12
12
 
13
- it "should kill the process" do
13
+ it "kills the process" do
14
14
  ::Process.kill_tree(9, pid)
15
15
 
16
16
  wait_until_killed([pid])
@@ -22,11 +22,11 @@ describe ::Process, "integrating with real processes" do
22
22
 
23
23
  let(:ppid) { start_multiple_processes }
24
24
 
25
- before(:each) do
25
+ before(:example) do
26
26
  wait_until_true("process tree has started") { ::Sys::ProcTree::Tree.find(ppid).length == 3 }
27
27
  end
28
28
 
29
- it "should kill all processes in the tree" do
29
+ it "kills all processes in the tree" do
30
30
  tree_pids = ::Sys::ProcTree::Tree.find(ppid)
31
31
 
32
32
  ::Process.kill_tree(9, ppid)
data/spec/process_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  describe ::Process do
2
2
 
3
- it "should have the capability to kill a process tree" do
4
- ::Process.should be_a(::Sys::ProcTree::Process)
3
+ it "has the ability to kill a process tree" do
4
+ expect(::Process).to be_a(::Sys::ProcTree::Process)
5
5
  end
6
6
 
7
7
  end
metadata CHANGED
@@ -1,136 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-proctree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sys-proctable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
19
+ version: 0.9.0
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0.9'
29
+ version: 0.9.0
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: travis-lint
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '1.7'
39
+ version: '2.0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.7'
46
+ version: '2.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: metric_fu
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '4.7'
53
+ version: '4.11'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '4.7'
60
+ version: '4.11'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ~>
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '2.14'
67
+ version: '3.2'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ~>
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '2.14'
74
+ version: '3.2'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: os
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ~>
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
81
  version: '0.9'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ~>
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0.9'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ~>
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '10.1'
95
+ version: '10.4'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ~>
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '10.1'
102
+ version: '10.4'
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: simplecov
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ~>
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0.8'
109
+ version: '0.9'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ~>
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0.8'
116
+ version: '0.9'
111
117
  description: Discovers and kills process trees via process lists provided by the sys-proctable
112
118
  gem
113
- email: matthew.ueckerman@myob.com
119
+ email: " matthew.ueckerman@myob.com "
114
120
  executables: []
115
121
  extensions: []
116
122
  extra_rdoc_files: []
117
123
  files:
118
- - ./lib/sys/proctree.rb
119
- - ./lib/sys/proctree/process.rb
120
- - ./lib/sys/proctree/process_status_list.rb
121
- - ./lib/sys/proctree/tree.rb
122
- - ./lib/sys/proctree/version.rb
123
- - ./spec/lib/sys/proctree/process_spec.rb
124
- - ./spec/lib/sys/proctree/process_status_list_spec.rb
125
- - ./spec/lib/sys/proctree/tree_spec.rb
126
- - ./spec/lib/sys/proctree_spec.rb
127
- - ./spec/process_integration_spec.rb
128
- - ./spec/process_spec.rb
129
- - ./spec/resources/start_child.bat
130
- - ./spec/resources/start_child.sh
131
- - ./spec/resources/start_parent.bat
132
- - ./spec/resources/start_parent.sh
133
- - ./spec/spec_helper.rb
124
+ - "./lib/sys/proctree.rb"
125
+ - "./lib/sys/proctree/process.rb"
126
+ - "./lib/sys/proctree/process_status_list.rb"
127
+ - "./lib/sys/proctree/tree.rb"
128
+ - "./lib/sys/proctree/version.rb"
129
+ - "./spec/lib/sys/proctree/process_spec.rb"
130
+ - "./spec/lib/sys/proctree/process_status_list_spec.rb"
131
+ - "./spec/lib/sys/proctree/tree_spec.rb"
132
+ - "./spec/lib/sys/proctree_spec.rb"
133
+ - "./spec/process_integration_spec.rb"
134
+ - "./spec/process_spec.rb"
135
+ - "./spec/resources/start_child.bat"
136
+ - "./spec/resources/start_child.sh"
137
+ - "./spec/resources/start_parent.bat"
138
+ - "./spec/resources/start_parent.sh"
139
+ - "./spec/spec_helper.rb"
134
140
  homepage: http://github.com/MYOB-Technology/sys-proctree
135
141
  licenses:
136
142
  - MIT
@@ -141,29 +147,29 @@ require_paths:
141
147
  - lib
142
148
  required_ruby_version: !ruby/object:Gem::Requirement
143
149
  requirements:
144
- - - '>='
150
+ - - ">="
145
151
  - !ruby/object:Gem::Version
146
152
  version: 1.9.3
147
153
  required_rubygems_version: !ruby/object:Gem::Requirement
148
154
  requirements:
149
- - - '>='
155
+ - - ">="
150
156
  - !ruby/object:Gem::Version
151
157
  version: '0'
152
158
  requirements: []
153
159
  rubyforge_project: sys-proctree
154
- rubygems_version: 2.2.1
160
+ rubygems_version: 2.4.6
155
161
  signing_key:
156
162
  specification_version: 4
157
163
  summary: Discovers and can attempt to lay waste to a process tree
158
164
  test_files:
159
- - ./spec/lib/sys/proctree/process_spec.rb
160
- - ./spec/lib/sys/proctree/process_status_list_spec.rb
161
- - ./spec/lib/sys/proctree/tree_spec.rb
162
- - ./spec/lib/sys/proctree_spec.rb
163
- - ./spec/process_integration_spec.rb
164
- - ./spec/process_spec.rb
165
- - ./spec/resources/start_child.bat
166
- - ./spec/resources/start_child.sh
167
- - ./spec/resources/start_parent.bat
168
- - ./spec/resources/start_parent.sh
169
- - ./spec/spec_helper.rb
165
+ - "./spec/lib/sys/proctree/process_spec.rb"
166
+ - "./spec/lib/sys/proctree/process_status_list_spec.rb"
167
+ - "./spec/lib/sys/proctree/tree_spec.rb"
168
+ - "./spec/lib/sys/proctree_spec.rb"
169
+ - "./spec/process_integration_spec.rb"
170
+ - "./spec/process_spec.rb"
171
+ - "./spec/resources/start_child.bat"
172
+ - "./spec/resources/start_child.sh"
173
+ - "./spec/resources/start_parent.bat"
174
+ - "./spec/resources/start_parent.sh"
175
+ - "./spec/spec_helper.rb"