123456789_123456789_123456789_123456789_123456789_

Class: Rake::FileTask

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

Overview

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

Clear the task list.

.create_rule

Define a rule for synthesizing tasks.

.define_task

Define a task given args and an option block.

.format_deps

Format dependencies parameter to pass to task.

.new

Create a task named task_name with no actions or prerequisites.

.scope_name

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

.task_defined?

TRUE if the task name is already defined.

.tasks

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

#actions

List of actions attached to a task.

#already_invoked

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

#application

Application owning this task.

#comment

First line (or sentence) of all comments.

#locations

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).

#needed?

Is this task needed?

#order_only_prerequisites

List of order only prerequisites for a task.

#prereqs
#prerequisites

List of prerequisites for a task.

#scope

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

#sources,
#sources=

List of sources for task.

#comment=

Instance Method Summary

Task - Inherited

#add_description

Add a description to the task.

#all_prerequisite_tasks

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

#arg_names

Name of arguments for this task.

#clear

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

#clear_actions

Clear the existing actions on a rake task.

#clear_args

Clear the existing arguments on a rake task.

#clear_comments

Clear the existing comments on a rake task.

#clear_prerequisites

Clear the existing prerequisites of a rake task.

#enhance

Enhance a task with prerequisites or actions.

#execute

Execute the actions associated with this task.

#full_comment

Full collection of comments.

#investigation

Return a string describing the internal state of a task.

#invoke

Invoke the task if it is needed.

#name

Name of the task, including any namespace qualifiers.

#prerequisite_tasks

List of prerequisite tasks.

#reenable

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

#set_arg_names

Set the names of the arguments for this task.

#source

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

#timestamp

Timestamp for this task.

#to_s

Return task name.

#|

Add order only dependencies.

#invoke_with_call_chain

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

#first_sentence

Get the first sentence in a string.

#format_trace_flags

Format the trace flags for display.

#transform_comments

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

#arg_description

Argument description (nil if none).

#inspect,
#invoke_prerequisites

Invoke all the prerequisites of a task.

#invoke_prerequisites_concurrently

Invoke all the prerequisites of a task in parallel.

#name_with_args

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 53

def scope_name(scope, task_name)
  Rake.from_pathname(task_name)
end

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?
  begin
    out_of_date?(File.mtime(name)) || @application.options.build_all
  rescue Errno::ENOENT
    true
  end
end

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 36

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
    else
      prereq_task.timestamp > stamp
    end
  }
end

#timestamp

Time stamp for file task.

[ GitHub ]

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

def timestamp
  begin
    File.mtime(name)
  rescue Errno::ENOENT
    Rake::LATE
  end
end