Class: DTR::Client
- Inherits:
-
Object
- Object
- DTR::Client
- Defined in:
- lib/dtr/base.rb
Constant Summary collapse
- RUNNERS =
{RubyRunner.name => RubyRunner.new}
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #completed_cmds ⇒ Object
- #execute(cmd) ⇒ Object
- #idle? ⇒ Boolean
-
#initialize(server, name, setup_cmd = ) ⇒ Client
constructor
A new instance of Client.
- #run(runner_name, test_files, signature) ⇒ Object
- #server_signature ⇒ Object
- #setup(signature) ⇒ Object
Constructor Details
#initialize(server, name, setup_cmd = ) ⇒ Client
Returns a new instance of Client.
192 193 194 195 196 197 198 |
# File 'lib/dtr/base.rb', line 192 def initialize(server, name, setup_cmd=DTROPTIONS[:setup]) @server = server @name = name @executing_cmd = nil @tmp_dir = DTROPTIONS[:tmp_dir] @setup_cmd = setup_cmd end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
190 191 192 |
# File 'lib/dtr/base.rb', line 190 def name @name end |
Instance Method Details
#completed_cmds ⇒ Object
218 219 220 |
# File 'lib/dtr/base.rb', line 218 def completed_cmds @completed_cmds ||= [] end |
#execute(cmd) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/dtr/base.rb', line 222 def execute(cmd) @executing_cmd = cmd outputs = {:stdout => "#{@tmp_dir}/execution_stdout.log", :stderr => "#{@tmp_dir}/execution_stderr.log"} outputs.values.each do |log_file| File.delete log_file if File.exist? log_file end begin CommandLine.execute cmd, outputs exit_code = 0 rescue CommandLine::ExecutionError => e exit_code = e.exitstatus end outputs.each_key do |key| outputs[key] = File.open(outputs[key], 'r') {|f| f.read} end self.completed_cmds << cmd @executing_cmd = nil {:client_name => @name, :stdout => outputs[:stdout], :stderr => outputs[:stderr], :exit_code => exit_code} end |
#idle? ⇒ Boolean
200 201 202 |
# File 'lib/dtr/base.rb', line 200 def idle? @executing_cmd.nil? end |
#run(runner_name, test_files, signature) ⇒ Object
204 205 206 |
# File 'lib/dtr/base.rb', line 204 def run(runner_name, test_files, signature) RUNNERS[runner_name].run(@server, self, test_files, signature) end |
#server_signature ⇒ Object
214 215 216 |
# File 'lib/dtr/base.rb', line 214 def server_signature @server.server_signature end |
#setup(signature) ⇒ Object
208 209 210 211 212 |
# File 'lib/dtr/base.rb', line 208 def setup(signature) result = execute(@setup_cmd) @server.update_setup_log(signature, result) result end |