Sha256: 025cc121c658f2d9419575d02b8707a72c6733617a4d2878f128967f2c92e2ee

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'rake/task'

module Rake
  class Task
    module StatePatch
      # overwriting the execute method to track the current state
      def execute(*args)
        @state = :running
        super
        @state = :done
      end
    end

    prepend StatePatch

    attr_reader :state

    # returns true, if this task was invoked
    # @return [Boolean]
    def invoked?
      !!@already_invoked
    end

    # returns true, if this task performed (executed)
    # @return [Boolean]
    def performed?
      @state == :done
    end

    # returns true, if this task is currently running
    # @return [Boolean]
    def running?
      @state == :running
    end

    # append the given block to the 'actions'-array
    # this method is chainable and returns self
    #
    # @param [Proc] block
    # @return [Rake::Task] self
    def append(&block)
      @actions << block
      self
    end

    # prepends the given block to the 'actions'-array
    # this method is chainable and returns self
    #
    # @param [Proc] block
    # @return [Rake::Task] self
    def prepend(&block)
      @actions.unshift(block)
      self
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_smart-support-1.5.0 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.4.0 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.3.0 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.2.0 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.1.1 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.1.0 lib/ruby_smart/support/core_ext/rake/task.rb
ruby_smart-support-1.0.0 lib/ruby_smart/support/core_ext/rake/task.rb