Skip to content

Instantly share code, notes, and snippets.

@metaskills
Last active August 29, 2015 13:55
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 metaskills/8691558 to your computer and use it in GitHub Desktop.
Save metaskills/8691558 to your computer and use it in GitHub Desktop.
Using Thor Actions In Rake Tasks
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
@metaskills
Copy link
Author

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 and rake only and I even have rake completions all setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment