die 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/die.gemspec +1 -1
- data/lib/die.rb +10 -10
- data/test/test_die.rb +7 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/die.gemspec
CHANGED
data/lib/die.rb
CHANGED
@@ -6,7 +6,7 @@ class Die
|
|
6
6
|
def kill_phash_entry(entry)
|
7
7
|
pid = entry[0].strip.to_i
|
8
8
|
Process.kill(self.signal, pid)
|
9
|
-
puts "#{self.signal} #{pid} #{entry[1]}"
|
9
|
+
$stdout.puts "#{self.signal} #{pid} #{entry[1]}"
|
10
10
|
end
|
11
11
|
|
12
12
|
def processes
|
@@ -37,10 +37,10 @@ class Die
|
|
37
37
|
def run
|
38
38
|
unless processes.empty?
|
39
39
|
p_hash = process_hash
|
40
|
-
puts
|
41
|
-
puts processes
|
42
|
-
puts
|
43
|
-
puts " Type 'all' to #{self.signal} 'em all, or the numbers (separated by a space) to kill some. Type anything else to quit."
|
40
|
+
$stdout.puts
|
41
|
+
$stdout.puts processes
|
42
|
+
$stdout.puts
|
43
|
+
$stdout.puts " Type 'all' to #{self.signal} 'em all, or the numbers (separated by a space) to kill some. Type anything else to quit."
|
44
44
|
inp = $stdin.gets.strip
|
45
45
|
if(inp =~ /^a(ll)?/i)
|
46
46
|
p_hash.each do |k,v|
|
@@ -52,24 +52,24 @@ class Die
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
else
|
55
|
-
puts "No processes matching #{ARGV[0]}"
|
55
|
+
$stdout.puts "No processes matching #{ARGV[0]}"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.run_from_options
|
60
|
-
opts = {
|
60
|
+
opts = {}
|
61
61
|
o = OptionParser.new do |opt|
|
62
62
|
opt.banner = self.help
|
63
63
|
opt.on("-v", "--version", "Show version") do
|
64
|
-
puts "#{self.to_s} #{File.read(File.join(File.dirname(__FILE__, '..', 'VERSION'))
|
65
|
-
|
64
|
+
$stdout.puts "#{self.to_s} #{File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))}"
|
65
|
+
return false
|
66
66
|
end
|
67
67
|
opt.on("-s", "--signal SIGNAL", "Signal (defaults to KILL)") do |sig|
|
68
|
-
puts sig, '00' * 100
|
69
68
|
opts[:signal] = sig
|
70
69
|
end
|
71
70
|
end
|
72
71
|
o.parse!
|
72
|
+
opts[:search] = ARGV[0..-1]
|
73
73
|
self.new(opts).run
|
74
74
|
end
|
75
75
|
|
data/test/test_die.rb
CHANGED
@@ -76,4 +76,11 @@ class TestDie < Test::Unit::TestCase
|
|
76
76
|
Die.new(:signal => "DONKEY")
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
def test_version
|
81
|
+
version = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
82
|
+
$stdout.expects(:puts).with('Die ' + version)
|
83
|
+
ARGV << "-v"
|
84
|
+
Die.run_from_options
|
85
|
+
end
|
79
86
|
end
|
metadata
CHANGED