codersdojo 1.1.09 → 1.1.10
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.
- data/app/console_view.rb +24 -18
 - data/app/filename_formatter.rb +1 -5
 - data/app/scaffolder.rb +1 -11
 - data/app/shell_wrapper.rb +4 -0
 - data/app/text_template_machine.rb +15 -0
 - metadata +3 -3
 
    
        data/app/console_view.rb
    CHANGED
    
    | 
         @@ -1,13 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'shell_wrapper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'text_template_machine'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            class ConsoleView
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            	def initialize scaffolder
         
     | 
| 
       6 
7 
     | 
    
         
             
            		@scaffolder = scaffolder
         
     | 
| 
      
 8 
     | 
    
         
            +
            		@template_machine = TextTemplateMachineFactory.create ShellWrapper.new
         
     | 
| 
       7 
9 
     | 
    
         
             
            	end
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
            	def show_help
         
     | 
| 
       10 
     | 
    
         
            -
            		 
     | 
| 
      
 12 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       11 
13 
     | 
    
         
             
            CodersDojo-Client, http://www.codersdojo.org, Copyright by it-agile GmbH (http://www.it-agile.de)
         
     | 
| 
       12 
14 
     | 
    
         
             
            CodersDojo-Client automatically runs your code kata, logs the progress and uploads the kata to codersdojo.org.
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
         @@ -16,7 +18,7 @@ helptext 
     | 
|
| 
       16 
18 
     | 
    
         
             
            	end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
            	def show_usage
         
     | 
| 
       19 
     | 
    
         
            -
            		 
     | 
| 
      
 21 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       20 
22 
     | 
    
         
             
            Usage: #{$0} command [options]
         
     | 
| 
       21 
23 
     | 
    
         
             
            Commands:
         
     | 
| 
       22 
24 
     | 
    
         
             
              help, -h, --help                     Print this help text.
         
     | 
| 
         @@ -50,7 +52,7 @@ helptext 
     | 
|
| 
       50 
52 
     | 
    
         | 
| 
       51 
53 
     | 
    
         
             
            	def show_help_setup
         
     | 
| 
       52 
54 
     | 
    
         
             
            			templates = @scaffolder.list_templates
         
     | 
| 
       53 
     | 
    
         
            -
            			 
     | 
| 
      
 55 
     | 
    
         
            +
            			show <<-helptext
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
       55 
57 
     | 
    
         
             
            setup <framework> <kata_file_no_ext>  Setup the environment for the kata for the given framework and kata file.
         
     | 
| 
       56 
58 
     | 
    
         
             
                                                  The kata_file should not have an extension. Use 'prime' and not 'prime.java'.
         
     | 
| 
         @@ -58,13 +60,13 @@ setup <framework> <kata_file_no_ext>  Setup the environment for the kata for the 
     | 
|
| 
       58 
60 
     | 
    
         
             
                                                  Use ??? as framework if your framework isn't in the list.
         
     | 
| 
       59 
61 
     | 
    
         | 
| 
       60 
62 
     | 
    
         
             
            Example:
         
     | 
| 
       61 
     | 
    
         
            -
                 
     | 
| 
      
 63 
     | 
    
         
            +
                :%/%dojo%/%my_kata$ #{$0} setup ruby.test-unit prime
         
     | 
| 
       62 
64 
     | 
    
         
             
                    Show the instructions how to setup the environment for kata execution with Ruby and test/unit.
         
     | 
| 
       63 
65 
     | 
    
         
             
            helptext
         
     | 
| 
       64 
66 
     | 
    
         
             
            	end
         
     | 
| 
       65 
67 
     | 
    
         | 
| 
       66 
68 
     | 
    
         
             
            	def show_help_start
         
     | 
| 
       67 
     | 
    
         
            -
            		 
     | 
| 
      
 69 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       68 
70 
     | 
    
         | 
| 
       69 
71 
     | 
    
         
             
            start <shell_command> <kata_file>  Start the continuous test runner, that runs <shell-command> whenever <kata_file>
         
     | 
| 
       70 
72 
     | 
    
         
             
                                               changes. The <kata_file> has to include the whole source code of the kata.
         
     | 
| 
         @@ -74,7 +76,7 @@ helptext 
     | 
|
| 
       74 
76 
     | 
    
         
             
            	end
         
     | 
| 
       75 
77 
     | 
    
         | 
| 
       76 
78 
     | 
    
         
             
            	def show_help_upload
         
     | 
| 
       77 
     | 
    
         
            -
            		 
     | 
| 
      
 79 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       78 
80 
     | 
    
         | 
| 
       79 
81 
     | 
    
         
             
            upload                      Upload the newest kata session in .codersdojo to codersdojo.com.
         
     | 
| 
       80 
82 
     | 
    
         | 
| 
         @@ -82,16 +84,16 @@ upload <session_directory>  Upload the kata <session_directory> to codersdojo.co 
     | 
|
| 
       82 
84 
     | 
    
         
             
                                        <session_directory> is relative to the working directory.
         
     | 
| 
       83 
85 
     | 
    
         | 
| 
       84 
86 
     | 
    
         
             
            Examples:
         
     | 
| 
       85 
     | 
    
         
            -
                 
     | 
| 
      
 87 
     | 
    
         
            +
                :%/%dojo%/%my_kata$ #{$0} upload
         
     | 
| 
       86 
88 
     | 
    
         
             
                    Upload the newest kata located in directory ".codersdojo" to codersdojo.com.
         
     | 
| 
       87 
     | 
    
         
            -
                 
     | 
| 
       88 
     | 
    
         
            -
                    Upload the kata located in directory ".codersdojo 
     | 
| 
      
 89 
     | 
    
         
            +
                :%/%dojo%/%my_kata$ #{$0} upload .codersdojo%/%2010-11-02_16-21-53
         
     | 
| 
      
 90 
     | 
    
         
            +
                    Upload the kata located in directory ".codersdojo%/%2010-11-02_16-21-53" to codersdojo.com.
         
     | 
| 
       89 
91 
     | 
    
         
             
            helptext
         
     | 
| 
       90 
92 
     | 
    
         
             
            	end
         
     | 
| 
       91 
93 
     | 
    
         | 
| 
       92 
94 
     | 
    
         
             
            	def show_help_upload_with_framework
         
     | 
| 
       93 
95 
     | 
    
         
             
            		templates = @scaffolder.list_templates
         
     | 
| 
       94 
     | 
    
         
            -
            		 
     | 
| 
      
 96 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       95 
97 
     | 
    
         | 
| 
       96 
98 
     | 
    
         
             
            upload-with-framework <framework> [<session_directory>]  
         
     | 
| 
       97 
99 
     | 
    
         
             
                                                      Upload the kata written with <framework> in <session_directory> to codersdojo.com. 
         
     | 
| 
         @@ -101,36 +103,40 @@ upload-with-framework <framework> [<session_directory>] 
     | 
|
| 
       101 
103 
     | 
    
         
             
                                                      If you used another framework, use ??? and send an email to codersdojo@it-agile.de
         
     | 
| 
       102 
104 
     | 
    
         | 
| 
       103 
105 
     | 
    
         
             
            Example:
         
     | 
| 
       104 
     | 
    
         
            -
                 
     | 
| 
       105 
     | 
    
         
            -
                    Upload the kata (written in Ruby with the test/unit framework) located in directory ".codersdojo 
     | 
| 
      
 106 
     | 
    
         
            +
                :%/%dojo%/%my_kata$ #{$0} upload-with-framework ruby.test-unit .codersdojo%/%2010-11-02_16-21-53
         
     | 
| 
      
 107 
     | 
    
         
            +
                    Upload the kata (written in Ruby with the test/unit framework) located in directory ".codersdojo%/%2010-11-02_16-21-53" to codersdojo.com.
         
     | 
| 
       106 
108 
     | 
    
         
             
            helptext
         
     | 
| 
       107 
109 
     | 
    
         
             
            	end
         
     | 
| 
       108 
110 
     | 
    
         | 
| 
       109 
111 
     | 
    
         
             
            	def show_help_unknown command
         
     | 
| 
       110 
     | 
    
         
            -
            		 
     | 
| 
      
 112 
     | 
    
         
            +
            		show <<-helptext
         
     | 
| 
       111 
113 
     | 
    
         
             
            Command #{command} not known. Try '#{$0} help' to list the supported commands.
         
     | 
| 
       112 
114 
     | 
    
         
             
            helptext
         
     | 
| 
       113 
115 
     | 
    
         
             
            	end
         
     | 
| 
       114 
116 
     | 
    
         | 
| 
       115 
117 
     | 
    
         
             
            	def show_start_kata command, file, framework
         
     | 
| 
       116 
     | 
    
         
            -
            	   
     | 
| 
      
 118 
     | 
    
         
            +
            	  show "Starting CodersDojo-Client with command #{command} and kata file #{file} with framework #{framework}. Use Ctrl+C to finish the kata."		
         
     | 
| 
       117 
119 
     | 
    
         
             
            	end
         
     | 
| 
       118 
120 
     | 
    
         | 
| 
       119 
121 
     | 
    
         
             
            	def show_missing_command_argument_error command
         
     | 
| 
       120 
     | 
    
         
            -
            		 
     | 
| 
      
 122 
     | 
    
         
            +
            		show "Command <#{command}> recognized but no argument was provided (at least one argument is required).\n\n"
         
     | 
| 
       121 
123 
     | 
    
         
             
            		show_usage
         
     | 
| 
       122 
124 
     | 
    
         
             
            	end
         
     | 
| 
       123 
125 
     | 
    
         | 
| 
       124 
126 
     | 
    
         
             
            	def show_upload_start session_directory, hostname, framework
         
     | 
| 
       125 
     | 
    
         
            -
            		 
     | 
| 
      
 127 
     | 
    
         
            +
            		show "Start upload from #{session_directory} with framework #{framework} to #{hostname}"
         
     | 
| 
       126 
128 
     | 
    
         
             
            	end
         
     | 
| 
       127 
129 
     | 
    
         | 
| 
       128 
130 
     | 
    
         
             
            	def show_upload_result result
         
     | 
| 
       129 
     | 
    
         
            -
            		 
     | 
| 
      
 131 
     | 
    
         
            +
            		show result
         
     | 
| 
       130 
132 
     | 
    
         
             
            	end
         
     | 
| 
       131 
133 
     | 
    
         | 
| 
       132 
134 
     | 
    
         
             
            	def show_socket_error command
         
     | 
| 
       133 
     | 
    
         
            -
            		 
     | 
| 
      
 135 
     | 
    
         
            +
            		show "Encountered network error while <#{command}>. Is http://www.codersdojo.com down?"
         
     | 
| 
      
 136 
     | 
    
         
            +
            	end
         
     | 
| 
      
 137 
     | 
    
         
            +
            	
         
     | 
| 
      
 138 
     | 
    
         
            +
            	def show text
         
     | 
| 
      
 139 
     | 
    
         
            +
            		puts @template_machine.render(text)
         
     | 
| 
       134 
140 
     | 
    
         
             
            	end
         
     | 
| 
       135 
141 
     | 
    
         | 
| 
       136 
142 
     | 
    
         
             
            end
         
     | 
    
        data/app/filename_formatter.rb
    CHANGED
    
    | 
         @@ -40,13 +40,9 @@ class FilenameFormatter 
     | 
|
| 
       40 
40 
     | 
    
         
             
              end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
              def extract_last_path_item dir_path
         
     | 
| 
       43 
     | 
    
         
            -
            	  last = dir_path.split(dir_separator).last
         
     | 
| 
      
 43 
     | 
    
         
            +
            	  last = dir_path.split(ShellWrapper.new.dir_separator).last
         
     | 
| 
       44 
44 
     | 
    
         
             
            		last.nil? ? "" : last
         
     | 
| 
       45 
45 
     | 
    
         
             
            	end
         
     | 
| 
       46 
     | 
    
         
            -
            	
         
     | 
| 
       47 
     | 
    
         
            -
            	def dir_separator
         
     | 
| 
       48 
     | 
    
         
            -
            		File::ALT_SEPARATOR ? File::ALT_SEPARATOR : File::SEPARATOR
         
     | 
| 
       49 
     | 
    
         
            -
            	end
         
     | 
| 
       50 
46 
     | 
    
         | 
| 
       51 
47 
     | 
    
         
             
            end
         
     | 
| 
       52 
48 
     | 
    
         | 
    
        data/app/scaffolder.rb
    CHANGED
    
    | 
         @@ -6,17 +6,7 @@ class Scaffolder 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            	def initialize shell
         
     | 
| 
       8 
8 
     | 
    
         
             
            		@shell = shell
         
     | 
| 
       9 
     | 
    
         
            -
            		@template_machine =  
     | 
| 
       10 
     | 
    
         
            -
            	end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            	def create_template_machine
         
     | 
| 
       13 
     | 
    
         
            -
            		template_machine = TextTemplateMachine.new @shell
         
     | 
| 
       14 
     | 
    
         
            -
            		template_machine.placeholder_values = {
         
     | 
| 
       15 
     | 
    
         
            -
            			'sh' => @shell.shell_extension,
         
     | 
| 
       16 
     | 
    
         
            -
            			':' => @shell.path_separator,
         
     | 
| 
       17 
     | 
    
         
            -
            			'rm' => @shell.remove_command_name
         
     | 
| 
       18 
     | 
    
         
            -
            		}
         
     | 
| 
       19 
     | 
    
         
            -
            		template_machine
         
     | 
| 
      
 9 
     | 
    
         
            +
            		@template_machine = TextTemplateMachineFactory.create @shell
         
     | 
| 
       20 
10 
     | 
    
         
             
            	end
         
     | 
| 
       21 
11 
     | 
    
         | 
| 
       22 
12 
     | 
    
         
             
            	def list_templates
         
     | 
    
        data/app/shell_wrapper.rb
    CHANGED
    
    | 
         @@ -106,6 +106,10 @@ class ShellWrapper 
     | 
|
| 
       106 
106 
     | 
    
         
             
            		windows? ? ';' : ':'
         
     | 
| 
       107 
107 
     | 
    
         
             
            	end
         
     | 
| 
       108 
108 
     | 
    
         | 
| 
      
 109 
     | 
    
         
            +
            	def dir_separator
         
     | 
| 
      
 110 
     | 
    
         
            +
            		File::ALT_SEPARATOR ? File::ALT_SEPARATOR : File::SEPARATOR
         
     | 
| 
      
 111 
     | 
    
         
            +
            	end
         
     | 
| 
      
 112 
     | 
    
         
            +
            	
         
     | 
| 
       109 
113 
     | 
    
         
             
            	def windows?
         
     | 
| 
       110 
114 
     | 
    
         
             
            		platform = RUBY_PLATFORM.downcase
         
     | 
| 
       111 
115 
     | 
    
         
             
            		platform.include?("windows") or platform.include?("mingw32")
         
     | 
| 
         @@ -24,3 +24,18 @@ class TextTemplateMachine 
     | 
|
| 
       24 
24 
     | 
    
         
             
            	end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            class TextTemplateMachineFactory
         
     | 
| 
      
 29 
     | 
    
         
            +
            	
         
     | 
| 
      
 30 
     | 
    
         
            +
            	def self.create shell
         
     | 
| 
      
 31 
     | 
    
         
            +
            		template_machine = TextTemplateMachine.new shell
         
     | 
| 
      
 32 
     | 
    
         
            +
            		template_machine.placeholder_values = {
         
     | 
| 
      
 33 
     | 
    
         
            +
            			'sh' => shell.shell_extension,
         
     | 
| 
      
 34 
     | 
    
         
            +
            			':' => shell.path_separator,
         
     | 
| 
      
 35 
     | 
    
         
            +
            			'/' => shell.dir_separator,
         
     | 
| 
      
 36 
     | 
    
         
            +
            			'rm' => shell.remove_command_name
         
     | 
| 
      
 37 
     | 
    
         
            +
            		}
         
     | 
| 
      
 38 
     | 
    
         
            +
            		template_machine
         
     | 
| 
      
 39 
     | 
    
         
            +
            	end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            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: 7
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 1
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1.1. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 10
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.1.10
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - CodersDojo-Team
         
     |