codersdojo 1.1.14 → 1.1.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ class ArgumentParser
13
13
  if command == "help" then
14
14
  @controller.help params[1]
15
15
  elsif command == "setup" then
16
- @controller.generate params[1], params[2] ? params[2] : '<kata_file>'
16
+ @controller.generate params[1], params[2]
17
17
  elsif command == "upload" then
18
18
  @controller.upload params[1]
19
19
  elsif command == "upload-with-framework" then
data/app/console_view.rb CHANGED
@@ -54,10 +54,9 @@ helptext
54
54
  templates = @scaffolder.list_templates
55
55
  show <<-helptext
56
56
 
57
- setup <framework> <kata_file_no_ext> Setup the environment for the kata for the given framework and kata file.
58
- The kata_file should not have an extension. Use 'prime' and not 'prime.java'.
59
- By now <framework> is one of #{templates}.
60
- Use ??? as framework if your framework isn't in the list.
57
+ setup <framework> <kata_file> Setup the environment for the kata for the given framework and kata file.
58
+ By now <framework> is one of #{templates}.
59
+ Use ??? as framework if your framework isn't in the list.
61
60
 
62
61
  Example:
63
62
  :%/%dojo%/%my_kata$ #{current_command_path} setup ruby.test-unit prime
@@ -118,9 +117,9 @@ helptext
118
117
  show "Starting CodersDojo-Client with command #{command} and kata file #{file} with framework #{framework}. Use Ctrl+C to finish the kata."
119
118
  end
120
119
 
121
- def show_missing_command_argument_error command
122
- show "Command <#{command}> recognized but no argument was provided (at least one argument is required).\n\n"
123
- show_usage
120
+ def show_missing_command_argument_error command, missing_argument
121
+ show "Command <#{command}> recognized but argument <#{missing_argument}> was missing.\n"
122
+ eval "show_help_#{command}"
124
123
  end
125
124
 
126
125
  def show_upload_start session_directory, hostname, framework
@@ -135,6 +134,12 @@ helptext
135
134
  show "Encountered network error while <#{command}>. Is http://www.codersdojo.com down?"
136
135
  end
137
136
 
137
+ def show_unknown_framework_error framework, templates
138
+ show "Unkown framework #{framework}. Possible frameworks:"
139
+ show templates
140
+ show "Use ??? as framework if your framework isn't in the list."
141
+ end
142
+
138
143
  def show_kata_exit_message
139
144
  show <<-msg
140
145
 
data/app/controller.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'scheduler'
2
2
  require 'uploader'
3
+ require 'filename_formatter'
3
4
 
4
5
  class Controller
5
6
 
@@ -8,6 +9,7 @@ class Controller
8
9
  @view = view
9
10
  @scaffolder = scaffolder
10
11
  @hostname = hostname
12
+ @filename_formatter = FilenameFormatter.new
11
13
  end
12
14
 
13
15
  def help command=nil
@@ -19,12 +21,15 @@ class Controller
19
21
  end
20
22
 
21
23
  def generate framework, kata_file
24
+ if not kata_file then
25
+ @view.show_missing_command_argument_error "setup", "kata_file"
26
+ return
27
+ end
22
28
  begin
23
29
  @scaffolder.scaffold framework, kata_file
24
- puts "\n" + @shell.read_file("README")
30
+ @view.show "\n" + @shell.read_file("README")
25
31
  rescue
26
- puts "Unkown framework #{framework}. Possible frameworks:"
27
- puts @scaffolder.list_templates
32
+ @view.show_unknown_framework_error framework, @scaffolder.list_templates
28
33
  end
29
34
  end
30
35
 
@@ -39,6 +39,14 @@ class FilenameFormatter
39
39
  "#{CODERSDOJO_WORKSPACE}/#{session_id}"
40
40
  end
41
41
 
42
+ def without_extension filename
43
+ if filename.include? '.' then
44
+ filename.split('.')[0..-2].join('.')
45
+ else
46
+ filename
47
+ end
48
+ end
49
+
42
50
  def extract_last_path_item dir_path
43
51
  last = dir_path.split(ShellWrapper.new.dir_separator).last
44
52
  last.nil? ? "" : last
data/app/scaffolder.rb CHANGED
@@ -7,6 +7,7 @@ class Scaffolder
7
7
  def initialize shell
8
8
  @shell = shell
9
9
  @template_machine = TextTemplateMachineFactory.create @shell
10
+ @filename_formatter = FilenameFormatter.new
10
11
  end
11
12
 
12
13
  def list_templates
@@ -16,7 +17,8 @@ class Scaffolder
16
17
  end
17
18
 
18
19
  def scaffold template, kata_file
19
- @template_machine.placeholder_values['kata_file'] = kata_file
20
+ @template_machine.placeholder_values['kata_file.ext'] = kata_file
21
+ @template_machine.placeholder_values['kata_file'] = @filename_formatter.without_extension kata_file
20
22
  template = template == '???' ? ANY_TEMPLATE : template
21
23
  dir_path = "#{template_path}/#{template}"
22
24
  to_copy = @shell.real_dir_entries dir_path
data/templates/any/README CHANGED
@@ -8,4 +8,4 @@ run-once.%sh% is not implemented by now. You have to implement it appropriately.
8
8
  Run run-endless.%sh% and start your kata. (On Mac/Linux you have to call ./run-endless.%sh%.)
9
9
 
10
10
  Assumptions:
11
- - The whole kata source code is in the one %kata_file%.
11
+ - The whole kata source code is in the one %kata_file.ext%.
@@ -1 +1 @@
1
- codersdojo start run-once.%sh% %kata_file%
1
+ codersdojo start run-once.%sh% %kata_file.ext%
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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 14
10
- version: 1.1.14
9
+ - 15
10
+ version: 1.1.15
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-02-09 00:00:00 +01:00
18
+ date: 2011-02-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency