codersdojo 1.2.13 → 1.2.14
Sign up to get free protection for your applications and to get access to all the features.
- data/app/argument_parser.rb +9 -2
- data/app/capture_single_run_command.rb +32 -0
- data/app/console_view.rb +42 -11
- data/app/filename_formatter.rb +4 -0
- data/app/init_session_command.rb +24 -0
- data/app/runner.rb +18 -8
- data/app/shell_wrapper.rb +8 -0
- data/app/start_command.rb +0 -9
- data/app/xhelp_command.rb +23 -0
- metadata +7 -4
data/app/argument_parser.rb
CHANGED
@@ -4,7 +4,10 @@ require 'shell_argument_exception'
|
|
4
4
|
require 'shell_wrapper'
|
5
5
|
require 'console_view'
|
6
6
|
require 'help_command'
|
7
|
+
require 'xhelp_command'
|
7
8
|
require 'generate_command'
|
9
|
+
require 'init_session_command'
|
10
|
+
require 'capture_single_run_command'
|
8
11
|
require 'upload_command'
|
9
12
|
require 'upload_no_open_command'
|
10
13
|
require 'start_command'
|
@@ -13,11 +16,15 @@ class ArgumentParser
|
|
13
16
|
|
14
17
|
def initialize shell, view, scaffolder, hostname
|
15
18
|
@help_command = HelpCommand.new view
|
19
|
+
@xhelp_command = XHelpCommand.new view
|
20
|
+
@generate_command = GenerateCommand.new shell, view, scaffolder
|
16
21
|
@upload_command = UploadCommand.new shell, view, hostname
|
17
22
|
@upload_no_open_command = UploadNoOpenCommand.new @upload_command
|
18
|
-
@
|
23
|
+
@init_session_command = InitSessionCommand.new shell, view
|
24
|
+
@capture_single_run_command = CaptureSingleRunCommand.new shell, view
|
19
25
|
@start_command = StartCommand.new shell, view, @upload_command
|
20
|
-
@commands = [@help_command, @
|
26
|
+
@commands = [@help_command, @xhelp_command, @generate_command, @init_session_command,
|
27
|
+
@capture_single_run_command, @start_command, @upload_command, @upload_no_open_command]
|
21
28
|
end
|
22
29
|
|
23
30
|
def parse params
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'runner'
|
2
|
+
|
3
|
+
class CaptureSingleRunCommand
|
4
|
+
|
5
|
+
COMMAND_NAME = 'capture-single-run'
|
6
|
+
|
7
|
+
def initialize shell, view
|
8
|
+
@shell = shell
|
9
|
+
@view = view
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute_from_shell params
|
13
|
+
unless params[1] then @view.show_missing_command_argument_error COMMAND_NAME, "shell_command"; return end
|
14
|
+
unless params[2] then @view.show_missing_command_argument_error COMMAND_NAME, "kata_file"; return end
|
15
|
+
capture_single_run params[1], params[2]
|
16
|
+
end
|
17
|
+
|
18
|
+
def capture_single_run run_command, kata_file
|
19
|
+
runner = Runner.new @shell, SessionIdGenerator.new
|
20
|
+
runner.run_command = run_command
|
21
|
+
session_id = @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
|
22
|
+
filename_formatter = FilenameFormatter.new
|
23
|
+
last_state_dir = @shell.newest_dir_entry(filename_formatter.session_dir session_id)
|
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
|
26
|
+
end
|
27
|
+
|
28
|
+
def accepts_shell_command? command
|
29
|
+
command == COMMAND_NAME
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/app/console_view.rb
CHANGED
@@ -26,6 +26,7 @@ Usage: #{current_command_path} command [options]
|
|
26
26
|
Commands:
|
27
27
|
help, -h, --help Print this help text.
|
28
28
|
help <command> See the details of the command.
|
29
|
+
xhelp Print help text for advanced commands.
|
29
30
|
setup <framework> <kata_file> Setup the environment for running the kata.
|
30
31
|
upload [<session_dir>] Upload the kata to http://www.codersdojo.org and open the kata in a browser.
|
31
32
|
upload-no-open [<session_dir>] Upload the kata to http://www.codersdojo.org
|
@@ -33,17 +34,23 @@ Commands:
|
|
33
34
|
Report bugs to <codersdojo@it-agile.de>
|
34
35
|
helptext
|
35
36
|
end
|
37
|
+
|
38
|
+
def show_extended_help
|
39
|
+
show <<-helptext
|
40
|
+
Usage: #{current_command_path} command [options]
|
41
|
+
Commands:
|
42
|
+
help <command> See the details of the command.
|
43
|
+
init-session Create a new session dir within the .codersdojo dir.
|
44
|
+
capture-single-run <shell_command> <kata_file> Capture a single run.
|
45
|
+
start <shell_command> <kata_file> Start the continuous test loop.
|
46
|
+
helptext
|
47
|
+
end
|
36
48
|
|
37
49
|
def show_detailed_help command
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
elsif command == 'upload' then
|
43
|
-
show_help_upload
|
44
|
-
elsif command == 'upload-no-open' then
|
45
|
-
show_help_upload_no_open
|
46
|
-
else
|
50
|
+
command = command.gsub('-', '_')
|
51
|
+
begin
|
52
|
+
eval "show_help_#{command}"
|
53
|
+
rescue
|
47
54
|
show_help_unknown command
|
48
55
|
end
|
49
56
|
end
|
@@ -71,7 +78,7 @@ helptext
|
|
71
78
|
show <<-helptext
|
72
79
|
|
73
80
|
start <shell_command> <kata_file>
|
74
|
-
Start the continuous test runner, that runs <
|
81
|
+
Start the continuous test runner, that runs <shell_command> whenever <kata_file>
|
75
82
|
changes. The <kata_file> has to include the whole source code of the kata.
|
76
83
|
Whenever the test runner is started, it creates a new session directory in the
|
77
84
|
directory .codersdojo where it logs the steps of the kata.
|
@@ -97,6 +104,26 @@ Examples:
|
|
97
104
|
helptext
|
98
105
|
end
|
99
106
|
|
107
|
+
def show_help_init_session
|
108
|
+
show <<-helptext
|
109
|
+
|
110
|
+
init-session
|
111
|
+
Create a new session dir in the .codersdojo dir.
|
112
|
+
Usually this command is used before using capture-single-run.
|
113
|
+
helptext
|
114
|
+
end
|
115
|
+
|
116
|
+
def show_help_capture_single_run
|
117
|
+
show <<-helptext
|
118
|
+
|
119
|
+
capture-single-run <shell_command> <kata_file>
|
120
|
+
Execute <shell-command> once for <kata_file>.
|
121
|
+
The <kata_file> has to include the whole source code of the kata.
|
122
|
+
The run will be captured into the newest session dir in the .codersdojo dir.
|
123
|
+
Usually this command is used after a session dir has been created with the init-session command.
|
124
|
+
helptext
|
125
|
+
end
|
126
|
+
|
100
127
|
def show_help_upload_no_open
|
101
128
|
show <<-helptext
|
102
129
|
|
@@ -132,7 +159,7 @@ helptext
|
|
132
159
|
|
133
160
|
def show_missing_command_argument_error command, missing_argument
|
134
161
|
show "Command <#{command}> recognized but argument <#{missing_argument}> was missing.\n"
|
135
|
-
|
162
|
+
show_detailed_help command
|
136
163
|
end
|
137
164
|
|
138
165
|
def show_upload_start session_directory, hostname, framework
|
@@ -174,6 +201,10 @@ msg
|
|
174
201
|
def show_kata_upload_hint
|
175
202
|
show "You finished your kata. You can upload it with 'codersdojo upload'."
|
176
203
|
end
|
204
|
+
|
205
|
+
def show_init_session_result session_dir
|
206
|
+
show "Session directory created: #{session_dir}"
|
207
|
+
end
|
177
208
|
|
178
209
|
def show text
|
179
210
|
puts @template_machine.render(text)
|
data/app/filename_formatter.rb
CHANGED
@@ -35,6 +35,10 @@ class FilenameFormatter
|
|
35
35
|
"#{session_directory}/#{STATE_DIR_PREFIX}#{step}"
|
36
36
|
end
|
37
37
|
|
38
|
+
def step_number_from_state_dir state_dir
|
39
|
+
state_dir.delete(STATE_DIR_PREFIX).to_i
|
40
|
+
end
|
41
|
+
|
38
42
|
def session_dir session_id
|
39
43
|
"#{CODERSDOJO_WORKSPACE}/#{session_id}"
|
40
44
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'runner'
|
2
|
+
|
3
|
+
class InitSessionCommand
|
4
|
+
|
5
|
+
def initialize shell, view
|
6
|
+
@shell = shell
|
7
|
+
@view = view
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute_from_shell params
|
11
|
+
init_session
|
12
|
+
end
|
13
|
+
|
14
|
+
def init_session
|
15
|
+
runner = Runner.new @shell, SessionIdGenerator.new
|
16
|
+
session_dir = runner.init_session
|
17
|
+
@view.show_init_session_result session_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def accepts_shell_command? command
|
21
|
+
command == 'init-session'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/app/runner.rb
CHANGED
@@ -13,14 +13,16 @@ class Runner
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def start
|
16
|
-
init_session
|
16
|
+
init_session
|
17
17
|
execute
|
18
18
|
end
|
19
19
|
|
20
20
|
def init_session
|
21
21
|
@step = 0
|
22
22
|
@session_id = @session_provider.generate_id
|
23
|
-
|
23
|
+
session_dir = @filename_formatter.session_dir @session_id
|
24
|
+
@shell.mkdir_p(session_dir)
|
25
|
+
session_dir
|
24
26
|
end
|
25
27
|
|
26
28
|
def execute
|
@@ -30,16 +32,24 @@ class Runner
|
|
30
32
|
return
|
31
33
|
end
|
32
34
|
Progress.end
|
33
|
-
|
35
|
+
execute_once @file, @session_id, @step
|
36
|
+
@step += 1
|
37
|
+
@previous_change_time = change_time
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute_once file, session_id, step
|
41
|
+
process = @shell.execute @run_command
|
34
42
|
result = TextConverter.new.remove_escape_sequences process.output
|
35
|
-
state_dir = @filename_formatter.state_dir
|
43
|
+
state_dir = @filename_formatter.state_dir session_id, step
|
36
44
|
@shell.mkdir state_dir
|
37
|
-
@shell.cp
|
45
|
+
@shell.cp file, state_dir
|
38
46
|
@shell.write_file @filename_formatter.result_file(state_dir), result
|
39
47
|
@shell.write_file @filename_formatter.info_file(state_dir), "#{InfoPropertyFile.RETURN_CODE_PROPERTY}: #{process.return_code}"
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
def run_command= command
|
51
|
+
@run_command = @shell.expand_run_command command
|
52
|
+
end
|
43
53
|
|
44
54
|
end
|
45
55
|
|
data/app/shell_wrapper.rb
CHANGED
data/app/start_command.rb
CHANGED
@@ -17,7 +17,6 @@ class StartCommand
|
|
17
17
|
def start command, file
|
18
18
|
unless command then @view.show_missing_command_argument_error "start", "shell_command"; return end
|
19
19
|
unless file then @view.show_missing_command_argument_error "start", "kata_file"; return end
|
20
|
-
command = expand_run_command command
|
21
20
|
@view.show_start_kata command, file, @meta_file.framework_property
|
22
21
|
dojo = Runner.new @shell, SessionIdGenerator.new
|
23
22
|
dojo.file = file
|
@@ -30,12 +29,4 @@ class StartCommand
|
|
30
29
|
command == 'start'
|
31
30
|
end
|
32
31
|
|
33
|
-
def expand_run_command command
|
34
|
-
if command.end_with?(".sh") then
|
35
|
-
"bash #{command}"
|
36
|
-
else
|
37
|
-
command
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
32
|
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
|
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:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 14
|
10
|
+
version: 1.2.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- CodersDojo-Team
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-16 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -60,12 +60,14 @@ extra_rdoc_files: []
|
|
60
60
|
|
61
61
|
files:
|
62
62
|
- app/argument_parser.rb
|
63
|
+
- app/capture_single_run_command.rb
|
63
64
|
- app/codersdojo.rb
|
64
65
|
- app/console_view.rb
|
65
66
|
- app/filename_formatter.rb
|
66
67
|
- app/generate_command.rb
|
67
68
|
- app/help_command.rb
|
68
69
|
- app/info_property_file.rb
|
70
|
+
- app/init_session_command.rb
|
69
71
|
- app/meta_config_file.rb
|
70
72
|
- app/progress.rb
|
71
73
|
- app/property_file_missing_exception.rb
|
@@ -84,6 +86,7 @@ files:
|
|
84
86
|
- app/upload_command.rb
|
85
87
|
- app/upload_no_open_command.rb
|
86
88
|
- app/uploader.rb
|
89
|
+
- app/xhelp_command.rb
|
87
90
|
- app/xml_element_extractor.rb
|
88
91
|
- templates/any/README
|
89
92
|
- templates/any/run-endless.%sh%
|