Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/smshex_r.../opt/alt/ruby33/share/rubygems
File: rubygems.rb
# frozen_string_literal: true
[0] Fix | Delete
[1] Fix | Delete
#--
[2] Fix | Delete
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
[3] Fix | Delete
# All rights reserved.
[4] Fix | Delete
# See LICENSE.txt for permissions.
[5] Fix | Delete
#++
[6] Fix | Delete
[7] Fix | Delete
require "rbconfig"
[8] Fix | Delete
[9] Fix | Delete
module Gem
[10] Fix | Delete
VERSION = "3.5.11"
[11] Fix | Delete
end
[12] Fix | Delete
[13] Fix | Delete
# Must be first since it unloads the prelude from 1.9.2
[14] Fix | Delete
require_relative "rubygems/compatibility"
[15] Fix | Delete
[16] Fix | Delete
require_relative "rubygems/defaults"
[17] Fix | Delete
require_relative "rubygems/deprecate"
[18] Fix | Delete
require_relative "rubygems/errors"
[19] Fix | Delete
[20] Fix | Delete
##
[21] Fix | Delete
# RubyGems is the Ruby standard for publishing and managing third party
[22] Fix | Delete
# libraries.
[23] Fix | Delete
#
[24] Fix | Delete
# For user documentation, see:
[25] Fix | Delete
#
[26] Fix | Delete
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
[27] Fix | Delete
# * {RubyGems User Guide}[https://guides.rubygems.org/]
[28] Fix | Delete
# * {Frequently Asked Questions}[https://guides.rubygems.org/faqs]
[29] Fix | Delete
#
[30] Fix | Delete
# For gem developer documentation see:
[31] Fix | Delete
#
[32] Fix | Delete
# * {Creating Gems}[https://guides.rubygems.org/make-your-own-gem]
[33] Fix | Delete
# * Gem::Specification
[34] Fix | Delete
# * Gem::Version for version dependency notes
[35] Fix | Delete
#
[36] Fix | Delete
# Further RubyGems documentation can be found at:
[37] Fix | Delete
#
[38] Fix | Delete
# * {RubyGems Guides}[https://guides.rubygems.org]
[39] Fix | Delete
# * {RubyGems API}[https://www.rubydoc.info/github/rubygems/rubygems] (also available from
[40] Fix | Delete
# <tt>gem server</tt>)
[41] Fix | Delete
#
[42] Fix | Delete
# == RubyGems Plugins
[43] Fix | Delete
#
[44] Fix | Delete
# RubyGems will load plugins in the latest version of each installed gem or
[45] Fix | Delete
# $LOAD_PATH. Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
[46] Fix | Delete
# placed at the root of your gem's #require_path. Plugins are installed at a
[47] Fix | Delete
# special location and loaded on boot.
[48] Fix | Delete
#
[49] Fix | Delete
# For an example plugin, see the {Graph gem}[https://github.com/seattlerb/graph]
[50] Fix | Delete
# which adds a <tt>gem graph</tt> command.
[51] Fix | Delete
#
[52] Fix | Delete
# == RubyGems Defaults, Packaging
[53] Fix | Delete
#
[54] Fix | Delete
# RubyGems defaults are stored in lib/rubygems/defaults.rb. If you're packaging
[55] Fix | Delete
# RubyGems or implementing Ruby you can change RubyGems' defaults.
[56] Fix | Delete
#
[57] Fix | Delete
# For RubyGems packagers, provide lib/rubygems/defaults/operating_system.rb
[58] Fix | Delete
# and override any defaults from lib/rubygems/defaults.rb.
[59] Fix | Delete
#
[60] Fix | Delete
# For Ruby implementers, provide lib/rubygems/defaults/#{RUBY_ENGINE}.rb and
[61] Fix | Delete
# override any defaults from lib/rubygems/defaults.rb.
[62] Fix | Delete
#
[63] Fix | Delete
# If you need RubyGems to perform extra work on install or uninstall, your
[64] Fix | Delete
# defaults override file can set pre/post install and uninstall hooks.
[65] Fix | Delete
# See Gem::pre_install, Gem::pre_uninstall, Gem::post_install,
[66] Fix | Delete
# Gem::post_uninstall.
[67] Fix | Delete
#
[68] Fix | Delete
# == Bugs
[69] Fix | Delete
#
[70] Fix | Delete
# You can submit bugs to the
[71] Fix | Delete
# {RubyGems bug tracker}[https://github.com/rubygems/rubygems/issues]
[72] Fix | Delete
# on GitHub
[73] Fix | Delete
#
[74] Fix | Delete
# == Credits
[75] Fix | Delete
#
[76] Fix | Delete
# RubyGems is currently maintained by Eric Hodel.
[77] Fix | Delete
#
[78] Fix | Delete
# RubyGems was originally developed at RubyConf 2003 by:
[79] Fix | Delete
#
[80] Fix | Delete
# * Rich Kilmer -- rich(at)infoether.com
[81] Fix | Delete
# * Chad Fowler -- chad(at)chadfowler.com
[82] Fix | Delete
# * David Black -- dblack(at)wobblini.net
[83] Fix | Delete
# * Paul Brannan -- paul(at)atdesk.com
[84] Fix | Delete
# * Jim Weirich -- jim(at)weirichhouse.org
[85] Fix | Delete
#
[86] Fix | Delete
# Contributors:
[87] Fix | Delete
#
[88] Fix | Delete
# * Gavin Sinclair -- gsinclair(at)soyabean.com.au
[89] Fix | Delete
# * George Marrows -- george.marrows(at)ntlworld.com
[90] Fix | Delete
# * Dick Davies -- rasputnik(at)hellooperator.net
[91] Fix | Delete
# * Mauricio Fernandez -- batsman.geo(at)yahoo.com
[92] Fix | Delete
# * Simon Strandgaard -- neoneye(at)adslhome.dk
[93] Fix | Delete
# * Dave Glasser -- glasser(at)mit.edu
[94] Fix | Delete
# * Paul Duncan -- pabs(at)pablotron.org
[95] Fix | Delete
# * Ville Aine -- vaine(at)cs.helsinki.fi
[96] Fix | Delete
# * Eric Hodel -- drbrain(at)segment7.net
[97] Fix | Delete
# * Daniel Berger -- djberg96(at)gmail.com
[98] Fix | Delete
# * Phil Hagelberg -- technomancy(at)gmail.com
[99] Fix | Delete
# * Ryan Davis -- ryand-ruby(at)zenspider.com
[100] Fix | Delete
# * Evan Phoenix -- evan(at)fallingsnow.net
[101] Fix | Delete
# * Steve Klabnik -- steve(at)steveklabnik.com
[102] Fix | Delete
#
[103] Fix | Delete
# (If your name is missing, PLEASE let us know!)
[104] Fix | Delete
#
[105] Fix | Delete
# == License
[106] Fix | Delete
#
[107] Fix | Delete
# See {LICENSE.txt}[rdoc-ref:lib/rubygems/LICENSE.txt] for permissions.
[108] Fix | Delete
#
[109] Fix | Delete
# Thanks!
[110] Fix | Delete
#
[111] Fix | Delete
# -The RubyGems Team
[112] Fix | Delete
[113] Fix | Delete
module Gem
[114] Fix | Delete
RUBYGEMS_DIR = __dir__
[115] Fix | Delete
[116] Fix | Delete
##
[117] Fix | Delete
# An Array of Regexps that match windows Ruby platforms.
[118] Fix | Delete
[119] Fix | Delete
WIN_PATTERNS = [
[120] Fix | Delete
/bccwin/i,
[121] Fix | Delete
/cygwin/i,
[122] Fix | Delete
/djgpp/i,
[123] Fix | Delete
/mingw/i,
[124] Fix | Delete
/mswin/i,
[125] Fix | Delete
/wince/i,
[126] Fix | Delete
].freeze
[127] Fix | Delete
[128] Fix | Delete
GEM_DEP_FILES = %w[
[129] Fix | Delete
gem.deps.rb
[130] Fix | Delete
gems.rb
[131] Fix | Delete
Gemfile
[132] Fix | Delete
Isolate
[133] Fix | Delete
].freeze
[134] Fix | Delete
[135] Fix | Delete
##
[136] Fix | Delete
# Subdirectories in a gem repository
[137] Fix | Delete
[138] Fix | Delete
REPOSITORY_SUBDIRECTORIES = %w[
[139] Fix | Delete
build_info
[140] Fix | Delete
cache
[141] Fix | Delete
doc
[142] Fix | Delete
extensions
[143] Fix | Delete
gems
[144] Fix | Delete
plugins
[145] Fix | Delete
specifications
[146] Fix | Delete
].freeze
[147] Fix | Delete
[148] Fix | Delete
##
[149] Fix | Delete
# Subdirectories in a gem repository for default gems
[150] Fix | Delete
[151] Fix | Delete
REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[
[152] Fix | Delete
gems
[153] Fix | Delete
specifications/default
[154] Fix | Delete
].freeze
[155] Fix | Delete
[156] Fix | Delete
@@win_platform = nil
[157] Fix | Delete
[158] Fix | Delete
@configuration = nil
[159] Fix | Delete
@gemdeps = nil
[160] Fix | Delete
@loaded_specs = {}
[161] Fix | Delete
LOADED_SPECS_MUTEX = Thread::Mutex.new
[162] Fix | Delete
@path_to_default_spec_map = {}
[163] Fix | Delete
@platforms = []
[164] Fix | Delete
@ruby = nil
[165] Fix | Delete
@ruby_api_version = nil
[166] Fix | Delete
@sources = nil
[167] Fix | Delete
[168] Fix | Delete
@post_build_hooks ||= []
[169] Fix | Delete
@post_install_hooks ||= []
[170] Fix | Delete
@post_uninstall_hooks ||= []
[171] Fix | Delete
@pre_uninstall_hooks ||= []
[172] Fix | Delete
@pre_install_hooks ||= []
[173] Fix | Delete
@pre_reset_hooks ||= []
[174] Fix | Delete
@post_reset_hooks ||= []
[175] Fix | Delete
[176] Fix | Delete
@default_source_date_epoch = nil
[177] Fix | Delete
[178] Fix | Delete
@discover_gems_on_require = true
[179] Fix | Delete
[180] Fix | Delete
##
[181] Fix | Delete
# Try to activate a gem containing +path+. Returns true if
[182] Fix | Delete
# activation succeeded or wasn't needed because it was already
[183] Fix | Delete
# activated. Returns false if it can't find the path in a gem.
[184] Fix | Delete
[185] Fix | Delete
def self.try_activate(path)
[186] Fix | Delete
# finds the _latest_ version... regardless of loaded specs and their deps
[187] Fix | Delete
# if another gem had a requirement that would mean we shouldn't
[188] Fix | Delete
# activate the latest version, then either it would already be activated
[189] Fix | Delete
# or if it was ambiguous (and thus unresolved) the code in our custom
[190] Fix | Delete
# require will try to activate the more specific version.
[191] Fix | Delete
[192] Fix | Delete
spec = Gem::Specification.find_by_path path
[193] Fix | Delete
return false unless spec
[194] Fix | Delete
return true if spec.activated?
[195] Fix | Delete
[196] Fix | Delete
begin
[197] Fix | Delete
spec.activate
[198] Fix | Delete
rescue Gem::LoadError => e # this could fail due to gem dep collisions, go lax
[199] Fix | Delete
spec_by_name = Gem::Specification.find_by_name(spec.name)
[200] Fix | Delete
if spec_by_name.nil?
[201] Fix | Delete
raise e
[202] Fix | Delete
else
[203] Fix | Delete
spec_by_name.activate
[204] Fix | Delete
end
[205] Fix | Delete
end
[206] Fix | Delete
[207] Fix | Delete
true
[208] Fix | Delete
end
[209] Fix | Delete
[210] Fix | Delete
def self.needs
[211] Fix | Delete
rs = Gem::RequestSet.new
[212] Fix | Delete
[213] Fix | Delete
yield rs
[214] Fix | Delete
[215] Fix | Delete
finish_resolve rs
[216] Fix | Delete
end
[217] Fix | Delete
[218] Fix | Delete
def self.finish_resolve(request_set=Gem::RequestSet.new)
[219] Fix | Delete
request_set.import Gem::Specification.unresolved_deps.values
[220] Fix | Delete
request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
[221] Fix | Delete
[222] Fix | Delete
request_set.resolve_current.each do |s|
[223] Fix | Delete
s.full_spec.activate
[224] Fix | Delete
end
[225] Fix | Delete
end
[226] Fix | Delete
[227] Fix | Delete
##
[228] Fix | Delete
# Find the full path to the executable for gem +name+. If the +exec_name+
[229] Fix | Delete
# is not given, an exception will be raised, otherwise the
[230] Fix | Delete
# specified executable's path is returned. +requirements+ allows
[231] Fix | Delete
# you to specify specific gem versions.
[232] Fix | Delete
[233] Fix | Delete
def self.bin_path(name, exec_name = nil, *requirements)
[234] Fix | Delete
requirements = Gem::Requirement.default if
[235] Fix | Delete
requirements.empty?
[236] Fix | Delete
[237] Fix | Delete
find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
[238] Fix | Delete
end
[239] Fix | Delete
[240] Fix | Delete
def self.find_spec_for_exe(name, exec_name, requirements)
[241] Fix | Delete
raise ArgumentError, "you must supply exec_name" unless exec_name
[242] Fix | Delete
[243] Fix | Delete
dep = Gem::Dependency.new name, requirements
[244] Fix | Delete
[245] Fix | Delete
loaded = Gem.loaded_specs[name]
[246] Fix | Delete
[247] Fix | Delete
return loaded if loaded && dep.matches_spec?(loaded)
[248] Fix | Delete
[249] Fix | Delete
specs = dep.matching_specs(true)
[250] Fix | Delete
[251] Fix | Delete
specs = specs.find_all do |spec|
[252] Fix | Delete
spec.executables.include? exec_name
[253] Fix | Delete
end if exec_name
[254] Fix | Delete
[255] Fix | Delete
unless spec = specs.first
[256] Fix | Delete
msg = "can't find gem #{dep} with executable #{exec_name}"
[257] Fix | Delete
raise Gem::GemNotFoundException, msg
[258] Fix | Delete
end
[259] Fix | Delete
[260] Fix | Delete
spec
[261] Fix | Delete
end
[262] Fix | Delete
private_class_method :find_spec_for_exe
[263] Fix | Delete
[264] Fix | Delete
##
[265] Fix | Delete
# Find the full path to the executable for gem +name+. If the +exec_name+
[266] Fix | Delete
# is not given, an exception will be raised, otherwise the
[267] Fix | Delete
# specified executable's path is returned. +requirements+ allows
[268] Fix | Delete
# you to specify specific gem versions.
[269] Fix | Delete
#
[270] Fix | Delete
# A side effect of this method is that it will activate the gem that
[271] Fix | Delete
# contains the executable.
[272] Fix | Delete
#
[273] Fix | Delete
# This method should *only* be used in bin stub files.
[274] Fix | Delete
[275] Fix | Delete
def self.activate_bin_path(name, exec_name = nil, *requirements) # :nodoc:
[276] Fix | Delete
spec = find_spec_for_exe name, exec_name, requirements
[277] Fix | Delete
Gem::LOADED_SPECS_MUTEX.synchronize do
[278] Fix | Delete
spec.activate
[279] Fix | Delete
finish_resolve
[280] Fix | Delete
end
[281] Fix | Delete
spec.bin_file exec_name
[282] Fix | Delete
end
[283] Fix | Delete
[284] Fix | Delete
##
[285] Fix | Delete
# The mode needed to read a file as straight binary.
[286] Fix | Delete
[287] Fix | Delete
def self.binary_mode
[288] Fix | Delete
"rb"
[289] Fix | Delete
end
[290] Fix | Delete
[291] Fix | Delete
##
[292] Fix | Delete
# The path where gem executables are to be installed.
[293] Fix | Delete
[294] Fix | Delete
def self.bindir(install_dir=Gem.dir)
[295] Fix | Delete
return File.join install_dir, "bin" unless
[296] Fix | Delete
install_dir.to_s == Gem.default_dir.to_s
[297] Fix | Delete
Gem.default_bindir
[298] Fix | Delete
end
[299] Fix | Delete
[300] Fix | Delete
##
[301] Fix | Delete
# The path were rubygems plugins are to be installed.
[302] Fix | Delete
[303] Fix | Delete
def self.plugindir(install_dir=Gem.dir)
[304] Fix | Delete
File.join install_dir, "plugins"
[305] Fix | Delete
end
[306] Fix | Delete
[307] Fix | Delete
##
[308] Fix | Delete
# Reset the +dir+ and +path+ values. The next time +dir+ or +path+
[309] Fix | Delete
# is requested, the values will be calculated from scratch. This is
[310] Fix | Delete
# mainly used by the unit tests to provide test isolation.
[311] Fix | Delete
[312] Fix | Delete
def self.clear_paths
[313] Fix | Delete
@paths = nil
[314] Fix | Delete
@user_home = nil
[315] Fix | Delete
Gem::Specification.reset
[316] Fix | Delete
Gem::Security.reset if defined?(Gem::Security)
[317] Fix | Delete
end
[318] Fix | Delete
[319] Fix | Delete
##
[320] Fix | Delete
# The standard configuration object for gems.
[321] Fix | Delete
[322] Fix | Delete
def self.configuration
[323] Fix | Delete
@configuration ||= Gem::ConfigFile.new []
[324] Fix | Delete
end
[325] Fix | Delete
[326] Fix | Delete
##
[327] Fix | Delete
# Use the given configuration object (which implements the ConfigFile
[328] Fix | Delete
# protocol) as the standard configuration object.
[329] Fix | Delete
[330] Fix | Delete
def self.configuration=(config)
[331] Fix | Delete
@configuration = config
[332] Fix | Delete
end
[333] Fix | Delete
[334] Fix | Delete
##
[335] Fix | Delete
# A Zlib::Deflate.deflate wrapper
[336] Fix | Delete
[337] Fix | Delete
def self.deflate(data)
[338] Fix | Delete
require "zlib"
[339] Fix | Delete
Zlib::Deflate.deflate data
[340] Fix | Delete
end
[341] Fix | Delete
[342] Fix | Delete
# Retrieve the PathSupport object that RubyGems uses to
[343] Fix | Delete
# lookup files.
[344] Fix | Delete
[345] Fix | Delete
def self.paths
[346] Fix | Delete
@paths ||= Gem::PathSupport.new(ENV)
[347] Fix | Delete
end
[348] Fix | Delete
[349] Fix | Delete
# Initialize the filesystem paths to use from +env+.
[350] Fix | Delete
# +env+ is a hash-like object (typically ENV) that
[351] Fix | Delete
# is queried for 'GEM_HOME', 'GEM_PATH', and 'GEM_SPEC_CACHE'
[352] Fix | Delete
# Keys for the +env+ hash should be Strings, and values of the hash should
[353] Fix | Delete
# be Strings or +nil+.
[354] Fix | Delete
[355] Fix | Delete
def self.paths=(env)
[356] Fix | Delete
clear_paths
[357] Fix | Delete
target = {}
[358] Fix | Delete
env.each_pair do |k,v|
[359] Fix | Delete
case k
[360] Fix | Delete
when "GEM_HOME", "GEM_PATH", "GEM_SPEC_CACHE"
[361] Fix | Delete
case v
[362] Fix | Delete
when nil, String
[363] Fix | Delete
target[k] = v
[364] Fix | Delete
when Array
[365] Fix | Delete
unless Gem::Deprecate.skip
[366] Fix | Delete
warn <<-EOWARN
[367] Fix | Delete
Array values in the parameter to `Gem.paths=` are deprecated.
[368] Fix | Delete
Please use a String or nil.
[369] Fix | Delete
An Array (#{env.inspect}) was passed in from #{caller[3]}
[370] Fix | Delete
EOWARN
[371] Fix | Delete
end
[372] Fix | Delete
target[k] = v.join File::PATH_SEPARATOR
[373] Fix | Delete
end
[374] Fix | Delete
else
[375] Fix | Delete
target[k] = v
[376] Fix | Delete
end
[377] Fix | Delete
end
[378] Fix | Delete
@paths = Gem::PathSupport.new ENV.to_hash.merge(target)
[379] Fix | Delete
Gem::Specification.dirs = @paths.path
[380] Fix | Delete
end
[381] Fix | Delete
[382] Fix | Delete
##
[383] Fix | Delete
# The path where gems are to be installed.
[384] Fix | Delete
[385] Fix | Delete
def self.dir
[386] Fix | Delete
paths.home
[387] Fix | Delete
end
[388] Fix | Delete
[389] Fix | Delete
def self.path
[390] Fix | Delete
paths.path
[391] Fix | Delete
end
[392] Fix | Delete
[393] Fix | Delete
def self.spec_cache_dir
[394] Fix | Delete
paths.spec_cache_dir
[395] Fix | Delete
end
[396] Fix | Delete
[397] Fix | Delete
##
[398] Fix | Delete
# Quietly ensure the Gem directory +dir+ contains all the proper
[399] Fix | Delete
# subdirectories. If we can't create a directory due to a permission
[400] Fix | Delete
# problem, then we will silently continue.
[401] Fix | Delete
#
[402] Fix | Delete
# If +mode+ is given, missing directories are created with this mode.
[403] Fix | Delete
#
[404] Fix | Delete
# World-writable directories will never be created.
[405] Fix | Delete
[406] Fix | Delete
def self.ensure_gem_subdirectories(dir = Gem.dir, mode = nil)
[407] Fix | Delete
ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES)
[408] Fix | Delete
end
[409] Fix | Delete
[410] Fix | Delete
##
[411] Fix | Delete
# Quietly ensure the Gem directory +dir+ contains all the proper
[412] Fix | Delete
# subdirectories for handling default gems. If we can't create a
[413] Fix | Delete
# directory due to a permission problem, then we will silently continue.
[414] Fix | Delete
#
[415] Fix | Delete
# If +mode+ is given, missing directories are created with this mode.
[416] Fix | Delete
#
[417] Fix | Delete
# World-writable directories will never be created.
[418] Fix | Delete
[419] Fix | Delete
def self.ensure_default_gem_subdirectories(dir = Gem.dir, mode = nil)
[420] Fix | Delete
ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES)
[421] Fix | Delete
end
[422] Fix | Delete
[423] Fix | Delete
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
[424] Fix | Delete
old_umask = File.umask
[425] Fix | Delete
File.umask old_umask | 0o002
[426] Fix | Delete
[427] Fix | Delete
options = {}
[428] Fix | Delete
[429] Fix | Delete
options[:mode] = mode if mode
[430] Fix | Delete
[431] Fix | Delete
subdirs.each do |name|
[432] Fix | Delete
subdir = File.join dir, name
[433] Fix | Delete
next if File.exist? subdir
[434] Fix | Delete
[435] Fix | Delete
require "fileutils"
[436] Fix | Delete
[437] Fix | Delete
begin
[438] Fix | Delete
FileUtils.mkdir_p subdir, **options
[439] Fix | Delete
rescue SystemCallError
[440] Fix | Delete
end
[441] Fix | Delete
end
[442] Fix | Delete
ensure
[443] Fix | Delete
File.umask old_umask
[444] Fix | Delete
end
[445] Fix | Delete
[446] Fix | Delete
##
[447] Fix | Delete
# The extension API version of ruby. This includes the static vs non-static
[448] Fix | Delete
# distinction as extensions cannot be shared between the two.
[449] Fix | Delete
[450] Fix | Delete
def self.extension_api_version # :nodoc:
[451] Fix | Delete
if RbConfig::CONFIG["ENABLE_SHARED"] == "no"
[452] Fix | Delete
"#{ruby_api_version}-static"
[453] Fix | Delete
else
[454] Fix | Delete
ruby_api_version
[455] Fix | Delete
end
[456] Fix | Delete
end
[457] Fix | Delete
[458] Fix | Delete
##
[459] Fix | Delete
# Returns a list of paths matching +glob+ that can be used by a gem to pick
[460] Fix | Delete
# up features from other gems. For example:
[461] Fix | Delete
#
[462] Fix | Delete
# Gem.find_files('rdoc/discover').each do |path| load path end
[463] Fix | Delete
#
[464] Fix | Delete
# if +check_load_path+ is true (the default), then find_files also searches
[465] Fix | Delete
# $LOAD_PATH for files as well as gems.
[466] Fix | Delete
#
[467] Fix | Delete
# Note that find_files will return all files even if they are from different
[468] Fix | Delete
# versions of the same gem. See also find_latest_files
[469] Fix | Delete
[470] Fix | Delete
def self.find_files(glob, check_load_path=true)
[471] Fix | Delete
files = []
[472] Fix | Delete
[473] Fix | Delete
files = find_files_from_load_path glob if check_load_path
[474] Fix | Delete
[475] Fix | Delete
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
[476] Fix | Delete
[477] Fix | Delete
files.concat gem_specifications.map {|spec|
[478] Fix | Delete
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
[479] Fix | Delete
}.flatten
[480] Fix | Delete
[481] Fix | Delete
# $LOAD_PATH might contain duplicate entries or reference
[482] Fix | Delete
# the spec dirs directly, so we prune.
[483] Fix | Delete
files.uniq! if check_load_path
[484] Fix | Delete
[485] Fix | Delete
files
[486] Fix | Delete
end
[487] Fix | Delete
[488] Fix | Delete
def self.find_files_from_load_path(glob) # :nodoc:
[489] Fix | Delete
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
[490] Fix | Delete
$LOAD_PATH.map do |load_path|
[491] Fix | Delete
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
[492] Fix | Delete
end.flatten.select {|file| File.file? file }
[493] Fix | Delete
end
[494] Fix | Delete
[495] Fix | Delete
##
[496] Fix | Delete
# Returns a list of paths matching +glob+ from the latest gems that can be
[497] Fix | Delete
# used by a gem to pick up features from other gems. For example:
[498] Fix | Delete
#
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function