codersdojo 1.4.06 → 1.4.07

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.
@@ -3,6 +3,7 @@ require 'runner'
3
3
  require 'shell_argument_exception'
4
4
  require 'shell_wrapper'
5
5
  require 'console_view'
6
+ require 'return_code_evaluator'
6
7
  require 'state_reader'
7
8
  require 'help_command'
8
9
  require 'xhelp_command'
@@ -18,15 +19,17 @@ class ArgumentParser
18
19
 
19
20
  def initialize shell, view, scaffolder, hostname
20
21
  meta_config_file = MetaConfigFile.new shell
22
+ return_code_evaluator = ReturnCodeEvaluator.new meta_config_file.success_detection
23
+ runner = Runner.new shell, SessionIdGenerator.new, view, return_code_evaluator
21
24
  @help_command = HelpCommand.new view
22
25
  @xhelp_command = XHelpCommand.new view
23
26
  @generate_command = GenerateCommand.new shell, view, scaffolder
24
27
  @upload_command = UploadCommand.new shell, view, hostname
25
28
  @upload_no_open_command = UploadNoOpenCommand.new @upload_command
26
- @init_session_command = InitSessionCommand.new shell, view
27
- @capture_single_run_command = CaptureSingleRunCommand.new shell, view
29
+ @init_session_command = InitSessionCommand.new view, runner
30
+ @capture_single_run_command = CaptureSingleRunCommand.new shell, view, runner
28
31
  @revert_to_green_command = RevertToGreenCommand.new shell, view, meta_config_file, StateReader.new(shell)
29
- @start_command = StartCommand.new shell, view, [@upload_command, @revert_to_green_command]
32
+ @start_command = StartCommand.new meta_config_file, runner, view, [@upload_command, @revert_to_green_command]
30
33
  @commands = [@help_command, @xhelp_command, @generate_command, @init_session_command,
31
34
  @capture_single_run_command, @start_command, @revert_to_green_command,
32
35
  @upload_command, @upload_no_open_command]
@@ -4,9 +4,10 @@ class CaptureSingleRunCommand
4
4
 
5
5
  COMMAND_NAME = 'capture-single-run'
6
6
 
7
- def initialize shell, view
7
+ def initialize shell, view, runner
8
8
  @shell = shell
9
9
  @view = view
10
+ @runner = runner
10
11
  end
11
12
 
12
13
  def execute_from_shell params
@@ -16,13 +17,12 @@ class CaptureSingleRunCommand
16
17
  end
17
18
 
18
19
  def capture_single_run run_command, kata_file
19
- runner = Runner.new @shell, SessionIdGenerator.new, @view
20
- runner.run_command = run_command
20
+ @runner.run_command = run_command
21
21
  session_id = @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
22
22
  filename_formatter = FilenameFormatter.new
23
23
  last_state_dir = @shell.newest_dir_entry(filename_formatter.session_dir session_id)
24
24
  step = last_state_dir.nil? ? 0 : filename_formatter.step_number_from_state_dir(last_state_dir) + 1
25
- runner.execute_once kata_file, session_id, step
25
+ @runner.execute_once kata_file, session_id, step
26
26
  end
27
27
 
28
28
  def accepts_shell_command? command
@@ -3,5 +3,5 @@ class InfoPropertyFile
3
3
  def self.RETURN_CODE_PROPERTY
4
4
  'return_code'
5
5
  end
6
-
6
+
7
7
  end
@@ -2,9 +2,9 @@ require 'runner'
2
2
 
3
3
  class InitSessionCommand
4
4
 
5
- def initialize shell, view
6
- @shell = shell
5
+ def initialize view, runner
7
6
  @view = view
7
+ @runner = runner
8
8
  end
9
9
 
10
10
  def execute_from_shell params
@@ -12,8 +12,7 @@ class InitSessionCommand
12
12
  end
13
13
 
14
14
  def init_session
15
- runner = Runner.new @shell, SessionIdGenerator.new, @view
16
- session_dir = runner.init_session
15
+ session_dir = @runner.init_session
17
16
  @view.show_init_session_result session_dir
18
17
  end
19
18
 
@@ -14,6 +14,10 @@ class MetaConfigFile
14
14
  properties['source_files']
15
15
  end
16
16
 
17
+ def success_detection
18
+ properties['success_detection']
19
+ end
20
+
17
21
  def properties
18
22
  @properties = @shell.read_properties PROPERTY_FILENAME unless @properties
19
23
  @properties
@@ -0,0 +1,24 @@
1
+ class ReturnCodeEvaluator
2
+
3
+ SUCCESS_RETURN_CODE = 0
4
+ FAILURE_RETURN_CODE = 1
5
+
6
+ def initialize success_detection
7
+ @success_detection = success_detection
8
+ end
9
+
10
+ def return_code process
11
+ return process.return_code unless @success_detection
12
+ return_code_from_output process.output
13
+ end
14
+
15
+ def return_code_from_output output
16
+ space_or_start_of_line = "( |^)"
17
+ if output =~ /#{space_or_start_of_line}#{@success_detection}/ then
18
+ SUCCESS_RETURN_CODE
19
+ else
20
+ FAILURE_RETURN_CODE
21
+ end
22
+ end
23
+
24
+ end
data/app/runner.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "info_property_file"
2
2
  require "filename_formatter"
3
3
  require "text_converter"
4
+ require "return_code_evaluator"
4
5
 
5
6
  class Runner
6
7
 
@@ -8,11 +9,12 @@ class Runner
8
9
 
9
10
  WORKING_DIR = '.'
10
11
 
11
- def initialize shell, session_provider, view
12
+ def initialize shell, session_provider, view, return_code_evaluator
12
13
  @filename_formatter = FilenameFormatter.new
13
14
  @shell = shell
14
15
  @session_provider = session_provider
15
16
  @view = view
17
+ @return_code_evaluator = return_code_evaluator
16
18
  end
17
19
 
18
20
  def start
@@ -47,10 +49,11 @@ class Runner
47
49
  process = @shell.execute @run_command
48
50
  result = TextConverter.new.remove_escape_sequences process.output
49
51
  state_dir = @filename_formatter.state_dir session_id, step
52
+ return_code = @return_code_evaluator.return_code(process)
50
53
  @shell.mkdir state_dir
51
54
  @shell.cp_r files, state_dir
52
55
  @shell.write_file @filename_formatter.result_file(state_dir), result
53
- @shell.write_file @filename_formatter.info_file(state_dir), "#{InfoPropertyFile.RETURN_CODE_PROPERTY}: #{process.return_code}"
56
+ @shell.write_file @filename_formatter.info_file(state_dir), "#{InfoPropertyFile.RETURN_CODE_PROPERTY}: #{return_code}"
54
57
  end
55
58
 
56
59
  def run_command= command
@@ -17,5 +17,3 @@ class SessionZipper
17
17
  end
18
18
 
19
19
  end
20
-
21
- SessionZipper.new.compress ".codersdojo/broken"
data/app/start_command.rb CHANGED
@@ -3,10 +3,10 @@ require 'scheduler'
3
3
 
4
4
  class StartCommand
5
5
 
6
- def initialize shell, view, eval_loop_commands
7
- @shell = shell
6
+ def initialize meta_config_file, runner, view, eval_loop_commands
7
+ @runner = runner
8
8
  @view = view
9
- @meta_file = MetaConfigFile.new @shell
9
+ @meta_file = meta_config_file
10
10
  @eval_loop_commands = eval_loop_commands
11
11
  end
12
12
 
@@ -18,10 +18,9 @@ class StartCommand
18
18
  unless command then @view.show_missing_command_argument_error "start", "shell_command"; return end
19
19
  if file then @view.show_deprecated_command_argument_warning "start", "kata_file" end # since 30-may-2011, remove argument in later version
20
20
  @view.show_start_kata command, file, @meta_file.framework_property
21
- runner = Runner.new @shell, SessionIdGenerator.new, @view
22
- runner.source_files = @meta_file.source_files
23
- runner.run_command = command
24
- scheduler = Scheduler.new runner, @view, @eval_loop_commands
21
+ @runner.source_files = @meta_file.source_files
22
+ @runner.run_command = command
23
+ scheduler = Scheduler.new @runner, @view, @eval_loop_commands
25
24
  scheduler.start
26
25
  end
27
26
 
data/app/uploader.rb CHANGED
@@ -6,6 +6,7 @@ require 'filename_formatter'
6
6
  require 'xml_element_extractor'
7
7
  require 'rest_client'
8
8
  require 'shell_wrapper'
9
+ require 'session_zipper'
9
10
 
10
11
  class Uploader
11
12
 
@@ -21,6 +22,7 @@ class Uploader
21
22
  end
22
23
 
23
24
  def session_dir= dir
25
+ @session_dir = dir
24
26
  @state_reader.session_dir = dir
25
27
  end
26
28
 
@@ -30,6 +32,7 @@ class Uploader
30
32
  end
31
33
 
32
34
  def upload_kata_and_states
35
+ upload_zipped_kata zip_kata
33
36
  read_states
34
37
  kata = upload_kata
35
38
  finish_url = "#{@hostname}#{@@description_path}/#{XMLElementExtractor.extract('kata/private-uuid', kata)}"
@@ -52,10 +55,19 @@ class Uploader
52
55
  RestClient.post "#{@hostname}#{@@kata_path}", kata_data
53
56
  end
54
57
 
55
- private
58
+ def zip_kata
59
+ # SessionZipper.new.compress @session_dir
60
+ end
61
+
62
+ def upload_zipped_kata zip_file
63
+ # RestClient.post "#{@hostname}#{@@zipped_kata_path}", {:zipped_kata => zip_file}
64
+ end
65
+
66
+ private
56
67
  @@kata_path = '/katas'
57
68
  @@state_path = '/states'
58
69
  @@description_path = '/kata_description'
70
+ @@zipped_kata_path = '/zipped_katas'
59
71
 
60
72
  end
61
73
 
@@ -1,3 +1,3 @@
1
1
  framework: clojure.is-test
2
2
  source_files: .*\.clj
3
-
3
+ success_detection: "0 failures, 0 errors"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
- - 6
9
- version: 1.4.06
8
+ - 7
9
+ version: 1.4.07
10
10
  platform: ruby
11
11
  authors:
12
12
  - CodersDojo-Team
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-09-10 00:00:00 +02:00
17
+ date: 2011-09-14 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -95,6 +95,7 @@ files:
95
95
  - app/meta_config_file.rb
96
96
  - app/progress.rb
97
97
  - app/property_file_missing_exception.rb
98
+ - app/return_code_evaluator.rb
98
99
  - app/revert_to_green_command.rb
99
100
  - app/runner.rb
100
101
  - app/scaffolder.rb
@@ -226,7 +227,6 @@ files:
226
227
  - templates/ruby.test-unit/.meta
227
228
  - templates/scala.junit/.meta
228
229
  - templates/shell.shunit/.meta
229
- - lib/place_libs_here
230
230
  has_rdoc: true
231
231
  homepage: http://www.codersdojo.org/
232
232
  licenses: []
data/lib/place_libs_here DELETED
File without changes