class Thermite::Rails::Tasks::ProjectRakeTask
Base class to be used for creating Rake tasks for individual Projects.
Public Class Methods
new(project)
click to toggle source
@param project [Thermite::Rails::Project]
# File lib/thermite/rails/tasks/project_rake_task.rb, line 14 def initialize(project) @project = project @shell = Thor::Shell::Color.new end
Public Instance Methods
color_puts(message, color = :blue)
click to toggle source
@param message [String] @param color Whatever is supported by highline.
# File lib/thermite/rails/tasks/project_rake_task.rb, line 43 def color_puts(message, color = :blue) @shell.say "[#{crate_name}] #{message}", color end
crate_name_for_ruby()
click to toggle source
@param [String]
# File lib/thermite/rails/tasks/project_rake_task.rb, line 20 def crate_name_for_ruby crate_name.underscore end
define_rake_task()
click to toggle source
In your child class, this method should `define` the Rake task.
# File lib/thermite/rails/tasks/project_rake_task.rb, line 30 def define_rake_task return if Rake::Task.task_defined?(task_name) raise 'Define in child' end
defined?()
click to toggle source
@return [Boolean] Has a task with this name already been defined?
# File lib/thermite/rails/tasks/project_rake_task.rb, line 37 def defined? Rake::Task.task_defined?(task_name) end
task_name()
click to toggle source
@param [String]
# File lib/thermite/rails/tasks/project_rake_task.rb, line 25 def task_name raise 'Define in child' end
Private Instance Methods
load_and() { || ... }
click to toggle source
# File lib/thermite/rails/tasks/project_rake_task.rb, line 64 def load_and Dir.chdir(project_path) do load_rakefile do yield end end end
load_rakefile() { || ... }
click to toggle source
# File lib/thermite/rails/tasks/project_rake_task.rb, line 72 def load_rakefile load 'Rakefile' yield rescue LoadError => ex color_puts("Skipping due to LoadError: #{ex.message}", :red) end
run_task(task_name)
click to toggle source
@param task_name
[String]
# File lib/thermite/rails/tasks/project_rake_task.rb, line 50 def run_task(task_name) color_puts("Running task: #{task_name}", :blue) load_and do Rake::Task[task_name].invoke end rescue RuntimeError => ex if ex.message.match?("Don't know how to build task '#{task_name}'") color_puts("#{ex.message}; skipping", :yellow) else abort ex.message end end