after 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
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 ADDED
@@ -0,0 +1,17 @@
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.
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  require 'jeweler'
2
3
  Jeweler::Tasks.new do |gemspec|
3
4
  gemspec.name = "after"
@@ -6,9 +7,8 @@ require 'jeweler'
6
7
  gemspec.email = "rogerdpack@gmail.com"
7
8
  gemspec.authors = ["rogerdpack"]
8
9
  gemspec.add_dependency 'sane'
9
- gemspec.add_dependency 'andand'
10
10
  gemspec.add_development_dependency 'jeweler'
11
11
  gemspec.add_development_dependency 'rspec'
12
12
  gemspec.add_dependency 'ruby-wmi'
13
- gemspec.add_dependency 'win32-process'
14
- end
13
+ gemspec.add_dependency 'wait_pid'
14
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.4
data/bin/after CHANGED
@@ -1,16 +1,25 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  if ['-h', '--help'].in?(ARGV) || ARGV.length == 0
4
- puts 'syntax: [-v] "command string to match" then some other command to run with its args'
4
+ puts 'syntax: [-v] [-l or --list to only list] "command string to match" then some other command to run with its args'
5
5
  exit
6
6
  end
7
7
 
8
8
  require 'after'
9
+ require 'andand' # to avoid warnings
9
10
 
10
11
  if ARGV[0] == '-v'
11
12
  ARGV.shift
12
13
  $VERBOSE = true
13
- puts 'running in verbose mode'
14
+ puts 'running in verbose mode, my pid is ' + Process.pid.to_s
14
15
  end
16
+
17
+ if ARGV[0] == '-l' || ARGV[0] == '--list'
18
+ $VERBOSE = true # so it'll output
19
+ ARGV.shift
20
+ After.find_pids(ARGV.shift)
21
+ exit
22
+ end
23
+
15
24
  After.find_and_wait_for(ARGV.shift)
16
25
  system(ARGV)
data/lib/after.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'ruby-wmi'
1
+ require 'ruby-wmi' # wow not even pretended linux compat. yet
2
2
  require 'sane'
3
- require 'andand'
4
- require 'win32/process' # waitpid for doze
3
+ require 'wait_pid'
5
4
 
6
5
  class After
7
6
 
@@ -10,8 +9,10 @@ class After
10
9
  procs = WMI::Win32_Process.find(:all)
11
10
  pids = []
12
11
  for proc in procs # TODO respect proc.Name!
13
- if proc.CommandLine.andand.contain?(many_args)
14
- pids << proc.ProcessId.to_i
12
+ if proc.CommandLine && proc.CommandLine.contain?(many_args)
13
+ pid = proc.ProcessId.to_i
14
+ next if pid == Process.pid
15
+ pids << pid
15
16
  if $VERBOSE
16
17
  print 'adding ', proc.ProcessId, ' ', proc.Name, ' ', proc.CommandLine, "\n"
17
18
  end
@@ -22,7 +23,7 @@ class After
22
23
 
23
24
  def self.find_and_wait_for(args)
24
25
  pids = find_pids args
25
- pids.each{|pid| Process.waitpid pid}
26
+ pids.each{|pid| WaitPid.wait_nonchild_pid pid }
26
27
  end
27
28
 
28
29
  end
data/spec/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'wait_pid'
8
+
9
+ class Test::Unit::TestCase
10
+ end
File without changes
@@ -1,11 +1,13 @@
1
1
  require 'spec/autorun'
2
- require 'sane' # require_rel
2
+ require 'sane'
3
3
  require_rel '../lib/after'
4
4
 
5
5
  describe After do
6
6
 
7
7
  def go how_many = 1
8
8
  pid = Process.spawn "ruby ./sleep.rb #{how_many}"
9
+ Thread.new { Process.wait pid } # wait for it, so we can collect child processes, too
10
+ pid
9
11
  end
10
12
 
11
13
  it "should be able to grab the right pid" do
@@ -35,6 +37,17 @@ describe After do
35
37
  assert (Time.now - start) > 2
36
38
  end
37
39
 
38
- it "should split the commands up right--if necessary"
40
+ it "should split the commands up right and across name, too"
41
+
42
+ it "should respect name"
43
+
44
+ it "should not return the PID of this process" do
45
+ a = After.find_pids('ruby')
46
+ assert !Process.pid.in?(a)
47
+ end
48
+
49
+ it "should run all args" do
50
+ go 0
51
+ end
39
52
 
40
53
  end
@@ -0,0 +1,7 @@
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
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.0.2
4
+ version: 0.0.4
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-16 00:00:00 -07:00
12
+ date: 2009-12-22 00:00:00 -07:00
13
13
  default_executable: after
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,16 +22,6 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: andand
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
35
25
  - !ruby/object:Gem::Dependency
36
26
  name: jeweler
37
27
  type: :development
@@ -63,7 +53,7 @@ dependencies:
63
53
  version: "0"
64
54
  version:
65
55
  - !ruby/object:Gem::Dependency
66
- name: win32-process
56
+ name: wait_pid
67
57
  type: :runtime
68
58
  version_requirement:
69
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -79,15 +69,23 @@ executables:
79
69
  extensions: []
80
70
 
81
71
  extra_rdoc_files:
72
+ - LICENSE
82
73
  - README
74
+ - README.rdoc
83
75
  files:
76
+ - .document
77
+ - .gitignore
78
+ - LICENSE
84
79
  - README
80
+ - README.rdoc
85
81
  - Rakefile
86
82
  - VERSION
87
83
  - bin/after
88
84
  - lib/after.rb
89
- - test/sleep.rb
90
- - test/spec.after.rb
85
+ - spec/helper.rb
86
+ - spec/sleep.rb
87
+ - spec/spec.after.rb
88
+ - spec/test_wait_pid.rb
91
89
  has_rdoc: true
92
90
  homepage:
93
91
  licenses: []
@@ -117,5 +115,7 @@ signing_key:
117
115
  specification_version: 3
118
116
  summary: Command to allow you to run a command in one console window, then run another in a separate window after the first completes
119
117
  test_files:
120
- - test/sleep.rb
121
- - test/spec.after.rb
118
+ - spec/helper.rb
119
+ - spec/sleep.rb
120
+ - spec/spec.after.rb
121
+ - spec/test_wait_pid.rb