Class: Commands::Runners::Runner
Defined Under Namespace
Classes: DebugHooker, FailureHooker, VerboseHooker
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Mockable
#make_mock
Methods included from Hooker
included
Methods included from Hookable
included
Methods included from Abstract
included
Constructor Details
#initialize ⇒ Runner
41
42
43
44
45
|
# File 'lib/commands/runners/runner.rb', line 41
def initialize
@command_data_factory = Datas.const_get(:Factory).new
@open_mode = :w
hooker_subscribe self
end
|
Instance Attribute Details
#command_data_factory ⇒ Object
21
22
23
|
# File 'lib/commands/runners/runner.rb', line 21
def command_data_factory
@command_data_factory
end
|
Instance Method Details
#initialize_copy(copy) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/commands/runners/runner.rb', line 48
def initialize_copy ( copy )
super
if defined? @hookers
@hookers = @hookers.dup
else
@hookers = []
end
end
|
#make_debug ⇒ Object
104
105
106
107
|
# File 'lib/commands/runners/runner.rb', line 104
def make_debug
hooker_subscribe DebugHooker.new
self
end
|
#make_verbose ⇒ Object
98
99
100
101
|
# File 'lib/commands/runners/runner.rb', line 98
def make_verbose
hooker_subscribe VerboseHooker.new
self
end
|
#raise_on_failures ⇒ Object
110
111
112
113
|
# File 'lib/commands/runners/runner.rb', line 110
def raise_on_failures
hooker_subscribe FailureHooker.new
self
end
|
#run(aCommand) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/commands/runners/runner.rb', line 62
def run ( aCommand )
unless aCommand.is_a? Command
raise ArgumentError, "Need a #{Command}"
end
hook_trigger :display_command, aCommand
data = @command_data_factory.create
data.open_mode = @open_mode
data.input = aCommand.input unless aCommand.input.nil?
data.output = aCommand.output unless aCommand.output.nil?
data.error = aCommand.error unless aCommand.error.nil?
hook_trigger :data, aCommand, data
run_impl(aCommand, data)
data
end
|
#run_impl(aCommand, data) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/commands/runners/runner.rb', line 81
def run_impl ( aCommand, data )
hook_trigger :before_open, data
aCommand = aCommand.instanciate_args
STDIN.reopen(data.input.to_io_for_commands) unless data.input.nil?
STDOUT.reopen(data.output.to_io_for_commands) unless data.output.nil?
STDERR.reopen(data.error.to_io_for_commands) unless data.error.nil?
STDOUT.flush
STDERR.flush
hook_trigger :before_chdir, data
Dir.chdir(aCommand.dir) unless aCommand.dir.nil?
hook_trigger :before_exec, aCommand, data
hook_trigger :exec, aCommand, data
end
|