codersdojo 1.5.00 → 1.5.01
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/argument_parser.rb +4 -4
- data/lib/codersdojo.rb +1 -1
- data/lib/commands/capture_single_run_command.rb +34 -0
- data/lib/commands/generate_command.rb +34 -0
- data/lib/commands/help_command.rb +27 -0
- data/lib/commands/init_session_command.rb +25 -0
- data/lib/commands/revert_to_green_command.rb +51 -0
- data/lib/commands/start_command.rb +35 -0
- data/lib/commands/upload_command.rb +53 -0
- data/lib/commands/upload_no_open_command.rb +23 -0
- data/lib/commands/xhelp_command.rb +23 -0
- data/lib/console_view.rb +1 -1
- data/lib/{runner.rb → run/runner.rb} +2 -2
- data/lib/{scaffolder.rb → scaffold/scaffolder.rb} +1 -1
- data/lib/{uploader.rb → upload/uploader.rb} +1 -1
- metadata +21 -12
- /data/lib/{return_code_evaluator.rb → record/return_code_evaluator.rb} +0 -0
- /data/lib/{session_id_generator.rb → record/session_id_generator.rb} +0 -0
- /data/lib/{scheduler.rb → run/scheduler.rb} +0 -0
- /data/lib/{text_converter.rb → run/text_converter.rb} +0 -0
- /data/lib/{text_template_machine.rb → scaffold/text_template_machine.rb} +0 -0
- /data/lib/{xml_element_extractor.rb → upload/xml_element_extractor.rb} +0 -0
data/lib/argument_parser.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'session_id_generator'
|
2
|
-
require '
|
1
|
+
require 'record/session_id_generator'
|
2
|
+
require 'record/return_code_evaluator'
|
3
|
+
require 'run/runner'
|
4
|
+
require 'state_reader'
|
3
5
|
require 'shell_argument_exception'
|
4
6
|
require 'shell_wrapper'
|
5
7
|
require 'console_view'
|
6
|
-
require 'return_code_evaluator'
|
7
|
-
require 'state_reader'
|
8
8
|
require 'commands/help_command'
|
9
9
|
require 'commands/xhelp_command'
|
10
10
|
require 'commands/generate_command'
|
data/lib/codersdojo.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class CaptureSingleRunCommand
|
2
|
+
|
3
|
+
COMMAND_NAME = 'capture-single-run'
|
4
|
+
|
5
|
+
def initialize shell, view, runner
|
6
|
+
@shell = shell
|
7
|
+
@view = view
|
8
|
+
@runner = runner
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute_from_shell params
|
12
|
+
unless params[1] then @view.show_missing_command_argument_error COMMAND_NAME, "shell_command"; return end
|
13
|
+
unless params[2] then @view.show_missing_command_argument_error COMMAND_NAME, "kata_file"; return end
|
14
|
+
capture_single_run params[1], params[2]
|
15
|
+
end
|
16
|
+
|
17
|
+
def capture_single_run run_command, kata_file
|
18
|
+
@runner.run_command = run_command
|
19
|
+
session_id = @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
|
20
|
+
filename_formatter = FilenameFormatter.new
|
21
|
+
last_state_dir = @shell.newest_dir_entry(filename_formatter.session_dir session_id)
|
22
|
+
step = last_state_dir.nil? ? 0 : filename_formatter.step_number_from_state_dir(last_state_dir) + 1
|
23
|
+
@runner.execute_once kata_file, session_id, step
|
24
|
+
end
|
25
|
+
|
26
|
+
def accepts_shell_command? command
|
27
|
+
command == COMMAND_NAME
|
28
|
+
end
|
29
|
+
|
30
|
+
def continue_test_loop?
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class GenerateCommand
|
2
|
+
|
3
|
+
def initialize shell, view, scaffolder
|
4
|
+
@shell = shell
|
5
|
+
@view = view
|
6
|
+
@scaffolder = scaffolder
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute_from_shell params
|
10
|
+
generate params[1], params[2]
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate framework, kata_file
|
14
|
+
if not kata_file then
|
15
|
+
@view.show_missing_command_argument_error "setup", "kata_file"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
begin
|
19
|
+
@scaffolder.scaffold framework, kata_file
|
20
|
+
@view.show "\n" + @shell.read_file("README")
|
21
|
+
rescue
|
22
|
+
@view.show_unknown_framework_error framework, @scaffolder.list_templates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def accepts_shell_command? command
|
27
|
+
command == 'setup'
|
28
|
+
end
|
29
|
+
|
30
|
+
def continue_test_loop?
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class HelpCommand
|
2
|
+
|
3
|
+
def initialize view
|
4
|
+
@view = view
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute_from_shell params
|
8
|
+
help params[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def help command=nil
|
12
|
+
if command then
|
13
|
+
@view.show_detailed_help command.downcase
|
14
|
+
else
|
15
|
+
@view.show_help
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def accepts_shell_command? command
|
20
|
+
['help', '-h', '--help'].member? command
|
21
|
+
end
|
22
|
+
|
23
|
+
def continue_test_loop?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class InitSessionCommand
|
2
|
+
|
3
|
+
def initialize view, runner
|
4
|
+
@view = view
|
5
|
+
@runner = runner
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute_from_shell params
|
9
|
+
init_session
|
10
|
+
end
|
11
|
+
|
12
|
+
def init_session
|
13
|
+
session_dir = @runner.init_session
|
14
|
+
@view.show_init_session_result session_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
def accepts_shell_command? command
|
18
|
+
command == 'init-session'
|
19
|
+
end
|
20
|
+
|
21
|
+
def continue_test_loop?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class RevertToGreenCommand
|
2
|
+
|
3
|
+
def initialize shell, view, meta_config_file, state_reader
|
4
|
+
@shell = shell
|
5
|
+
@view = view
|
6
|
+
@meta_config_file = meta_config_file
|
7
|
+
@state_reader = state_reader
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute_from_shell params
|
11
|
+
revert_to_green
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
revert_to_green
|
16
|
+
end
|
17
|
+
|
18
|
+
def revert_to_green
|
19
|
+
formatter = FilenameFormatter.new
|
20
|
+
@state_reader.session_dir = formatter.session_dir @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
|
21
|
+
@state_reader.goto_last_state
|
22
|
+
state = @state_reader.read_previous_state if @state_reader.state_exist?
|
23
|
+
while @state_reader.state_exist? and state.red?
|
24
|
+
state = @state_reader.read_previous_state
|
25
|
+
end
|
26
|
+
if @state_reader.state_exist? and state.green?
|
27
|
+
@view.show_revert_to_step @state_reader.next_step+1
|
28
|
+
@shell.rm_r @meta_config_file.source_files
|
29
|
+
state.files.each do |file|
|
30
|
+
dest_file = Filename.new(file).extract_last_path_item.to_s
|
31
|
+
@shell.write_file dest_file, @shell.read_file(file)
|
32
|
+
end
|
33
|
+
else
|
34
|
+
@view.show_no_green_state_to_revert_to
|
35
|
+
@state_reader.goto_last_state
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def command_key
|
40
|
+
'g'
|
41
|
+
end
|
42
|
+
|
43
|
+
def accepts_shell_command? command
|
44
|
+
command == 'revert-to-green'
|
45
|
+
end
|
46
|
+
|
47
|
+
def continue_test_loop?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'meta_config_file'
|
2
|
+
require 'run/scheduler'
|
3
|
+
|
4
|
+
class StartCommand
|
5
|
+
|
6
|
+
def initialize meta_config_file, runner, view, eval_loop_commands
|
7
|
+
@runner = runner
|
8
|
+
@view = view
|
9
|
+
@meta_file = meta_config_file
|
10
|
+
@eval_loop_commands = eval_loop_commands
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute_from_shell params
|
14
|
+
start params[1], params[2]
|
15
|
+
end
|
16
|
+
|
17
|
+
def start command, file
|
18
|
+
unless command then @view.show_missing_command_argument_error "start", "shell_command"; return end
|
19
|
+
if file then @view.show_deprecated_command_argument_warning "start", "kata_file" end # since 30-may-2011, remove argument in later version
|
20
|
+
@view.show_start_kata command, file, @meta_file.framework_property
|
21
|
+
@runner.source_files = @meta_file.source_files
|
22
|
+
@runner.run_command = command
|
23
|
+
scheduler = Scheduler.new @runner, @view, @eval_loop_commands
|
24
|
+
scheduler.start
|
25
|
+
end
|
26
|
+
|
27
|
+
def accepts_shell_command? command
|
28
|
+
command == 'start'
|
29
|
+
end
|
30
|
+
|
31
|
+
def continue_test_loop?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'meta_config_file'
|
2
|
+
require 'upload/uploader'
|
3
|
+
|
4
|
+
class UploadCommand
|
5
|
+
|
6
|
+
attr_accessor :uploader
|
7
|
+
|
8
|
+
def initialize shell, view, hostname
|
9
|
+
@shell = shell
|
10
|
+
@view = view
|
11
|
+
@hostname = hostname
|
12
|
+
@uploader = Uploader.new(hostname, '', '')
|
13
|
+
@meta_file = MetaConfigFile.new @shell
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
upload nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute_from_shell params
|
21
|
+
upload params[1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def upload session_directory, open_browser=true
|
25
|
+
formatter = FilenameFormatter.new
|
26
|
+
framework = @meta_file.framework_property
|
27
|
+
if not session_directory then
|
28
|
+
session_directory = formatter.session_dir @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
|
29
|
+
end
|
30
|
+
@view.show_upload_start session_directory, @hostname, framework
|
31
|
+
@uploader.framework = framework
|
32
|
+
@uploader.session_dir = session_directory
|
33
|
+
upload_result = @uploader.upload
|
34
|
+
@view.show_upload_result upload_result
|
35
|
+
url = upload_result.split.last
|
36
|
+
if open_browser then
|
37
|
+
@shell.open_with_default_app url
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def command_key
|
42
|
+
'u'
|
43
|
+
end
|
44
|
+
|
45
|
+
def accepts_shell_command? command
|
46
|
+
command == 'upload'
|
47
|
+
end
|
48
|
+
|
49
|
+
def continue_test_loop?
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class UploadNoOpenCommand
|
2
|
+
|
3
|
+
def initialize upload_command
|
4
|
+
@upload_command = upload_command
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute_from_shell params
|
8
|
+
upload params[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def upload session_directory
|
12
|
+
@upload_command.upload session_directory, false
|
13
|
+
end
|
14
|
+
|
15
|
+
def accepts_shell_command? command
|
16
|
+
command == 'upload-no-open'
|
17
|
+
end
|
18
|
+
|
19
|
+
def continue_test_loop?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class XHelpCommand
|
2
|
+
|
3
|
+
def initialize view
|
4
|
+
@view = view
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute_from_shell params
|
8
|
+
help params[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def help command=nil
|
12
|
+
if command then
|
13
|
+
@view.show_detailed_help command.downcase
|
14
|
+
else
|
15
|
+
@view.show_extended_help
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def accepts_shell_command? command
|
20
|
+
command == 'xhelp'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/console_view.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 1
|
9
|
+
version: 1.5.01
|
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-
|
17
|
+
date: 2011-09-15 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -84,22 +84,31 @@ extra_rdoc_files: []
|
|
84
84
|
files:
|
85
85
|
- lib/argument_parser.rb
|
86
86
|
- lib/codersdojo.rb
|
87
|
+
- lib/commands/capture_single_run_command.rb
|
88
|
+
- lib/commands/generate_command.rb
|
89
|
+
- lib/commands/help_command.rb
|
90
|
+
- lib/commands/init_session_command.rb
|
91
|
+
- lib/commands/revert_to_green_command.rb
|
92
|
+
- lib/commands/start_command.rb
|
93
|
+
- lib/commands/upload_command.rb
|
94
|
+
- lib/commands/upload_no_open_command.rb
|
95
|
+
- lib/commands/xhelp_command.rb
|
87
96
|
- lib/console_view.rb
|
88
97
|
- lib/filename_formatter.rb
|
89
98
|
- lib/info_property_file.rb
|
90
99
|
- lib/meta_config_file.rb
|
91
100
|
- lib/property_file_missing_exception.rb
|
92
|
-
- lib/return_code_evaluator.rb
|
93
|
-
- lib/
|
94
|
-
- lib/
|
95
|
-
- lib/scheduler.rb
|
96
|
-
- lib/
|
101
|
+
- lib/record/return_code_evaluator.rb
|
102
|
+
- lib/record/session_id_generator.rb
|
103
|
+
- lib/run/runner.rb
|
104
|
+
- lib/run/scheduler.rb
|
105
|
+
- lib/run/text_converter.rb
|
106
|
+
- lib/scaffold/scaffolder.rb
|
107
|
+
- lib/scaffold/text_template_machine.rb
|
97
108
|
- lib/state.rb
|
98
109
|
- lib/state_reader.rb
|
99
|
-
- lib/
|
100
|
-
- lib/
|
101
|
-
- lib/uploader.rb
|
102
|
-
- lib/xml_element_extractor.rb
|
110
|
+
- lib/upload/uploader.rb
|
111
|
+
- lib/upload/xml_element_extractor.rb
|
103
112
|
- templates/any/README
|
104
113
|
- templates/any/run-endless.%sh%
|
105
114
|
- templates/any/run-once.%sh%
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|