Class: Exercise::Command
- Inherits:
-
Thor
- Object
- Thor
- Exercise::Command
- Defined in:
- lib/commands/exercise/command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
146 147 148 |
# File 'lib/commands/exercise/command.rb', line 146 def self.exit_on_failure? true end |
Instance Method Details
#create(name) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/commands/exercise/command.rb', line 195 def create(name) say "Creating new exercise: #{name}" FileUtils.mkdir_p(name) exercise_structure['directories'].each do |directory| FileUtils.mkdir_p("#{name}/#{directory}") end FileUtils.cp_r("#{scaffold_path}/.", name) all_files_in(name).each { |path| say "Created: #{path}" } say ok 'Complete' end |
#generate(path = '.') ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/commands/exercise/command.rb', line 180 def generate(path = '.') register_environment([:environment_variables]) templates = File.directory?(path) ? templates(path) : [path] original_dir = Dir.pwd failures = all_updated(templates, original_dir).find_all do |template| process_template(original_dir, template) end raise CourseContentRenderingError, failures.collect(&:path) unless failures.empty? end |
#requiring_update(path = '.') ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/commands/exercise/command.rb', line 157 def requiring_update(path = '.') directories = if File.directory?(path) templates(path) else [template] end results = directories.find_all do |temp| template_updated?(temp, Dir.pwd) end.flatten say results.to_json end |