Methods
D
F
I
L
N
O
P
R
S
Attributes
[RW] separator
Class Public methods
new(*list)
# File tool/vpath.rb, line 5
def initialize(*list)
  @list = list
  @additional = []
  @separator = nil
end
Instance Public methods
def_options(opt)
# File tool/vpath.rb, line 54
def def_options(opt)
  opt.on("-I", "--srcdir=DIR", "add a directory to search path") {|dir|
    @additional << dir
  }
  opt.on("-L", "--vpath=PATH LIST", "add directories to search path") {|dirs|
    @additional << [dirs]
  }
  opt.on("--path-separator=SEP", /\A(?:\W\z|\.(\W).+)/, "separator for vpath") {|sep, vsep|
    # hack for msys make.
    @separator = vsep || sep
  }
end
foreach(file, *args, &block)
# File tool/vpath.rb, line 50
def foreach(file, *args, &block)
  open(file) {|f| f.each(*args, &block)}
end
inspect()
# File tool/vpath.rb, line 11
def inspect
  list.inspect
end
list()
# File tool/vpath.rb, line 67
def list
  @additional.reject! do |dirs|
    case dirs
    when String
      @list << dirs
    when Array
      raise "--path-separator option is needed for vpath list" unless @separator
      # @separator ||= (require 'rbconfig'; RbConfig::CONFIG["PATH_SEPARATOR"])
      @list.concat(dirs[0].split(@separator))
    end
    true
  end
  @list
end
lstat(*args, &block)
Alias for: process
open(*args)
# File tool/vpath.rb, line 33
def open(*args)
  f = search(File.method(:open), *args)
  if block_given?
    begin
      yield f
    ensure
      f.close unless f.closed?
    end
  else
    f
  end
end
process(*args, &block)
Also aliased as: stat, lstat
# File tool/vpath.rb, line 26
def process(*args, &block)
  search(File.method(__callee__), *args, &block)
end
read(*args)
# File tool/vpath.rb, line 46
def read(*args)
  open(*args) {|f| f.read}
end
# File tool/vpath.rb, line 15
def search(meth, base, *rest)
  begin
    meth.call(base, *rest)
  rescue Errno::ENOENT => error
    list.each do |dir|
      return meth.call(File.join(dir, base), *rest) rescue nil
    end
    raise error
  end
end
stat(*args, &block)
Alias for: process
strip(path)
# File tool/vpath.rb, line 82
def strip(path)
  prefix = list.map {|dir| Regexp.quote(dir)}
  path.sub(/\A#{prefix.join('|')}(?:\/|\z)/, '')
end