Class: Gem::GemPathSearcher

Class | Gem::GemPathSearcher
In: | lib/rubygems/gem_path_searcher.rb
Parent: | Object

GemPathSearcher has the capability to find loadable files inside gems. It generates data up front to speed up searches later.

### Methods

find find_all init_gemspecs lib_dirs_for matching_file? matching_files new

### Public Class methods

new()

Initialise the data we need to make searches later.

### Public Instance methods

find(path)

Look in all the installed gems until a matching path is found. Return the gemspec of the gem where it was found. If no match is found, return nil.

The gems are searched in alphabetical order, and in reverse version order.

For example:

      find('log4r')              # -> (log4r-1.1 spec)
      find('log4r.rb')           # -> (log4r-1.1 spec)
      find('rake/rdoctask')      # -> (rake-0.4.12 spec)
      find('foobarbaz')          # -> nil

Matching paths can have various suffixes (’.rb’, ’.so’, and others), which may or may not already be attached to file. This method doesn‘t care about the full filename that matches; only that there is a match.

find_all(path)

Works like find, but finds all gemspecs matching `path`.

init_gemspecs()

Return a list of all installed gemspecs, sorted by alphabetical order and in reverse version order. (bar-2, bar-1, foo-2)

lib_dirs_for(spec)

Returns library directories glob for a gemspec. For example,

      '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'

matching_file?(spec, path)

Attempts to find a matching path using the require_paths of the given `spec`.

matching_files(spec, path)

Returns files matching `path` in `spec`.

[Validate]