1. Gem::
  2. PathSupport

class Gem::PathSupport

Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings to the rest of RubyGems.

Attributes

home[R]

The default system path for managing Gems.

path[R]

Array of paths to search for Gems.

Public Class Methods

Source
# File lib/rubygems/path_support.rb, line 26definitialize(env)@home =normalize_home_dir(env["GEM_HOME"]||Gem.default_dir)@path =split_gem_pathenv["GEM_PATH"],@home@spec_cache_dir =env["GEM_SPEC_CACHE"]||Gem.default_spec_cache_dirend

Constructor. Takes a single argument which is to be treated like a hashtable, or defaults toENV, the system environment.

Private Instance Methods

Source
# File lib/rubygems/path_support.rb, line 74defdefault_pathGem.default_path+ [@home]end

Return the default Gem path

Source
# File lib/rubygems/path_support.rb, line 78defexpand(path)ifFile.directory?(path)File.realpath(path)elsepathendend
Source
# File lib/rubygems/path_support.rb, line 35defnormalize_home_dir(home)ifFile::ALT_SEPARATORhome =home.gsub(File::ALT_SEPARATOR,File::SEPARATOR)endexpand(home)end
Source
# File lib/rubygems/path_support.rb, line 46defsplit_gem_path(gpaths,home)# FIX: it should be [home, *path], not [*path, home]gem_path = []ifgpathsgem_path =gpaths.split(Gem.path_separator)# Handle the path_separator being set to a regexp, which will cause# end_with? to errorif/#{Gem.path_separator}\z/.match?(gpaths)gem_path+=default_pathendifFile::ALT_SEPARATORgem_path.map!do|this_path|this_path.gsubFile::ALT_SEPARATOR,File::SEPARATORendendgem_path<<homeelsegem_path =default_pathendgem_path.map {|path|expand(path) }.uniqend

Split the Gem search path (as reported byGem.path).