Sha256: 6131066e059102dd75b8d5fb861f693834e6a99e5d7f66a474db374f7ee067c2

Contents?: true

Size: 436 Bytes

Versions: 4

Compression:

Stored size: 436 Bytes

Contents

# Extend the File class to add a function to check for a file in the 
# load path.

class File
  # find a file in the load path or raise an exception if the file can
  # not be found.
  def File.find_file_in_path(filename)
    $:.each do |path|
      file_with_path = path+'/'+filename
      return file_with_path if file?(file_with_path) 
    end
  
    raise ArgumentError, "Can't find file #{filename} in Ruby library path"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tartan-0.2.1 lib/core_ext/file.rb
tartan-0.1.1 lib/core_ext/file.rb
tartan-0.1.0 lib/core_ext/file.rb
tartan-0.2.0 lib/core_ext/file.rb