Last active
August 29, 2015 13:55
-
-
Save metaskills/8691558 to your computer and use it in GitHub Desktop.
Using Thor Actions In Rake Tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thor' | |
namespace :myns do | |
class Hammer < Thor | |
include Thor::Actions | |
end | |
desc "Some task." | |
task :cleanup_files do | |
assets = Rails.root.join 'vendor/assets' | |
hammer :gsub_file, assets.join('some.file'), /garbage/, 'gmoney' | |
end | |
private | |
def hammer(*args) | |
Hammer.new.send *args | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like using Rake and did not want to make a new thor setup and have to remember which actions are tasks in Rake vs Thor. Besdies, my Spring binstubs are for
rails
andrake
only and I even have rake completions all setup.