class Rake::DataTask::DataTask

Public Class Methods

new(data, app) click to toggle source

Instantiate a new DataTask.

@param [Data] data the Data object that keeps track of existence and modification @param [Rake::Application] app required by the parent class’s constructor

Calls superclass method
# File lib/data_task.rb, line 21
def initialize(data, app)
  super
  @data = data
end

Private Class Methods

scope_name(scope, task_name) click to toggle source

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

# File lib/data_task.rb, line 61
def scope_name(scope, task_name)
  task_name
end

Public Instance Methods

needed?() click to toggle source

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

# File lib/data_task.rb, line 28
def needed?
  !@data.exist? || out_of_date?(timestamp)
end
timestamp() click to toggle source

Time stamp for data task.

# File lib/data_task.rb, line 33
def timestamp
  if @data.exist?
    mtime = @data.mtime.to_time
    raise "Table #{name} exists but modified time is unavailable." if mtime.nil?
    mtime
  else
    Rake::EARLY
  end
end

Private Instance Methods

out_of_date?(stamp) click to toggle source

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

# File lib/data_task.rb, line 46
def out_of_date?(stamp)
  @prerequisites.any? do |n| 
    prereq_time = application[n, @scope].timestamp
    return false if prereq_time == Rake::EARLY

    prereq_time > stamp
  end
end