Sha256: 854558635749fdcab6997394dd2380c301fa5f8d03202600277d167a50367d27

Contents?: true

Size: 1.28 KB

Versions: 215

Compression:

Stored size: 1.28 KB

Contents

require 'rake/task.rb'
require 'rake/early_time'

module Rake
  # #########################################################################
  # 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 FileTask < Task

    # Is this file task needed?  Yes if it doesn't exist, or if its time stamp
    # is out of date.
    def needed?
      ! File.exist?(name) || out_of_date?(timestamp)
    end

    # Time stamp for file task.
    def timestamp
      if File.exist?(name)
        File.mtime(name.to_s)
      else
        Rake::EARLY
      end
    end

    private

    # Are there any prerequisites with a later time than the given time stamp?
    def out_of_date?(stamp)
      @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
    end

    # ----------------------------------------------------------------
    # Task class methods.
    #
    class << self
      # 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.
      def scope_name(scope, task_name)
        task_name
      end
    end
  end
end

Version data entries

215 entries across 169 versions & 43 rubygems

Version Path
challah-rolls-0.2.0 vendor/bundle/gems/rake-10.0.1/lib/rake/file_task.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/rake-10.0.1/lib/rake/file_task.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb
challah-rolls-0.2.0 vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb
challah-0.8.3 vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb
challah-0.8.3 vendor/bundle/gems/rake-10.0.1/lib/rake/file_task.rb
rake-10.0.1 lib/rake/file_task.rb
rake-0.9.4 lib/rake/file_task.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_task.rb
rake-10.0.0 lib/rake/file_task.rb
rake-0.9.3 lib/rake/file_task.rb
rake-0.9.3.beta.4 lib/rake/file_task.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_task.rb
rake-10.0.0.beta.2 lib/rake/file_task.rb
rake-10.0.0.beta.1 lib/rake/file_task.rb
rake-0.9.3.beta.3 lib/rake/file_task.rb
rake-0.9.3.beta.2 lib/rake/file_task.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_task.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_task.rb