after 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.1
data/bin/after CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  if ARGV.include?('-h') || ARGV.include?('--help') || ARGV.length == 0
4
- puts 'syntax: [-v] [-l or --list to only list] "command string to match" then some other command to run with its args'
4
+ puts 'syntax: [-v] [-l or --list to only list] [-p pid] "command string to match" then some other command to run with its args'
5
5
  exit
6
6
  end
7
7
 
@@ -11,15 +11,21 @@ require 'andand' # to avoid warnings
11
11
  if ARGV[0] == '-v'
12
12
  ARGV.shift
13
13
  $VERBOSE = true
14
- puts 'running in verbose mode, my pid is ' + Process.pid.to_s
14
+ puts 'running in verbose mode'
15
15
  end
16
16
 
17
17
  if ARGV[0] == '-l' || ARGV[0] == '--list'
18
- $VERBOSE = true # so it'll output
18
+ $VERBOSE = true # so it'll output the names...
19
19
  ARGV.shift
20
20
  After.find_pids(ARGV.shift)
21
- exit
21
+ exit # premature exit
22
+ elsif ARGV[0] == '-p'
23
+ ARGV.shift
24
+ pid = ARGV.shift
25
+ After.wait_pid pid.to_i
26
+ else
27
+ After.find_and_wait_for(ARGV.shift)
22
28
  end
23
29
 
24
- After.find_and_wait_for(ARGV.shift)
25
- system(ARGV)
30
+ puts 'running', ARGV if $VERBOSE
31
+ system(*ARGV) if ARGV.length > 0
data/lib/after.rb CHANGED
@@ -23,7 +23,17 @@ class After
23
23
 
24
24
  def self.find_and_wait_for(args)
25
25
  pids = find_pids args
26
- pids.each{|pid| WaitPid.wait_nonchild_pid pid }
26
+ if pids.length > 1
27
+ puts "found more than one -- waiting for all #{pids.inspect}"
28
+ end
29
+ pids.each{|pid|
30
+ puts "waiting for #{pid}"
31
+ WaitPid.wait_nonchild_pid pid
32
+ }
33
+ end
34
+
35
+ def self.wait_pid pid
36
+ WaitPid.wait_nonchild_pid pid
27
37
  end
28
38
 
29
39
  end
data/spec/spec.after.rb CHANGED
@@ -49,5 +49,10 @@ describe After do
49
49
  it "should run all args" do
50
50
  go 0
51
51
  end
52
+
53
+ it "should allow for passing in a pid" do
54
+ pid = go 1
55
+ After.wait_pid pid
56
+ end
52
57
 
53
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rogerdpack
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-31 00:00:00 -07:00
12
+ date: 2010-01-05 00:00:00 -07:00
13
13
  default_executable: after
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -69,15 +69,11 @@ executables:
69
69
  extensions: []
70
70
 
71
71
  extra_rdoc_files:
72
- - LICENSE
73
72
  - README
74
- - README.rdoc
75
73
  files:
76
74
  - .document
77
75
  - .gitignore
78
- - LICENSE
79
76
  - README
80
- - README.rdoc
81
77
  - Rakefile
82
78
  - VERSION
83
79
  - bin/after
@@ -85,7 +81,6 @@ files:
85
81
  - spec/helper.rb
86
82
  - spec/sleep.rb
87
83
  - spec/spec.after.rb
88
- - spec/test_wait_pid.rb
89
84
  has_rdoc: true
90
85
  homepage:
91
86
  licenses: []
@@ -118,4 +113,3 @@ test_files:
118
113
  - spec/helper.rb
119
114
  - spec/sleep.rb
120
115
  - spec/spec.after.rb
121
- - spec/test_wait_pid.rb
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 rdp
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = wait_pid
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2009 rdp. See LICENSE for details.
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestWaitPid < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end