die 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/die.gemspec +1 -1
  3. data/lib/die.rb +10 -10
  4. data/test/test_die.rb +7 -0
  5. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{die}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Billy Reisinger"]
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 = {:signal => "KILL", :search => ARGV[0..-1]}
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
- exit
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
 
@@ -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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: die
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Billy Reisinger