Skip to content

Instantly share code, notes, and snippets.

@samkim
Created April 12, 2013 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samkim/5375860 to your computer and use it in GitHub Desktop.
Save samkim/5375860 to your computer and use it in GitHub Desktop.
Meta rake file that collects tasks in other rake files
require "rubygems"
require "rake"
Rake::TaskManager.record_task_metadata = true
puts "Begin loading tasks"
# Import rake scripts from the following directories:
[
'build',
'deploy'
].each do |dir|
Dir.glob("#{dir}/*.rake").each do |file|
puts "Loading #{file}"
import file
end
end
puts "Done loading tasks"
puts
# Require user to specify an action before doing anything
desc "Show usage info by default"
task :default => [:usage]
desc "Show overview of available tasks"
task :usage do
# Using heredocs, excuse the weird formatting
# Overview info
puts <<INTRO
Rake development tasks
Usage: rake <task> <options>
INTRO
# List and describe all available tasks
puts <<TASKS
Available tasks:
====================
TASKS
Rake.application.tasks.each do |task|
puts "#{task.name} - #{task.comment}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment