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
tdiary-5.0.11 vendor/bundle/gems/rake-12.3.1/lib/rake/scope.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rake-12.3.0/lib/rake/scope.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/lib/rake/scope.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rake-12.3.0/lib/rake/scope.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/rake-12.2.1/lib/rake/scope.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/scope.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/lib/rake/scope.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/lib/rake/scope.rb
tdiary-5.0.9 vendor/bundle/gems/rake-12.3.1/lib/rake/scope.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/rake-12.3.1/lib/rake/scope.rb
sb_prime_table-0.1.1 vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/lib/rake/scope.rb
sb_prime_table-0.1.0 vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/lib/rake/scope.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/lib/rake/scope.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/rake-12.3.0/lib/rake/scope.rb
tdiary-5.0.8 vendor/bundle/gems/rake-12.3.1/lib/rake/scope.rb
rake-12.3.1 lib/rake/scope.rb
tdiary-5.0.7 vendor/bundle/gems/rake-12.3.0/lib/rake/scope.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/scope.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/scope.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/lib/rake/scope.rb