Sha256: 81efedf724391c43baf3dcb2139befbcad4c76e12a725381a8bdc234ef205f76

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require_relative 'meta_extension'
require_relative 'path/find'
require_relative 'path/util'
require_relative 'path/tmpfile'

module Path
  extend MetaExtension
  extension_attr :pkgdir, :libdir, :path_maps

  def self.default_pkgdir
    @@default_pkgdir ||= 'scout'
  end
  
  def self.default_pkgdir=(pkgdir)
    @@default_pkgdir = pkgdir
  end

  def pkgdir
    @pkgdir ||= Path.default_pkgdir
  end

  def libdir
    @libdir || Path.caller_lib_dir
  end

  def path_maps
    @path_maps ||= Path.path_maps.dup
  end

  def join(subpath, prevpath = nil)
    subpath = subpath.to_s if Symbol === subpath
    prevpath = prevpath.to_s if Symbol === prevpath

    subpath = File.join(prevpath.to_s, subpath) if prevpath
    new = self.empty? ? subpath : File.join(self, subpath)
    self.annotate(new)
    new
  end

  alias [] join
  alias / join

  def method_missing(name, prev = nil, *args, &block)
    if block_given? || name.to_s.start_with?('to_')
      super name, prev, *args, &block
    else
      join(name, prev)
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scout-gear-8.1.0 lib/scout/path.rb
scout-gear-8.0.0 lib/scout/path.rb
scout-gear-7.3.0 lib/scout/path.rb
scout-gear-7.2.0 lib/scout/path.rb
scout-gear-7.1.0 lib/scout/path.rb
scout-gear-6.0.0 lib/scout/path.rb
scout-gear-5.2.0 lib/scout/path.rb