Sha256: 78c84600fc64827ce3a199c5ac16dff0757dd796281abb1fd9653bc7efaa5f32

Contents?: true

Size: 634 Bytes

Versions: 5

Compression:

Stored size: 634 Bytes

Contents

$LOAD_PATH.instance_eval do
  def find_file(file)
    find_all_files(file){|f| return f}
    nil
  end

  def find_all_files(file, ext = nil)
    file += ext if ext and File.extname(file) != ext
    inject([]){|ary, path| 
      target = File.expand_path(file, path)
      if File.readable?(target)
        ary << target
        yield target if block_given?
      end
      ary
    }
  end

  def add_current
    add(__DIR_REL__(caller.first))
  end

  def add_current!
    add!(__DIR_REL__(caller.first))
  end

  def add(path)
    push(path) unless include?(path)
  end

  def add!(path)
    delete(path)
    unshift(path)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
callsite-0.0.11 lib/loaders/load_path.rb
callsite-0.0.6 lib/loaders/load_path.rb
callsite-0.0.5 lib/loaders/load_path.rb
callsite-0.0.4 lib/loaders/load_path.rb
callsite-0.0.3 lib/loaders/load_path.rb