Sha256: 8c89ad2c65f66c68695db42d7e56cc2b5666b0ac68005e6f23f4514765827018

Contents?: true

Size: 611 Bytes

Versions: 6

Compression:

Stored size: 611 Bytes

Contents

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake/tasklib'

module Rake

  # A task whick is no longer needed after its first invocation
  class OnceTask < Task

    attr_accessor :invoked
    attr_accessor :timestamp

    def self.define_task( *args, &block )
      task = super( *args, &block )
      task.timestamp = nil
      task.invoked = false
      task
    end

    def execute(*args)
      @timestamp = Time.now
      @invoked = true
      super(*args)
    end

    def needed?
      ! @invoked
    end

  end

end

def once_task(*args, &block)
  Rake::OnceTask.define_task(*args, &block)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rake-builder-0.7.0 lib/rake/once_task.rb
rake-builder-0.0.19 lib/rake/once_task.rb
rake-builder-0.0.18 lib/rake/once_task.rb
rake-builder-0.0.17 lib/rake/once_task.rb
rake-builder-0.0.16 lib/rake/once_task.rb
rake-builder-0.0.15 lib/rake/once_task.rb