Class: Rake::FileTask

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Task
Instance Chain:
self, Task
Inherits: Rake::Task
Defined in: lib/rake/file_task.rb


A FileTask is a task that includes time based dependencies. If any of a FileTask's prerequisites have a timestamp that is later than the file represented by this task, then the file must be rebuilt (using the supplied actions).

Class Method Summary

Task - Inherited


Return a task with the given name.


Clear the task list.


Define a rule for synthesizing tasks.


Define a task given args and an option block.


Format dependencies parameter to pass to task.


Create a task named task_name with no actions or prerequisites.


Apply the scope to the task name according to the rules for this kind of task.


TRUE if the task name is already defined.


List of all defined tasks.

Instance Attribute Summary

  • #needed? ⇒ Boolean readonly

    Is this file task needed? Yes if it doesn't exist, or if its time stamp is out of date.

Task - Inherited


List of actions attached to a task.


Has this task already been invoked? Already invoked tasks will be skipped unless you reenable them.


Application owning this task.


First line (or sentence) of all comments.


File/Line locations of each of the task definitions for this task (only valid if the task was defined with the detect location option set).


Is this task needed?


List of order only prerequisites for a task.


List of prerequisites for a task.


Array of nested namespaces names used for task lookup by this task.


List of sources for task.


Instance Method Summary

Task - Inherited


Add a description to the task.


List of all unique prerequisite tasks including prerequisite tasks' prerequisites.


Name of arguments for this task.


Clear the existing prerequisites, actions, comments, and arguments of a rake task.


Clear the existing actions on a rake task.


Clear the existing arguments on a rake task.


Clear the existing comments on a rake task.


Clear the existing prerequisites of a rake task.


Enhance a task with prerequisites or actions.


Execute the actions associated with this task.


Full collection of comments.


Return a string describing the internal state of a task.


Invoke the task if it is needed.


Name of the task, including any namespace qualifiers.


List of prerequisite tasks.


Reenable the task, allowing its tasks to be executed if the task is invoked again.


Set the names of the arguments for this task.


First source from a rule (nil if no sources).


Timestamp for this task.


Return task name.


Add order only dependencies.


Same as invoke, but explicitly pass a call chain to detect circular dependencies.


Get the first sentence in a string.


Format the trace flags for display.


Transform the list of comments as specified by the block and join with the separator.


Argument description (nil if none).


Invoke all the prerequisites of a task.


Invoke all the prerequisites of a task in parallel.


Name of task with argument list description.

#collect_prerequisites, #add_chain_to, #add_comment, #lookup_prerequisite

Constructor Details

This class inherits a constructor from Rake::Task

Class Method Details

.scope_name(scope, task_name)

Apply the scope to the task name according to the rules for this kind of task. File based tasks ignore the scope when creating the name.

[ GitHub ]

# File 'lib/rake/file_task.rb', line 49

def scope_name(scope, task_name)

Instance Attribute Details

#needed?Boolean (readonly)

Is this file task needed? Yes if it doesn't exist, or if its time stamp is out of date.

[ GitHub ]

# File 'lib/rake/file_task.rb', line 16

def needed?
  !File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all

Instance Method Details

#out_of_date?(stamp) ⇒ Boolean (private)

Are there any prerequisites with a later time than the given time stamp?

[ GitHub ]

# File 'lib/rake/file_task.rb', line 32

def out_of_date?(stamp)
  all_prerequisite_tasks.any? { |prereq|
    prereq_task = application[prereq, @scope]
    if prereq_task.instance_of?(Rake::FileTask)
      prereq_task.timestamp > stamp || @application.options.build_all
      prereq_task.timestamp > stamp


Time stamp for file task.

[ GitHub ]

# File 'lib/rake/file_task.rb', line 21

def timestamp
  if File.exist?(name)