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
About the Author
About the Reviewers

Creating a folder with the directory method

Sometimes, you will have to create folders with nesting. You can create files and folders with file tasks. If you need to create a folder tree, you can achieve this with the file tasks' definitions and their dependencies. The following is an example of this usage:

file 'my_gem' do |t| mkdir end
file 'my_gem/tests" => ['my_gem'] do |t| mkdir end
file 'my_gem/tests/fixtures" => ['my_gem/tests/fixtures'] do |t|

When you try to execute the my_gem/tests/fixtures task, it will first call the dependent my_gem/tests task and then the call will be passed to the my_gem task. The tasks create folders with their name. Finally, we will have created a ready-to-use folder path, my_gem/tests/fixtures.

Another way is to use the FileUtils#mkdir_p method, which might be used in the task action or just in the Rakefile context. However, this is not the Rake way. There is a special way to define folder tasks in the Rake language:...