Book Image

Rake Task Management Essentials

By : Andrey Koleshko
Book Image

Rake Task Management Essentials

By: Andrey Koleshko

Overview of this book

Table of Contents (18 chapters)
Rake Task Management Essentials
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Thor – the next generation of Rake


There is a tool that can be used as an alternative to Rake and promises to get rid of Rake's disadvantage—parsing command-line arguments (as you can remember from Chapter 1, The Software Task Management Tool – Rake, it was a little bit inconvenient). The tool is Thor (official page: http://whatisthor.com). Another advantage of this tool is a great feature that is completely absent in Rake—generators. For example, Rails uses Thor's generators to generate a skeleton for an application.

Now, let's create some test task of Thor. Say, the task should just get an optional argument, an e-mail, and just write this to the standard output. Just create this file with the following code and the name test.thor:

class Test < Thor
  desc 'send_email', 'Send mail'
  method_option :email,
    :aliases => '-e',
    :desc => 'email of a recipient'
  def send_email
    puts "Recipient: #{options[:email]}"
  end
end

Now if you have installed Thor, you will be able to...