codersdojo 1.1.05 → 1.1.06
Sign up to get free protection for your applications and to get access to all the features.
- data/app/codersdojo.rb +3 -8
- data/app/console_view.rb +12 -11
- data/app/controller.rb +6 -6
- data/app/filename_formatter.rb +4 -0
- data/app/shell_wrapper.rb +7 -0
- data/app/state.rb +11 -0
- data/app/state_reader.rb +6 -13
- data/app/uploader.rb +21 -20
- data/bin/codersdojo +1 -0
- data/templates/python.pytest/%kata_file%.py +9 -0
- data/templates/python.pytest/README +8 -0
- data/templates/python.pytest/run-endless.%sh% +1 -0
- data/templates/python.pytest/run-once.%sh% +1 -0
- metadata +9 -4
data/app/codersdojo.rb
CHANGED
@@ -7,19 +7,17 @@ require 'scaffolder'
|
|
7
7
|
|
8
8
|
class CodersDojo
|
9
9
|
|
10
|
-
def initialize params
|
10
|
+
def initialize params, hostname = "http://www.codersdojo.com"
|
11
11
|
@params = params
|
12
|
+
@hostname = hostname
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
16
|
if called_from_spec? then return end
|
16
|
-
hostname = "http://www.codersdojo.com"
|
17
|
-
# hostname = "http://localhost:3000"
|
18
|
-
|
19
17
|
shell = ShellWrapper.new
|
20
18
|
scaffolder = Scaffolder.new shell
|
21
19
|
view = ConsoleView.new scaffolder
|
22
|
-
controller = Controller.new shell, view, scaffolder, hostname
|
20
|
+
controller = Controller.new shell, view, scaffolder, @hostname
|
23
21
|
|
24
22
|
begin
|
25
23
|
arg_parser = ArgumentParser.new controller
|
@@ -34,6 +32,3 @@ class CodersDojo
|
|
34
32
|
end
|
35
33
|
|
36
34
|
end
|
37
|
-
|
38
|
-
# entry from shell
|
39
|
-
CodersDojo.new(ARGV).run
|
data/app/console_view.rb
CHANGED
@@ -19,10 +19,10 @@ helptext
|
|
19
19
|
puts <<-helptext
|
20
20
|
Usage: #{$0} command [options]
|
21
21
|
Commands:
|
22
|
-
help, -h, --help
|
23
|
-
help <command>
|
24
|
-
setup <framework> <kata_file>
|
25
|
-
upload <framework> <session_dir> Upload the kata to http://www.codersdojo.org
|
22
|
+
help, -h, --help Print this help text.
|
23
|
+
help <command> See the details of the command.
|
24
|
+
setup <framework> <kata_file> Setup the environment for running the kata.
|
25
|
+
upload <framework> [<session_dir>] Upload the kata to http://www.codersdojo.org
|
26
26
|
|
27
27
|
Report bugs to <codersdojo@it-agile.de>
|
28
28
|
helptext
|
@@ -69,10 +69,11 @@ helptext
|
|
69
69
|
templates = @scaffolder.list_templates
|
70
70
|
puts <<-helptext
|
71
71
|
|
72
|
-
upload <framework> <session_directory> Upload the kata written with <framework> in <session_directory> to codersdojo.com.
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
upload <framework> [<session_directory>] Upload the kata written with <framework> in <session_directory> to codersdojo.com.
|
73
|
+
<session_directory> is relative to the working directory.
|
74
|
+
If you don't specify a <session_directory> the newest session in .codersdojo is uploaded.
|
75
|
+
By now <framework> is one of #{templates}.
|
76
|
+
If you used another framework, use ??? and send an email to codersdojo@it-agile.de
|
76
77
|
|
77
78
|
Example:
|
78
79
|
:/dojo/my_kata$ #{$0} upload ruby.test-unit .codersdojo/2010-11-02_16-21-53
|
@@ -87,7 +88,7 @@ helptext
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def show_start_kata command, file
|
90
|
-
puts "Starting
|
91
|
+
puts "Starting CodersDojo-Client with command #{command} and kata file #{file}. Use Ctrl+C to finish the kata."
|
91
92
|
end
|
92
93
|
|
93
94
|
def show_missing_command_argument_error command
|
@@ -95,8 +96,8 @@ helptext
|
|
95
96
|
show_usage
|
96
97
|
end
|
97
98
|
|
98
|
-
def show_upload_start hostname
|
99
|
-
puts "Start upload to #{hostname}"
|
99
|
+
def show_upload_start session_directory, hostname
|
100
|
+
puts "Start upload from #{session_directory} to #{hostname}"
|
100
101
|
end
|
101
102
|
|
102
103
|
def show_upload_result result
|
data/app/controller.rb
CHANGED
@@ -42,13 +42,13 @@ class Controller
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def upload framework, session_directory
|
45
|
-
|
46
|
-
if session_directory then
|
47
|
-
|
48
|
-
@view.show_upload_result uploader.upload
|
49
|
-
else
|
50
|
-
@view.show_missing_command_argument_error "upload"
|
45
|
+
formatter = FilenameFormatter.new
|
46
|
+
if not session_directory then
|
47
|
+
session_directory = formatter.session_dir @shell.newest_dir_entry(FilenameFormatter.codersdojo_workspace)
|
51
48
|
end
|
49
|
+
@view.show_upload_start session_directory, @hostname
|
50
|
+
uploader = Uploader.new @hostname, framework, session_directory
|
51
|
+
@view.show_upload_result uploader.upload
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
data/app/filename_formatter.rb
CHANGED
@@ -8,6 +8,10 @@ class FilenameFormatter
|
|
8
8
|
STATE_DIR_PREFIX
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.codersdojo_workspace
|
12
|
+
CODERSDOJO_WORKSPACE
|
13
|
+
end
|
14
|
+
|
11
15
|
def source_code_file state_dir
|
12
16
|
Dir.entries(state_dir).each { |file|
|
13
17
|
return state_file state_dir, file unless file =='..' || file == '.' || file == RESULT_FILE }
|
data/app/shell_wrapper.rb
CHANGED
@@ -60,6 +60,13 @@ class ShellWrapper
|
|
60
60
|
def real_dir_entries dir
|
61
61
|
Dir.new(dir).entries - ["..", "."]
|
62
62
|
end
|
63
|
+
|
64
|
+
def newest_dir_entry dir
|
65
|
+
Dir.new(dir).sort_by do |entry|
|
66
|
+
complete_path = File.join dir, entry
|
67
|
+
File.mtime(complete_path)
|
68
|
+
end.last
|
69
|
+
end
|
63
70
|
|
64
71
|
def file? filename
|
65
72
|
File.file? filename
|
data/app/state.rb
ADDED
data/app/state_reader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'filename_formatter'
|
2
|
+
require 'state'
|
2
3
|
|
3
4
|
class StateReader
|
4
5
|
|
@@ -7,9 +8,13 @@ class StateReader
|
|
7
8
|
def initialize shell
|
8
9
|
@filename_formatter = FilenameFormatter.new
|
9
10
|
@shell = shell
|
10
|
-
|
11
|
+
reset
|
11
12
|
end
|
12
13
|
|
14
|
+
def reset
|
15
|
+
@next_step = 0
|
16
|
+
end
|
17
|
+
|
13
18
|
def session_dir= session_dir
|
14
19
|
@session_dir = session_dir
|
15
20
|
@session_id = @filename_formatter.extract_last_path_item @session_dir
|
@@ -48,15 +53,3 @@ class StateReader
|
|
48
53
|
|
49
54
|
end
|
50
55
|
|
51
|
-
class State
|
52
|
-
|
53
|
-
attr_accessor :time, :code, :result
|
54
|
-
|
55
|
-
def initialize time=nil, code=nil, result=nil
|
56
|
-
@time = time
|
57
|
-
@code = code
|
58
|
-
@result = result
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
data/app/uploader.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'state'
|
1
2
|
require 'state_reader'
|
2
3
|
require 'progress'
|
3
4
|
require 'filename_formatter'
|
@@ -6,42 +7,42 @@ require 'rest_client'
|
|
6
7
|
|
7
8
|
class Uploader
|
8
9
|
|
10
|
+
attr_reader :states
|
11
|
+
|
9
12
|
def initialize hostname, framework, session_dir, state_reader = StateReader.new(ShellWrapper.new)
|
13
|
+
@states = []
|
10
14
|
@hostname = hostname
|
11
15
|
@framework = framework
|
12
16
|
@state_reader = state_reader
|
13
17
|
@state_reader.session_dir = session_dir
|
14
18
|
end
|
15
19
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def upload_state kata_id
|
21
|
-
state = @state_reader.read_next_state
|
22
|
-
RestClient.post "#{@hostname}#{@@kata_path}/#{kata_id}#{@@state_path}", {:code => state.code, :result => state.result, :created_at => state.time}
|
23
|
-
Progress.next
|
24
|
-
end
|
25
|
-
|
26
|
-
def upload_states kata_id
|
27
|
-
Progress.write_empty_progress @state_reader.state_count
|
28
|
-
while @state_reader.has_next_state
|
29
|
-
upload_state kata_id
|
30
|
-
end
|
31
|
-
Progress.end
|
20
|
+
def upload
|
21
|
+
return upload_kata_and_states if @state_reader.enough_states?
|
22
|
+
return "You need at least two states"
|
32
23
|
end
|
33
24
|
|
34
25
|
def upload_kata_and_states
|
26
|
+
read_states
|
35
27
|
kata = upload_kata
|
36
|
-
upload_states(XMLElementExtractor.extract('kata/id', kata))
|
37
28
|
finish_url = "#{@hostname}#{@@description_path}/#{XMLElementExtractor.extract('kata/uuid', kata)}"
|
38
29
|
summary_url = XMLElementExtractor.extract('kata/short-url', kata)
|
39
30
|
"Complete kata information at #{finish_url}"
|
40
31
|
end
|
41
32
|
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
def read_states
|
34
|
+
@state_reader.reset
|
35
|
+
while @state_reader.has_next_state
|
36
|
+
@states << @state_reader.read_next_state
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def upload_kata
|
41
|
+
kata_data = {:framework => @framework}
|
42
|
+
states_data = states.each_with_index do |state,index|
|
43
|
+
kata_data["states[#{index}]"] = {:code => state.code, :result => state.result, :created_at => state.time}
|
44
|
+
end
|
45
|
+
RestClient.post "#{@hostname}#{@@kata_path}", kata_data
|
45
46
|
end
|
46
47
|
|
47
48
|
private
|
data/bin/codersdojo
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
codersdojo start run-once.%sh% %kata_file%.py
|
@@ -0,0 +1 @@
|
|
1
|
+
py.test %kata_file%.py
|
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 6
|
10
|
+
version: 1.1.06
|
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-01
|
18
|
+
date: 2011-02-01 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- app/session_id_generator.rb
|
56
56
|
- app/shell_argument_exception.rb
|
57
57
|
- app/shell_wrapper.rb
|
58
|
+
- app/state.rb
|
58
59
|
- app/state_reader.rb
|
59
60
|
- app/text_converter.rb
|
60
61
|
- app/text_template_machine.rb
|
@@ -86,6 +87,10 @@ files:
|
|
86
87
|
- templates/javascript.vows/README
|
87
88
|
- templates/javascript.vows/run-endless.%sh%
|
88
89
|
- templates/javascript.vows/spec.js
|
90
|
+
- templates/python.pytest/%kata_file%.py
|
91
|
+
- templates/python.pytest/README
|
92
|
+
- templates/python.pytest/run-endless.%sh%
|
93
|
+
- templates/python.pytest/run-once.%sh%
|
89
94
|
- templates/python.pyunit/%kata_file%.py
|
90
95
|
- templates/python.pyunit/README
|
91
96
|
- templates/python.pyunit/run-endless.%sh%
|