Sha256: 7580222cb501491f856e306269862d83fa2aac226febc210ebd81d9c2abcf099

Contents?: true

Size: 1.02 KB

Versions: 8

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.dup : 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

8 entries across 8 versions & 2 rubygems

Version Path
scout-essentials-1.3.1 lib/scout/path.rb
scout-essentials-1.3.0 lib/scout/path.rb
scout-essentials-1.2.0 lib/scout/path.rb
scout-essentials-1.1.1 lib/scout/path.rb
scout-essentials-1.1.0 lib/scout/path.rb
scout-essentials-1.0.0 lib/scout/path.rb
scout-gear-9.1.0 lib/scout/path.rb
scout-gear-9.0.0 lib/scout/path.rb