Sha256: 7c0ab2f0069adc6b0d6f1c8de1e3f5eebe0dd0b9f3a44ff1ba3ded7893d54fb4

Contents?: true

Size: 1.23 KB

Versions: 56

Compression:

Stored size: 1.23 KB

Contents

module Rake

  ####################################################################
  # InvocationChain tracks the chain of task invocations to detect
  # circular dependencies.
  class InvocationChain < LinkedList

    # Is the invocation already in the chain?
    def member?(invocation)
      head == invocation || tail.member?(invocation)
    end

    # Append an invocation to the chain of invocations. It is an error
    # if the invocation already listed.
    def append(invocation)
      if member?(invocation)
        fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
      end
      conj(invocation)
    end

    # Convert to string, ie: TOP => invocation => invocation
    def to_s
      "#{prefix}#{head}"
    end

    # Class level append.
    def self.append(invocation, chain)
      chain.append(invocation)
    end

    private

    def prefix
      "#{tail.to_s} => "
    end

    # Null object for an empty chain.
    class EmptyInvocationChain < LinkedList::EmptyLinkedList
      @parent = InvocationChain

      def member?(obj)
        false
      end

      def append(invocation)
        conj(invocation)
      end

      def to_s
        "TOP"
      end
    end

    EMPTY = EmptyInvocationChain.new
  end
end

Version data entries

56 entries across 55 versions & 11 rubygems

Version Path
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/invocation_chain.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/invocation_chain.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/invocation_chain.rb
plyom_user-0.3.1 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.3.0 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.9 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.8 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/invocation_chain.rb
vtd_xml-0.0.3-java bundle/jruby/1.9/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.7 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.6 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.5 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/invocation_chain.rb
plyom_user-0.2.4 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.3 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.2 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.1 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb
plyom_user-0.2.0 vendor/bundle/ruby/2.0.0/gems/rake-10.1.1/lib/rake/invocation_chain.rb