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