vcs 0.2.148 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +6 -0
- data/NEWS +9 -0
- data/README +82 -0
- data/Rakefile +7 -72
- data/SPEC.dyn.yml +10 -0
- data/SPEC.gemspec +14 -0
- data/SPEC.yml +39 -0
- data/bin/vcs +18 -16
- data/lib/vcs/changelog.rb +164 -0
- data/lib/vcs/conflict.rb +21 -0
- data/{src → lib/vcs}/cvs.rb +1 -1
- data/{src → lib/vcs}/diff.rb +2 -2
- data/lib/vcs/diffstat.rb +28 -0
- data/lib/vcs/edit.rb +16 -0
- data/{src → lib/vcs}/last_changed_date.rb +3 -5
- data/{src → lib/vcs}/mail.rb +4 -4
- data/lib/vcs/message.rb +79 -0
- data/{src → lib/vcs}/mycommit.rb +15 -15
- data/{src → lib/vcs}/news.rb +6 -6
- data/{src → lib/vcs}/prcs.rb +1 -1
- data/{src → lib/vcs}/revision.rb +3 -4
- data/lib/vcs/script.rb +19 -0
- data/{src → lib/vcs}/status.rb +1 -1
- data/{src → lib/vcs}/svn.rb +3 -5
- data/lib/vcs/url.rb +16 -0
- data/lib/vcs/vcs.rb +279 -0
- metadata +52 -150
- data/TODO +0 -19
- data/doc/jamis.rb +0 -564
- data/ruby_ex/abstract.rb +0 -254
- data/ruby_ex/abstract_node.rb +0 -85
- data/ruby_ex/algorithms/simulated_annealing.rb +0 -140
- data/ruby_ex/array_each_pair.rb +0 -18
- data/ruby_ex/ask.rb +0 -101
- data/ruby_ex/attributed_class.rb +0 -302
- data/ruby_ex/cache.rb +0 -373
- data/ruby_ex/checkout.rb +0 -12
- data/ruby_ex/choose.rb +0 -271
- data/ruby_ex/commands.rb +0 -18
- data/ruby_ex/commands/command.rb +0 -401
- data/ruby_ex/commands/datas.rb +0 -16
- data/ruby_ex/commands/datas/data.rb +0 -33
- data/ruby_ex/commands/datas/factory.rb +0 -66
- data/ruby_ex/commands/factory.rb +0 -66
- data/ruby_ex/commands/helpers.rb +0 -67
- data/ruby_ex/commands/pipe.rb +0 -64
- data/ruby_ex/commands/runners.rb +0 -17
- data/ruby_ex/commands/runners/exec.rb +0 -49
- data/ruby_ex/commands/runners/fork.rb +0 -97
- data/ruby_ex/commands/runners/runner.rb +0 -107
- data/ruby_ex/commands/seq.rb +0 -27
- data/ruby_ex/config_file.rb +0 -96
- data/ruby_ex/const_regexp.rb +0 -59
- data/ruby_ex/daemon.rb +0 -134
- data/ruby_ex/diff.rb +0 -667
- data/ruby_ex/dlogger.rb +0 -62
- data/ruby_ex/drb/dispatcher.rb +0 -252
- data/ruby_ex/drb/dispatcher_server_test.rb +0 -29
- data/ruby_ex/drb/drb_observable.rb +0 -97
- data/ruby_ex/drb/drb_observable_pool.rb +0 -27
- data/ruby_ex/drb/drb_service.rb +0 -43
- data/ruby_ex/drb/drb_undumped_attributes.rb +0 -55
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +0 -54
- data/ruby_ex/drb/insecure_protected_methods.rb +0 -103
- data/ruby_ex/drb/session_client_test.rb +0 -40
- data/ruby_ex/drb/session_manager.rb +0 -246
- data/ruby_ex/drb/session_server.rb +0 -53
- data/ruby_ex/dtime.rb +0 -143
- data/ruby_ex/dumpable_proc.rb +0 -63
- data/ruby_ex/exception.rb +0 -32
- data/ruby_ex/filetype.rb +0 -229
- data/ruby_ex/fileutils_ex.rb +0 -44
- data/ruby_ex/fold.rb +0 -58
- data/ruby_ex/generate_id.rb +0 -44
- data/ruby_ex/hookable.rb +0 -262
- data/ruby_ex/hooker.rb +0 -54
- data/ruby_ex/inactive_timeout.rb +0 -137
- data/ruby_ex/indexed_node.rb +0 -66
- data/ruby_ex/io_marshal.rb +0 -100
- data/ruby_ex/ioo.rb +0 -194
- data/ruby_ex/labeled_node.rb +0 -63
- data/ruby_ex/logger_observer.rb +0 -23
- data/ruby_ex/md5sum.rb +0 -66
- data/ruby_ex/mktemp.rb +0 -208
- data/ruby_ex/module/attr_once.rb +0 -36
- data/ruby_ex/module/autoload_tree.rb +0 -75
- data/ruby_ex/module/hierarchy.rb +0 -335
- data/ruby_ex/module/instance_method_visibility.rb +0 -73
- data/ruby_ex/module_ex.rb +0 -11
- data/ruby_ex/node.rb +0 -80
- data/ruby_ex/object_monitor.rb +0 -145
- data/ruby_ex/object_monitor_activity.rb +0 -33
- data/ruby_ex/observable.rb +0 -140
- data/ruby_ex/observable_pool.rb +0 -293
- data/ruby_ex/orderedhash.rb +0 -252
- data/ruby_ex/pathname_ex.rb +0 -152
- data/ruby_ex/pp_hierarchy.rb +0 -29
- data/ruby_ex/pseudo_cache.rb +0 -190
- data/ruby_ex/queue.rb +0 -56
- data/ruby_ex/random_generators.rb +0 -25
- data/ruby_ex/random_generators/random_generator.rb +0 -31
- data/ruby_ex/random_generators/ruby.rb +0 -23
- data/ruby_ex/safe_eval.rb +0 -348
- data/ruby_ex/sendmail.rb +0 -215
- data/ruby_ex/service_manager.rb +0 -121
- data/ruby_ex/session/administrable.rb +0 -120
- data/ruby_ex/session/client.rb +0 -153
- data/ruby_ex/session/const.rb +0 -18
- data/ruby_ex/session/dispatcher.rb +0 -184
- data/ruby_ex/session/error.rb +0 -21
- data/ruby_ex/session/fetchable.rb +0 -57
- data/ruby_ex/session/fetcher.rb +0 -62
- data/ruby_ex/session/hookable.rb +0 -26
- data/ruby_ex/session/profile.rb +0 -110
- data/ruby_ex/session/server.rb +0 -582
- data/ruby_ex/session/test/administrable_test.rb +0 -337
- data/ruby_ex/session/test/basic_test.rb +0 -523
- data/ruby_ex/session/test/dispatcher_test.rb +0 -409
- data/ruby_ex/session/test/fetchable_test.rb +0 -119
- data/ruby_ex/session/test/sub_server_test.rb +0 -188
- data/ruby_ex/shuffle.rb +0 -30
- data/ruby_ex/spring.rb +0 -136
- data/ruby_ex/spring_set.rb +0 -137
- data/ruby_ex/string_ex.rb +0 -28
- data/ruby_ex/symtbl.rb +0 -106
- data/ruby_ex/synflow.rb +0 -474
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +0 -164
- data/ruby_ex/thread_mutex.rb +0 -10
- data/ruby_ex/timeout_ex.rb +0 -81
- data/ruby_ex/top_down.rb +0 -73
- data/ruby_ex/trace.rb +0 -26
- data/ruby_ex/uri/druby.rb +0 -81
- data/ruby_ex/uri/file.rb +0 -65
- data/ruby_ex/uri/ftp_ex.rb +0 -37
- data/ruby_ex/uri/http_ex.rb +0 -43
- data/ruby_ex/uri/ssh.rb +0 -92
- data/ruby_ex/uri/svn.rb +0 -118
- data/ruby_ex/uri_ex.rb +0 -45
- data/ruby_ex/verbose_object.rb +0 -30
- data/ruby_ex/version.rb +0 -66
- data/ruby_ex/yaml/basenode_ext.rb +0 -63
- data/ruby_ex/yaml/chop_header.rb +0 -23
- data/ruby_ex/yaml/transform.rb +0 -449
- data/ruby_ex/yaml/yregexpath.rb +0 -76
- data/src/ask.rb +0 -101
- data/src/changelog.rb +0 -117
- data/src/conflict.rb +0 -20
- data/src/diffstat.rb +0 -42
- data/src/message.rb +0 -64
- data/src/reply-mail.rb +0 -14
- data/src/tools.rb +0 -22
- data/src/vcs.rb +0 -176
data/ruby_ex/commands/datas.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: datas.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
require 'module/autoload_tree'
|
7
|
-
|
8
|
-
module Commands
|
9
|
-
|
10
|
-
module Datas
|
11
|
-
|
12
|
-
autoloaded_module(__FILE__)
|
13
|
-
|
14
|
-
end # module Datas
|
15
|
-
|
16
|
-
end # module Commands
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: data.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
module Datas
|
9
|
-
|
10
|
-
#
|
11
|
-
# A CommandData instance contains all information returned by a Command#run:
|
12
|
-
#
|
13
|
-
# * It's exit status:
|
14
|
-
# - Exit number.
|
15
|
-
# - Signals
|
16
|
-
# - ...
|
17
|
-
#
|
18
|
-
# * It's outputs:
|
19
|
-
# - What it writes on stdout.
|
20
|
-
# - stderr.
|
21
|
-
class Data
|
22
|
-
|
23
|
-
attr_accessor :pid
|
24
|
-
attr_accessor :input
|
25
|
-
attr_accessor :output
|
26
|
-
attr_accessor :error
|
27
|
-
attr_accessor :status
|
28
|
-
|
29
|
-
end # class Data
|
30
|
-
|
31
|
-
end # module Datas
|
32
|
-
|
33
|
-
end # module Commands
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: factory.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
module Datas
|
9
|
-
|
10
|
-
class Factory < Data
|
11
|
-
|
12
|
-
attr_accessor :command_data_class
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@command_data_class = Data
|
16
|
-
end
|
17
|
-
|
18
|
-
def new_command_data ( *a, &b )
|
19
|
-
data = @command_data_class.new(*a, &b)
|
20
|
-
instance_variables.each do |var|
|
21
|
-
next if var =~ /command_data_class/
|
22
|
-
data.send(var[1..-1] + '=', instance_variable_get(var))
|
23
|
-
end
|
24
|
-
data
|
25
|
-
end
|
26
|
-
|
27
|
-
alias :create :new_command_data
|
28
|
-
|
29
|
-
end # class Factory
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
if $0 == __FILE__
|
34
|
-
require 'test/unit'
|
35
|
-
|
36
|
-
class FactoryTest < Test::Unit::TestCase
|
37
|
-
|
38
|
-
def setup
|
39
|
-
assert_nothing_raised { @fa = Factory.new }
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_0_initialize
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_new_command_data
|
46
|
-
assert_nothing_raised do
|
47
|
-
assert_kind_of(Data, @fa.create)
|
48
|
-
assert_kind_of(Data, @fa.new_command_data)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_simple
|
53
|
-
assert_nothing_raised do
|
54
|
-
@fa.pid = 42
|
55
|
-
@data = @fa.create
|
56
|
-
end
|
57
|
-
assert_equal(42, @data.pid)
|
58
|
-
end
|
59
|
-
|
60
|
-
end # class FactoryTest
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end # module Datas
|
65
|
-
|
66
|
-
end # module Commands
|
data/ruby_ex/commands/factory.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: factory.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
class Factory < Command
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
super(nil)
|
12
|
-
@command_class = Command
|
13
|
-
end
|
14
|
-
|
15
|
-
def new_command ( *a, &b )
|
16
|
-
cmd = @command_class.new(*a, &b)
|
17
|
-
instance_variables.each do |var|
|
18
|
-
next if var =~ /^@command(_class)?$/
|
19
|
-
cmd.send(var[1..-1] + '=', instance_variable_get(var))
|
20
|
-
end
|
21
|
-
cmd
|
22
|
-
end
|
23
|
-
|
24
|
-
alias :create :new_command
|
25
|
-
|
26
|
-
end # class Factory
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if $0 == __FILE__
|
31
|
-
require 'test/unit'
|
32
|
-
|
33
|
-
class FactoryTest < Test::Unit::TestCase
|
34
|
-
|
35
|
-
def setup
|
36
|
-
assert_nothing_raised { @fa = Factory.new }
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_0_initialize
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_new_command
|
43
|
-
assert_nothing_raised do
|
44
|
-
assert_kind_of(Command, @fa.create('wc'))
|
45
|
-
assert_kind_of(Command, @fa.new_command('ls'))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_simple
|
50
|
-
assert_nothing_raised do
|
51
|
-
@fa << 42
|
52
|
-
@fa.input = 'inp'
|
53
|
-
@fa = @fa > 'out'
|
54
|
-
@cmd = @fa.create('foo')
|
55
|
-
end
|
56
|
-
assert_equal('foo', @cmd.command)
|
57
|
-
assert_equal(42, @cmd.arg_list.first)
|
58
|
-
assert_equal('inp', @cmd.input)
|
59
|
-
assert_equal('out', @cmd.output)
|
60
|
-
end
|
61
|
-
|
62
|
-
end # class FactoryTest
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end # module Commands
|
data/ruby_ex/commands/helpers.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: helpers.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
module Helpers
|
9
|
-
|
10
|
-
class ::String
|
11
|
-
|
12
|
-
#
|
13
|
-
# Make a command from a String.
|
14
|
-
#
|
15
|
-
# Split your command when no quotations are used.
|
16
|
-
#
|
17
|
-
# Do not touch the String and give as one argument.
|
18
|
-
def to_cmd
|
19
|
-
if self =~ /['"`]/
|
20
|
-
Command.new(self)
|
21
|
-
else
|
22
|
-
Command.new(*split(/\s+/))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end # class ::String
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
class ::Array
|
31
|
-
|
32
|
-
def to_cmd
|
33
|
-
Command.new(*self)
|
34
|
-
end
|
35
|
-
|
36
|
-
end # class ::Array
|
37
|
-
|
38
|
-
end # module Helpers
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if __FILE__ == $0
|
43
|
-
|
44
|
-
require 'test/unit'
|
45
|
-
|
46
|
-
class HelpersTest < Test::Unit::TestCase
|
47
|
-
|
48
|
-
def test_string_to_cmd
|
49
|
-
assert_equal(['foo', 'bar'], "foo bar".to_cmd.to_a)
|
50
|
-
|
51
|
-
assert_equal(['foo', 'b/ar', 'qu44x32'],
|
52
|
-
"foo b/ar \t \n qu44x32".to_cmd.to_a)
|
53
|
-
|
54
|
-
s = "foo 'b/ar \t' \n qu44x32"
|
55
|
-
assert_equal([s], s.to_cmd.to_a)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_array_to_cmd
|
59
|
-
a = ['foo', "b/ar \t", "\n qu44x32"]
|
60
|
-
assert_equal(a, a.to_cmd.to_a)
|
61
|
-
end
|
62
|
-
|
63
|
-
end # class HelpersTest
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end # module Commands
|
data/ruby_ex/commands/pipe.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: pipe.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
class Pipe < Command
|
9
|
-
|
10
|
-
def initialize ( *cmds )
|
11
|
-
@cmds = cmds.map { |x| x.dup }
|
12
|
-
end
|
13
|
-
|
14
|
-
def run ( *a )
|
15
|
-
pids = []
|
16
|
-
([nil] + @cmds).zip(@cmds + [nil]).each do |cmd1, cmd2|
|
17
|
-
next if cmd1.nil? or cmd2.nil?
|
18
|
-
rd, wr = IO.pipe
|
19
|
-
cmd1.output = wr
|
20
|
-
cmd2.input = rd
|
21
|
-
pids << fork do
|
22
|
-
rd.close
|
23
|
-
cmd1.exec
|
24
|
-
end
|
25
|
-
wr.close
|
26
|
-
end
|
27
|
-
pids << fork do
|
28
|
-
@cmds.last.exec
|
29
|
-
end
|
30
|
-
pids.each { |pid| Process.waitpid pid }
|
31
|
-
end
|
32
|
-
|
33
|
-
def input= ( arg )
|
34
|
-
@cmds.first.input = arg
|
35
|
-
end
|
36
|
-
|
37
|
-
def input
|
38
|
-
@cmds.first.input
|
39
|
-
end
|
40
|
-
|
41
|
-
def output= ( arg )
|
42
|
-
@cmds.last.output = arg
|
43
|
-
end
|
44
|
-
|
45
|
-
def output
|
46
|
-
@cmds.last.output
|
47
|
-
end
|
48
|
-
|
49
|
-
def error= ( arg )
|
50
|
-
@cmds.last.error = arg
|
51
|
-
end
|
52
|
-
|
53
|
-
def error
|
54
|
-
@cmds.last.error
|
55
|
-
end
|
56
|
-
|
57
|
-
def to_sh
|
58
|
-
strs = @cmds.map { |cmd| "(#{cmd.to_sh})" }
|
59
|
-
"(#{strs.join(' | ')})#{sh_args}"
|
60
|
-
end
|
61
|
-
|
62
|
-
end # class Pipe
|
63
|
-
|
64
|
-
end # module Commands
|
data/ruby_ex/commands/runners.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: runners.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
require 'module/autoload_tree'
|
7
|
-
require 'abstract'
|
8
|
-
require 'hookable'
|
9
|
-
require 'hooker'
|
10
|
-
|
11
|
-
module Commands
|
12
|
-
|
13
|
-
module Runners
|
14
|
-
autoloaded_module(__FILE__)
|
15
|
-
end # module Runners
|
16
|
-
|
17
|
-
end # module Commands
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: exec.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
module Runners
|
9
|
-
|
10
|
-
class Exec < Runner
|
11
|
-
concrete
|
12
|
-
|
13
|
-
def exec ( aCommand, data )
|
14
|
-
Kernel.exec(*aCommand.to_a)
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class Exec
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if $0 == __FILE__
|
22
|
-
require 'test/unit'
|
23
|
-
|
24
|
-
class ExecTest < Test::Unit::TestCase
|
25
|
-
|
26
|
-
def setup
|
27
|
-
assert_nothing_raised { @runner = Exec.new }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_0_initialize
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_simple
|
34
|
-
TempPath.new do |tmp|
|
35
|
-
cmd = %Q[ruby -e "File.open('#{tmp}', 'w') { |f| f.puts :foo }"]
|
36
|
-
pid = fork do
|
37
|
-
@runner.run(cmd.to_cmd)
|
38
|
-
end
|
39
|
-
Process.waitpid pid
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end # class ExecTest
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end # module Runners
|
48
|
-
|
49
|
-
end # module Commands
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
3
|
-
# License:: GNU General Public License (GPL).
|
4
|
-
# Revision:: $Id: fork.rb 221 2005-05-09 12:40:57Z ertai $
|
5
|
-
|
6
|
-
module Commands
|
7
|
-
|
8
|
-
module Runners
|
9
|
-
|
10
|
-
class Fork < Exec
|
11
|
-
concrete
|
12
|
-
|
13
|
-
#
|
14
|
-
# Hooks declaration
|
15
|
-
#
|
16
|
-
|
17
|
-
hook_declare :exception_raised_during_exec
|
18
|
-
hook_declare :already_killed
|
19
|
-
hook_declare :waitpid
|
20
|
-
hook_declare :son
|
21
|
-
hook_declare :kill
|
22
|
-
|
23
|
-
#
|
24
|
-
# Methods
|
25
|
-
#
|
26
|
-
|
27
|
-
def run_impl ( aCommand, data )
|
28
|
-
data.pid = Kernel.fork do
|
29
|
-
begin
|
30
|
-
hook_trigger :son, aCommand, data
|
31
|
-
super
|
32
|
-
rescue Exception => ex
|
33
|
-
hook_trigger :exception_raised_during_exec, ex
|
34
|
-
end
|
35
|
-
end
|
36
|
-
hook_trigger :waitpid, data
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def abort ( data )
|
41
|
-
if data.pid
|
42
|
-
begin
|
43
|
-
hook_trigger :kill, data
|
44
|
-
hook_trigger :waitpid, data
|
45
|
-
rescue Errno::ESRCH
|
46
|
-
hook_trigger :already_killed, data.pid
|
47
|
-
end
|
48
|
-
end
|
49
|
-
super
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
def waitpid ( data )
|
54
|
-
Process.waitpid(data.pid)
|
55
|
-
data.status = $?
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
def exception_raised_during_exec ( anException )
|
60
|
-
exit! 127
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
def kill ( data )
|
65
|
-
Process.kill('-KILL', -data.pid)
|
66
|
-
end
|
67
|
-
|
68
|
-
end # class Fork
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
if $0 == __FILE__
|
73
|
-
require 'test/unit'
|
74
|
-
|
75
|
-
class ForkTest < Test::Unit::TestCase
|
76
|
-
|
77
|
-
def setup
|
78
|
-
assert_nothing_raised { @runner = Fork.new }
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_0_initialize
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_simple
|
85
|
-
TempPath.new do |tmp|
|
86
|
-
cmd = %Q[ruby -e "File.open('#{tmp}', 'w') { |f| f.puts :foo }"]
|
87
|
-
@runner.run(cmd.to_cmd)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end # class Fork
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
end # module Runners
|
96
|
-
|
97
|
-
end # module Commands
|