codersdojo 1.1.08 → 1.1.09

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.
@@ -2,6 +2,7 @@ class FilenameFormatter
2
2
 
3
3
  CODERSDOJO_WORKSPACE = ".codersdojo"
4
4
  RESULT_FILE = "result.txt"
5
+ INFO_FILE = "info.yml"
5
6
  STATE_DIR_PREFIX = "state_"
6
7
 
7
8
  def self.state_dir_prefix
@@ -21,6 +22,10 @@ class FilenameFormatter
21
22
  state_file state_dir, RESULT_FILE
22
23
  end
23
24
 
25
+ def info_file state_dir
26
+ state_file state_dir, INFO_FILE
27
+ end
28
+
24
29
  def state_file state_dir, file
25
30
  "#{state_dir}/#{file}"
26
31
  end
data/app/runner.rb CHANGED
@@ -29,12 +29,13 @@ class Runner
29
29
  return
30
30
  end
31
31
  Progress.end
32
- result = @shell.execute @run_command
33
- result = TextConverter.new.remove_escape_sequences result
32
+ process = @shell.execute @run_command
33
+ result = TextConverter.new.remove_escape_sequences process.output
34
34
  state_dir = @filename_formatter.state_dir @session_id, @step
35
35
  @shell.mkdir state_dir
36
36
  @shell.cp @file, state_dir
37
37
  @shell.write_file @filename_formatter.result_file(state_dir), result
38
+ @shell.write_file @filename_formatter.info_file(state_dir), "return_code: #{process.return_code}"
38
39
  @step += 1
39
40
  @previous_change_time = change_time
40
41
  end
@@ -0,0 +1,5 @@
1
+ class ShellProcess
2
+
3
+ attr_accessor :output, :return_code
4
+
5
+ end
data/app/shell_wrapper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'tempfile'
2
+ require 'shell_process'
2
3
 
3
4
  class ShellWrapper
4
5
 
@@ -29,12 +30,14 @@ class ShellWrapper
29
30
  end
30
31
 
31
32
  def execute command
33
+ process = ShellProcess.new
32
34
  redirect_stderr_to_stdout = "2>&1"
33
35
  spec_pipe = IO.popen("#{command} #{redirect_stderr_to_stdout}", "r")
34
- result = spec_pipe.read MAX_STDOUT_LENGTH
36
+ process.output = spec_pipe.read MAX_STDOUT_LENGTH
35
37
  spec_pipe.close
36
- puts result unless result.nil?
37
- result
38
+ process.return_code = $?
39
+ puts process.output unless process.output.nil?
40
+ process
38
41
  end
39
42
 
40
43
  def write_file filename, content
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codersdojo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 8
10
- version: 1.1.08
9
+ - 9
10
+ version: 1.1.09
11
11
  platform: ruby
12
12
  authors:
13
13
  - CodersDojo-Team
@@ -54,6 +54,7 @@ files:
54
54
  - app/scheduler.rb
55
55
  - app/session_id_generator.rb
56
56
  - app/shell_argument_exception.rb
57
+ - app/shell_process.rb
57
58
  - app/shell_wrapper.rb
58
59
  - app/state.rb
59
60
  - app/state_reader.rb