Sha256: 3956e9e74b48300facd0d77afbbe22f397d7b7a3035e6dd196a3d47c5ec82298

Contents?: true

Size: 899 Bytes

Versions: 27

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true
module Rake
  class Scope < LinkedList # :nodoc: all

    # Path for the scope.
    def path
      map(&:to_s).reverse.join(":")
    end

    # Path for the scope + the named path.
    def path_with_task_name(task_name)
      "#{path}:#{task_name}"
    end

    # Trim +n+ innermost scope levels from the scope. In no case will
    # this trim beyond the toplevel scope.
    def trim(n)
      result = self
      while n > 0 && ! result.empty?
        result = result.tail
        n -= 1
      end
      result
    end

    # Scope lists always end with an EmptyScope object. See Null
    # Object Pattern)
    class EmptyScope < EmptyLinkedList
      @parent = Scope

      def path
        ""
      end

      def path_with_task_name(task_name)
        task_name
      end
    end

    # Singleton null object for an empty scope.
    EMPTY = EmptyScope.new
  end
end

Version data entries

27 entries across 22 versions & 7 rubygems

Version Path
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/scope.rb
rake-12.3.0 lib/rake/scope.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rake-12.1.0/lib/rake/scope.rb
rake-12.2.1 lib/rake/scope.rb
rake-12.2.0 lib/rake/scope.rb
tdiary-5.0.6 vendor/bundle/gems/rake-12.1.0/lib/rake/scope.rb
rake-12.1.0 lib/rake/scope.rb