Sha256: d15c3063920b4541ce9bd8d33be2b5f46aaa69d6d53413c23d6acde122a36e1d

Contents?: true

Size: 1.16 KB

Versions: 33

Compression:

Stored size: 1.16 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

33 entries across 26 versions & 7 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/rake-10.3.2/lib/rake/invocation_chain.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb
spline-0.0.11 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb