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

Using file tasks to work with files

Often, you have to transform files from one type to another using a utility. For example, compiling source code to byte code in a language such as C or Java, or converting PNG images to JPG, and so on. For these challenges, Rake has many useful arms in its arsenal.

Assume that we have a Ruby project and it has a YAML-generated config file ending with .yaml and, for some reason, we have decided to rename it so that it ends with .yml. This process might have to be repeated very often as the file is generated by a third-party tool. Hence, we have to automate this process. We could do it manually with the following command:

$ mv settings.yaml settings.yml

The Rake produces a special type of task for cases like this. This is the file task. To define a file task, use a file method. The usage of this task is similar to general tasks. Honestly, it inherits all the general task behaviors. In a file task, we can set the prerequisites and write a task action or set...