This project is closed and read-only.
Backport #9489 » rubygems.2.2.2.patch
| lib/rubygems/available_set.rb (working copy) | ||
|---|---|---|
|
Tuple = Struct.new(:spec, :source)
|
||
|
attr_accessor :remote # :nodoc:
|
||
|
def initialize
|
||
|
@set = []
|
||
|
@sorted = nil
|
||
|
@remote = true
|
||
|
end
|
||
|
attr_reader :set
|
||
| lib/rubygems/basic_specification.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
##
|
||
|
# Returns the paths to the source files for use with analysis and
|
||
|
# documentation tools. These paths are relative to full_gem_path.
|
||
|
def source_paths
|
||
|
paths = raw_require_paths.dup
|
||
|
if @extensions then
|
||
|
ext_dirs = @extensions.map do |extension|
|
||
|
extension.split(File::SEPARATOR, 2).first
|
||
|
end.uniq
|
||
|
paths.concat ext_dirs
|
||
|
end
|
||
|
paths.uniq
|
||
|
end
|
||
|
##
|
||
|
# Return a Gem::Specification from this gem
|
||
|
def to_spec
|
||
| lib/rubygems/commands/contents_command.rb (working copy) | ||
|---|---|---|
|
spec.files.sort.map do |file|
|
||
|
case file
|
||
|
when /\A#{spec.bindir}\//
|
||
|
[Gem::ConfigMap[:bindir], $POSTMATCH]
|
||
|
[RbConfig::CONFIG['bindir'], $POSTMATCH]
|
||
|
when /\.so\z/
|
||
|
[Gem::ConfigMap[:archdir], file]
|
||
|
[RbConfig::CONFIG['archdir'], file]
|
||
|
else
|
||
|
[Gem::ConfigMap[:rubylibdir], file]
|
||
|
[RbConfig::CONFIG['rubylibdir'], file]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| lib/rubygems/commands/generate_index_command.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def execute
|
||
|
# This is always true becasue it's the only way now.
|
||
|
# This is always true because it's the only way now.
|
||
|
options[:build_modern] = true
|
||
|
if not File.exist?(options[:directory]) or
|
||
| lib/rubygems/commands/install_command.rb (working copy) | ||
|---|---|---|
|
def install_gem_without_dependencies name, req # :nodoc:
|
||
|
gem = nil
|
||
|
if remote? then
|
||
|
if local? then
|
||
|
if name =~ /\.gem$/ and File.file? name then
|
||
|
source = Gem::Source::SpecificFile.new name
|
||
|
spec = source.spec
|
||
|
else
|
||
|
source = Gem::Source::Local.new
|
||
|
spec = source.find_gem name, req
|
||
|
end
|
||
|
gem = source.download spec if spec
|
||
|
end
|
||
|
if remote? and not gem then
|
||
|
dependency = Gem::Dependency.new name, req
|
||
|
dependency.prerelease = options[:prerelease]
|
||
| ... | ... | |
|
gem = fetcher.download_to_cache dependency
|
||
|
end
|
||
|
if local? and not gem then
|
||
|
source = Gem::Source::Local.new
|
||
|
spec = source.find_gem name, req
|
||
|
gem = source.download spec
|
||
|
end
|
||
|
inst = Gem::Installer.new gem, options
|
||
|
inst.install
|
||
| lib/rubygems/commands/setup_command.rb (working copy) | ||
|---|---|---|
|
super 'setup', 'Install RubyGems',
|
||
|
:format_executable => true, :document => %w[ri],
|
||
|
:site_or_vendor => :sitelibdir,
|
||
|
:site_or_vendor => 'sitelibdir',
|
||
|
:destdir => '', :prefix => '', :previous_version => ''
|
||
|
add_option '--previous-version=VERSION',
|
||
| ... | ... | |
|
add_option '--[no-]vendor',
|
||
|
'Install into vendorlibdir not sitelibdir' do |vendor, options|
|
||
|
options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir
|
||
|
options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir'
|
||
|
end
|
||
|
add_option '--[no-]format-executable',
|
||
| ... | ... | |
|
site_or_vendor = options[:site_or_vendor]
|
||
|
if prefix.empty? then
|
||
|
lib_dir = Gem::ConfigMap[site_or_vendor]
|
||
|
bin_dir = Gem::ConfigMap[:bindir]
|
||
|
lib_dir = RbConfig::CONFIG[site_or_vendor]
|
||
|
bin_dir = RbConfig::CONFIG['bindir']
|
||
|
else
|
||
|
# Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets
|
||
|
# confused about installation location, so switch back to
|
||
|
# sitelibdir/vendorlibdir.
|
||
|
if defined?(APPLE_GEM_HOME) and
|
||
|
# just in case Apple and RubyGems don't get this patched up proper.
|
||
|
(prefix == Gem::ConfigMap[:libdir] or
|
||
|
(prefix == RbConfig::CONFIG['libdir'] or
|
||
|
# this one is important
|
||
|
prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then
|
||
|
lib_dir = Gem::ConfigMap[site_or_vendor]
|
||
|
bin_dir = Gem::ConfigMap[:bindir]
|
||
|
prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then
|
||
|
lib_dir = RbConfig::CONFIG[site_or_vendor]
|
||
|
bin_dir = RbConfig::CONFIG['bindir']
|
||
|
else
|
||
|
lib_dir = File.join prefix, 'lib'
|
||
|
bin_dir = File.join prefix, 'bin'
|
||
| lib/rubygems/compatibility.rb (working copy) | ||
|---|---|---|
|
module Gem
|
||
|
RubyGemsVersion = VERSION
|
||
|
# TODO remove at RubyGems 3
|
||
|
RbConfigPriorities = %w[
|
||
|
MAJOR
|
||
|
MINOR
|
||
| ... | ... | |
|
unless defined?(ConfigMap)
|
||
|
##
|
||
|
# Configuration settings from ::RbConfig
|
||
|
ConfigMap = Hash.new do |cm, key|
|
||
|
ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3
|
||
|
cm[key] = RbConfig::CONFIG[key.to_s]
|
||
|
end
|
||
|
else
|
||
| lib/rubygems/config_file.rb (working copy) | ||
|---|---|---|
|
attr_reader :ssl_verify_mode
|
||
|
##
|
||
|
# Path name of directory or file of openssl CA certificate, used for remote https connection
|
||
|
# Path name of directory or file of openssl CA certificate, used for remote
|
||
|
# https connection
|
||
|
attr_reader :ssl_ca_cert
|
||
|
attr_accessor :ssl_ca_cert
|
||
|
##
|
||
|
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
|
||
| lib/rubygems/defaults.rb (working copy) | ||
|---|---|---|
|
def self.default_dir
|
||
|
path = if defined? RUBY_FRAMEWORK_VERSION then
|
||
|
[
|
||
|
File.dirname(ConfigMap[:sitedir]),
|
||
|
File.dirname(RbConfig::CONFIG['sitedir']),
|
||
|
'Gems',
|
||
|
ConfigMap[:ruby_version]
|
||
|
RbConfig::CONFIG['ruby_version']
|
||
|
]
|
||
|
elsif ConfigMap[:rubylibprefix] then
|
||
|
elsif RbConfig::CONFIG['rubylibprefix'] then
|
||
|
[
|
||
|
ConfigMap[:rubylibprefix],
|
||
|
RbConfig::CONFIG['rubylibprefix'],
|
||
|
'gems',
|
||
|
ConfigMap[:ruby_version]
|
||
|
RbConfig::CONFIG['ruby_version']
|
||
|
]
|
||
|
else
|
||
|
[
|
||
|
ConfigMap[:libdir],
|
||
|
RbConfig::CONFIG['libdir'],
|
||
|
ruby_engine,
|
||
|
'gems',
|
||
|
ConfigMap[:ruby_version]
|
||
|
RbConfig::CONFIG['ruby_version']
|
||
|
]
|
||
|
end
|
||
| ... | ... | |
|
def self.user_dir
|
||
|
parts = [Gem.user_home, '.gem', ruby_engine]
|
||
|
parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty?
|
||
|
parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
|
||
|
File.join parts
|
||
|
end
|
||
| ... | ... | |
|
# Deduce Ruby's --program-prefix and --program-suffix from its install name
|
||
|
def self.default_exec_format
|
||
|
exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
|
||
|
exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s'
|
||
|
unless exec_format =~ /%s/ then
|
||
|
raise Gem::Exception,
|
||
| ... | ... | |
|
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
|
||
|
'/usr/bin'
|
||
|
else # generic install
|
||
|
ConfigMap[:bindir]
|
||
|
RbConfig::CONFIG['bindir']
|
||
|
end
|
||
|
end
|
||
| lib/rubygems/dependency_installer.rb (working copy) | ||
|---|---|---|
|
request_set = as.to_request_set install_development_deps
|
||
|
request_set.soft_missing = @force
|
||
|
request_set.remote = false unless consider_remote?
|
||
|
installer_set = Gem::Resolver::InstallerSet.new @domain
|
||
|
installer_set.always_install.concat request_set.always_install
|
||
| lib/rubygems/deprecate.rb (working copy) | ||
|---|---|---|
|
class_eval {
|
||
|
old = "_deprecated_#{name}"
|
||
|
alias_method old, name
|
||
|
define_method name do |*args, &block| # TODO: really works on 1.8.7?
|
||
|
define_method name do |*args, &block|
|
||
|
klass = self.kind_of? Module
|
||
|
target = klass ? "#{self}." : "#{self.class}#"
|
||
|
msg = [ "NOTE: #{target}#{name} is deprecated",
|
||
| lib/rubygems/ext/ext_conf_builder.rb (working copy) | ||
|---|---|---|
|
ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ')
|
||
|
cmd = [Gem.ruby, File.basename(extension), *args].join ' '
|
||
|
run cmd, results
|
||
|
begin
|
||
|
run cmd, results
|
||
|
ensure
|
||
|
FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
|
||
|
end
|
||
|
ENV["DESTDIR"] = nil
|
||
|
ENV["RUBYOPT"] = rubyopt
|
||
| lib/rubygems/installer.rb (working copy) | ||
|---|---|---|
|
#
|
||
|
def shebang(bin_file_name)
|
||
|
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
|
||
|
ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang
|
||
|
path = File.join gem_dir, spec.bindir, bin_file_name
|
||
|
first_line = File.open(path, "rb") {|file| file.gets}
|
||
| ... | ... | |
|
if which = Gem.configuration[:custom_shebang]
|
||
|
# replace bin_file_name with "ruby" to avoid endless loops
|
||
|
which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}")
|
||
|
which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}")
|
||
|
which = which.gsub(/\$(\w+)/) do
|
||
|
case $1
|
||
| ... | ... | |
|
if ARGV.first
|
||
|
str = ARGV.first
|
||
|
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
||
|
if str =~ /\\A_(.*)_\\z/
|
||
|
if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
|
||
|
version = $1
|
||
|
ARGV.shift
|
||
|
end
|
||
| lib/rubygems/package/tar_header.rb (working copy) | ||
|---|---|---|
|
vals[:gid] ||= 0
|
||
|
vals[:mtime] ||= 0
|
||
|
vals[:checksum] ||= ""
|
||
|
vals[:typeflag] ||= "0"
|
||
|
vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty?
|
||
|
vals[:magic] ||= "ustar"
|
||
|
vals[:version] ||= "00"
|
||
|
vals[:uname] ||= "wheel"
|
||
| lib/rubygems/platform.rb (working copy) | ||
|---|---|---|
|
attr_accessor :version
|
||
|
def self.local
|
||
|
arch = Gem::ConfigMap[:arch]
|
||
|
arch = RbConfig::CONFIG['arch']
|
||
|
arch = "#{arch}_60" if arch =~ /mswin32$/
|
||
|
@local ||= new(arch)
|
||
|
end
|
||
| lib/rubygems/rdoc.rb (working copy) | ||
|---|---|---|
|
::RDoc::Parser::C.reset
|
||
|
args = @spec.rdoc_options
|
||
|
args.concat @spec.require_paths
|
||
|
args.concat @spec.source_paths
|
||
|
args.concat @spec.extra_rdoc_files
|
||
|
case config_args = Gem.configuration[:rdoc]
|
||
| lib/rubygems/remote_fetcher.rb (working copy) | ||
|---|---|---|
|
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
|
||
|
# Always escape URI's to deal with potential spaces and such
|
||
|
unless URI::Generic === source_uri
|
||
|
source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
|
||
|
URI::DEFAULT_PARSER.escape(source_uri.to_s) :
|
||
|
URI.escape(source_uri.to_s))
|
||
|
# Always escape URI's to deal with potential spaces and such
|
||
|
# It should also be considered that source_uri may already be
|
||
|
# a valid URI with escaped characters. e.g. "{DESede}" is encoded
|
||
|
# as "%7BDESede%7D". If this is escaped again the percentage
|
||
|
# symbols will be escaped.
|
||
|
unless source_uri.is_a?(URI::Generic)
|
||
|
begin
|
||
|
source_uri = URI.parse(source_uri)
|
||
|
rescue
|
||
|
source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
|
||
|
URI::DEFAULT_PARSER.escape(source_uri.to_s) :
|
||
|
URI.escape(source_uri.to_s))
|
||
|
end
|
||
|
end
|
||
|
scheme = source_uri.scheme
|
||
| ... | ... | |
|
def cache_update_path uri, path = nil, update = true
|
||
|
mtime = path && File.stat(path).mtime rescue nil
|
||
|
if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true)
|
||
|
Gem.read_binary(path)
|
||
|
else
|
||
|
data = fetch_path(uri)
|
||
|
data = fetch_path(uri, mtime)
|
||
|
if update and path then
|
||
|
open(path, 'wb') do |io|
|
||
|
io.flock(File::LOCK_EX)
|
||
|
io.write data
|
||
|
end
|
||
|
end
|
||
|
if data == nil # indicates the server returned 304 Not Modified
|
||
|
return Gem.read_binary(path)
|
||
|
end
|
||
|
data
|
||
|
if update and path
|
||
|
open(path, 'wb') do |io|
|
||
|
io.flock(File::LOCK_EX)
|
||
|
io.write data
|
||
|
end
|
||
|
end
|
||
|
data
|
||
|
end
|
||
|
##
|
||
| lib/rubygems/request.rb (working copy) | ||
|---|---|---|
|
connection.key = OpenSSL::PKey::RSA.new pem
|
||
|
end
|
||
|
store.set_default_paths
|
||
|
add_rubygems_trusted_certs(store)
|
||
|
if Gem.configuration.ssl_ca_cert
|
||
|
if File.directory? Gem.configuration.ssl_ca_cert
|
||
|
store.add_path Gem.configuration.ssl_ca_cert
|
||
|
else
|
||
|
store.add_file Gem.configuration.ssl_ca_cert
|
||
|
end
|
||
|
else
|
||
|
store.set_default_paths
|
||
|
add_rubygems_trusted_certs(store)
|
||
|
end
|
||
|
connection.cert_store = store
|
||
|
rescue LoadError => e
|
||
| ... | ... | |
|
request = @request_class.new @uri.request_uri
|
||
|
unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then
|
||
|
request.basic_auth @uri.user, @uri.password
|
||
|
request.basic_auth Gem::UriFormatter.new(@uri.user).unescape,
|
||
|
Gem::UriFormatter.new(@uri.password).unescape
|
||
|
end
|
||
|
request.add_field 'User-Agent', @user_agent
|
||
| lib/rubygems/request_set/lockfile.rb (working copy) | ||
|---|---|---|
|
type, data, = get [:text, :requirement]
|
||
|
if type == :text and column == 4 then
|
||
|
last_spec = set.add name, data, Gem::Platform::RUBY
|
||
|
version, platform = data.split '-', 2
|
||
|
platform =
|
||
|
platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
|
||
|
last_spec = set.add name, version, platform
|
||
|
else
|
||
|
dependency = parse_dependency name, data
|
||
| lib/rubygems/request_set.rb (working copy) | ||
|---|---|---|
|
attr_accessor :ignore_dependencies
|
||
|
##
|
||
|
# When false no remote sets are used for resolving gems.
|
||
|
attr_accessor :remote
|
||
|
##
|
||
|
# Sets used for resolution
|
||
|
attr_reader :sets # :nodoc:
|
||
| ... | ... | |
|
@git_set = nil
|
||
|
@ignore_dependencies = false
|
||
|
@install_dir = Gem.dir
|
||
|
@remote = true
|
||
|
@requests = []
|
||
|
@sets = []
|
||
|
@soft_missing = false
|
||
| ... | ... | |
|
gemdeps = options[:gemdeps]
|
||
|
@install_dir = options[:install_dir] || Gem.dir
|
||
|
@remote = options[:domain] != :local
|
||
|
load_gemdeps gemdeps, options[:without_groups]
|
||
| ... | ... | |
|
@sets << @vendor_set
|
||
|
set = Gem::Resolver.compose_sets(*@sets)
|
||
|
set.remote = @remote
|
||
|
resolver = Gem::Resolver.new @dependencies, set
|
||
|
resolver.development = @development
|
||
| lib/rubygems/resolver/api_set.rb (working copy) | ||
|---|---|---|
|
# http://guides.rubygems.org/rubygems-org-api
|
||
|
def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies'
|
||
|
super()
|
||
|
dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8
|
||
|
@dep_uri = dep_uri
|
||
|
@uri = dep_uri + '../../..'
|
||
|
@uri = dep_uri + '../..'
|
||
|
@data = Hash.new { |h,k| h[k] = [] }
|
||
|
@source = Gem::Source.new @uri
|
||
| ... | ... | |
|
def find_all req
|
||
|
res = []
|
||
|
return res unless @remote
|
||
|
versions(req.name).each do |ver|
|
||
|
if req.dependency.match? req.name, ver[:number]
|
||
|
res << Gem::Resolver::APISpecification.new(self, ver)
|
||
| ... | ... | |
|
# data for DependencyRequests +reqs+.
|
||
|
def prefetch reqs
|
||
|
return unless @remote
|
||
|
names = reqs.map { |r| r.dependency.name }
|
||
|
needed = names - @data.keys
|
||
| lib/rubygems/resolver/best_set.rb (working copy) | ||
|---|---|---|
|
def initialize sources = Gem.sources
|
||
|
super()
|
||
|
sources.each_source do |source|
|
||
|
@sources = sources
|
||
|
end
|
||
|
##
|
||
|
# Picks which sets to use for the configured sources.
|
||
|
def pick_sets # :nodoc:
|
||
|
@sources.each_source do |source|
|
||
|
@sets << source.dependency_resolver_set
|
||
|
end
|
||
|
end
|
||
|
def find_all req # :nodoc:
|
||
|
pick_sets if @remote and @sets.empty?
|
||
|
super
|
||
|
end
|
||
|
def prefetch reqs # :nodoc:
|
||
|
pick_sets if @remote and @sets.empty?
|
||
|
super
|
||
|
end
|
||
|
def pretty_print q # :nodoc:
|
||
|
q.group 2, '[BestSet', ']' do
|
||
|
q.breakable
|
||
| lib/rubygems/resolver/composed_set.rb (working copy) | ||
|---|---|---|
|
# Gem::Resolver::compose_sets instead.
|
||
|
def initialize *sets
|
||
|
super()
|
||
|
@sets = sets
|
||
|
end
|
||
|
##
|
||
|
# Sets the remote network access for all composed sets.
|
||
|
def remote= remote
|
||
|
super
|
||
|
@sets.each { |set| set.remote = remote }
|
||
|
end
|
||
|
##
|
||
|
# Finds all specs matching +req+ in all sets.
|
||
|
def find_all req
|
||
| lib/rubygems/resolver/git_set.rb (working copy) | ||
|---|---|---|
|
attr_reader :specs # :nodoc:
|
||
|
def initialize # :nodoc:
|
||
|
super()
|
||
|
@git = ENV['git'] || 'git'
|
||
|
@need_submodules = {}
|
||
|
@repositories = {}
|
||
| ... | ... | |
|
@repositories.each do |name, (repository, reference)|
|
||
|
source = Gem::Source::Git.new name, repository, reference
|
||
|
source.root_dir = @root_dir
|
||
|
source.remote = @remote
|
||
|
source.specs.each do |spec|
|
||
|
git_spec = Gem::Resolver::GitSpecification.new self, spec, source
|
||
| lib/rubygems/resolver/index_set.rb (working copy) | ||
|---|---|---|
|
class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
||
|
def initialize source = nil # :nodoc:
|
||
|
super()
|
||
|
@f =
|
||
|
if source then
|
||
|
sources = Gem::SourceList.from [source]
|
||
| ... | ... | |
|
def find_all req
|
||
|
res = []
|
||
|
return res unless @remote
|
||
|
name = req.dependency.name
|
||
|
@all[name].each do |uri, n|
|
||
| lib/rubygems/resolver/installer_set.rb (working copy) | ||
|---|---|---|
|
# Creates a new InstallerSet that will look for gems in +domain+.
|
||
|
def initialize domain
|
||
|
super()
|
||
|
@domain = domain
|
||
|
@remote = consider_remote?
|
||
|
@f = Gem::SpecFetcher.fetcher
|
||
|
@all = Hash.new { |h,k| h[k] = [] }
|
||
|
@always_install = []
|
||
|
@ignore_dependencies = false
|
||
|
@ignore_installed = false
|
||
|
@loaded_remote_specs = []
|
||
|
@remote_set = Gem::Resolver::BestSet.new
|
||
|
@specs = {}
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
if consider_remote? then
|
||
|
load_remote_specs dep
|
||
|
@all[name].each do |remote_source, n|
|
||
|
if dep.match? n then
|
||
|
res << Gem::Resolver::IndexSpecification.new(
|
||
|
self, n.name, n.version, remote_source, n.platform)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
res.concat @remote_set.find_all req if consider_remote?
|
||
|
res
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
##
|
||
|
# Loads remote prerelease specs if +dep+ is a prerelease dependency
|
||
|
def load_remote_specs dep # :nodoc:
|
||
|
types = [:released]
|
||
|
types << :prerelease if dep.prerelease?
|
||
|
types.each do |type|
|
||
|
next if @loaded_remote_specs.include? type
|
||
|
@loaded_remote_specs << type
|
||
|
list, = @f.available_specs type
|
||
|
list.each do |uri, specs|
|
||
|
specs.each do |n|
|
||
|
@all[n.name] << [uri, n]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
##
|
||
|
# Called from IndexSpecification to get a true Specification
|
||
|
# object.
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def remote= remote # :nodoc:
|
||
|
case @domain
|
||
|
when :local then
|
||
|
@domain = :both if remote
|
||
|
when :remote then
|
||
|
@domain = nil unless remote
|
||
|
when :both then
|
||
|
@domain = :local unless remote
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| lib/rubygems/resolver/lock_set.rb (working copy) | ||
|---|---|---|
|
# Creates a new LockSet from the given +source+
|
||
|
def initialize source
|
||
|
super()
|
||
|
@source = Gem::Source::Lock.new source
|
||
|
@specs = []
|
||
|
end
|
||
| lib/rubygems/resolver/set.rb (working copy) | ||
|---|---|---|
|
class Gem::Resolver::Set
|
||
|
##
|
||
|
# Set to true to disable network access for this set
|
||
|
attr_accessor :remote
|
||
|
def initialize # :nodoc:
|
||
|
@remote = true
|
||
|
end
|
||
|
##
|
||
|
# The find_all method must be implemented. It returns all Resolver
|
||
|
# Specification objects matching the given DependencyRequest +req+.
|
||
| ... | ... | |
|
def prefetch reqs
|
||
|
end
|
||
|
##
|
||
|
# When true, this set is allowed to access the network when looking up
|
||
|
# specifications or dependencies.
|
||
|
def remote? # :nodoc:
|
||
|
@remote
|
||
|
end
|
||
|
end
|
||
| lib/rubygems/resolver/vendor_set.rb (working copy) | ||
|---|---|---|
|
attr_reader :specs # :nodoc:
|
||
|
def initialize # :nodoc:
|
||
|
super()
|
||
|
@directories = {}
|
||
|
@specs = {}
|
||
|
end
|
||
| lib/rubygems/resolver.rb (working copy) | ||
|---|---|---|
|
sets = sets.map do |set|
|
||
|
case set
|
||
|
when Gem::Resolver::BestSet then
|
||
|
set
|
||
|
when Gem::Resolver::ComposedSet then
|
||
|
set.sets
|
||
|
else
|
||
| ... | ... | |
|
end
|
||
|
##
|
||
|
# Finds the State in +states+ that matches the +conflict+ so that we can try
|
||
|
# other possible sets.
|
||
|
#
|
||
|
# If no good candidate is found, the first state is tried.
|
||
|
def find_conflict_state conflict, states # :nodoc:
|
||
|
until states.empty? do
|
||
|
state = states.pop
|
||
|
explain :consider, state.dep, conflict.failed_dep
|
||
|
if conflict.for_spec? state.spec
|
||
|
state.conflicts << [state.spec, conflict]
|
||
|
return state
|
||
|
end
|
||
|
end
|
||
|
nil
|
||
|
end
|
||
|
##
|
||
|
# Extracts the specifications that may be able to fulfill +dependency+ and
|
||
|
# returns those that match the local platform and all those that match.
|
||
| lib/rubygems/security.rb (working copy) | ||
|---|---|---|
|
# * HighSecurity - Here's the bugger that got us into this mess.
|
||
|
# The HighSecurity policy is identical to the MediumSecurity policy,
|
||
|
# except that it does not allow unsigned gems. A malicious user
|
||
|
# doesn't have a whole lot of options here; he can't modify the
|
||
|
# package contents without invalidating the signature, and he can't
|
||
|
# doesn't have a whole lot of options here; they can't modify the
|
||
|
# package contents without invalidating the signature, and they can't
|
||
|
# modify or remove signature or the signing certificate chain, or
|
||
|
# RubyGems will simply refuse to install the package. Oh well, maybe
|
||
|
# he'll have better luck causing problems for CPAN users instead :).
|
||
|
# they'll have better luck causing problems for CPAN users instead :).
|
||
|
#
|
||
|
# The reason RubyGems refused to install your shiny new signed gem was because
|
||
|
# it was from an untrusted source. Well, your code is infallible (naturally),
|
||
| lib/rubygems/source/git.rb (working copy) | ||
|---|---|---|
|
attr_reader :reference
|
||
|
##
|
||
|
# When false the cache for this repository will not be updated.
|
||
|
attr_accessor :remote
|
||
|
##
|
||
|
# The git repository this gem is sourced from.
|
||
|
attr_reader :repository
|
||
| ... | ... | |
|
@reference = reference
|
||
|
@need_submodules = submodules
|
||
|
@remote = true
|
||
|
@root_dir = Gem.dir
|
||
|
@git = ENV['git'] || 'git'
|
||
|
end
|
||
| ... | ... | |
|
def checkout # :nodoc:
|
||
|
cache
|
||
|
return false unless File.exist? repo_cache_dir
|
||
|
unless File.exist? install_dir then
|
||
|
system @git, 'clone', '--quiet', '--no-checkout',
|
||
|
repo_cache_dir, install_dir
|
||
| ... | ... | |
|
# Creates a local cache repository for the git gem.
|
||
|
def cache # :nodoc:
|
||
|
return unless @remote
|
||
|
if File.exist? repo_cache_dir then
|
||
|
Dir.chdir repo_cache_dir do
|
||
|
system @git, 'fetch', '--quiet', '--force', '--tags',
|
||
| ... | ... | |
|
# The directory where the git gem will be installed.
|
||
|
def install_dir # :nodoc:
|
||
|
return unless File.exist? repo_cache_dir
|
||
|
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
|
||
|
end
|
||
| ... | ... | |
|
def specs
|
||
|
checkout
|
||
|
return [] unless install_dir
|
||
|
Dir.chdir install_dir do
|
||
|
Dir['{,*,*/*}.gemspec'].map do |spec_file|
|
||
|
directory = File.dirname spec_file
|
||
| lib/rubygems/specification.rb (working copy) | ||
|---|---|---|
|
attr_reader :summary
|
||
|
##
|
||
|
# Singular writer for #authors
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# spec.author = 'John Jones'
|
||
|
def author= o
|
||
|
self.authors = [o]
|
||
|
end
|
||
|
##
|
||
|
# Sets the list of authors, ensuring it is an array.
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# spec.authors = ['John Jones', 'Mary Smith']
|
||
|
def authors= value
|
||
|
@authors = Array(value).flatten.grep(String)
|
||
|
end
|
||
|
##
|
||
|
# The platform this gem runs on.
|
||
|
#
|
||
|
# This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.
|
||
| ... | ... | |
|
add_bindir(@executables),
|
||
|
@extra_rdoc_files,
|
||
|
@extensions,
|
||
|
].flatten.sort.uniq.compact
|
||
|
].flatten.uniq.compact.sort
|
||
|
end
|
||
|
######################################################################
|
||
| ... | ... | |
|
end
|
||
|
##
|
||
|
# Singular writer for #authors
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# spec.author = 'John Jones'
|
||
|
def author= o
|
||
|
self.authors = [o]
|
||
|
end
|
||
|
##
|
||
|
# Sets the list of authors, ensuring it is an array.
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# spec.authors = ['John Jones', 'Mary Smith']
|
||
|
def authors= value
|
||
|
@authors = Array(value).flatten.grep(String)
|
||
|
end
|
||
|
##
|
||
|
# Executables included in the gem.
|
||
|
#
|
||
|
# For example, the rake gem has rake as an executable. You don’t specify the
|
||
| lib/rubygems/test_case.rb (working copy) | ||
|---|---|---|
|
assert File.exist?(path), msg
|
||
|
end
|
||
|
##
|
||
|
# Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
|
||
|
# the original value when the block ends
|
||
|
def enable_shared value
|
||
|
enable_shared = RbConfig::CONFIG['ENABLE_SHARED']
|
||
|
RbConfig::CONFIG['ENABLE_SHARED'] = value
|
||
|
yield
|
||
|
ensure
|
||
|
if enable_shared then
|
||
|
RbConfig::CONFIG['enable_shared'] = enable_shared
|
||
|
else
|
||
|
RbConfig::CONFIG.delete 'enable_shared'
|
||
|
end
|
||
|
end
|
||
|
# TODO: move to minitest
|
||
|
def refute_path_exists path, msg = nil
|
||
|
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
||
| ... | ... | |
|
Gem.searcher = nil
|
||
|
Gem::SpecFetcher.fetcher = nil
|
||
|
@orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
||
|
Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name]
|
||
|
@orig_BASERUBY = RbConfig::CONFIG['BASERUBY']
|
||
|
RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name']
|
||
|
@orig_arch = Gem::ConfigMap[:arch]
|
||
|
@orig_arch = RbConfig::CONFIG['arch']
|
||
|
if win_platform?
|
||
|
util_set_arch 'i386-mswin32'
|
||
| ... | ... | |
|
def teardown
|
||
|
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
|
||
|
Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY
|
||
|
Gem::ConfigMap[:arch] = @orig_arch
|
||
|
if @orig_BASERUBY
|
||
|
RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY
|
||
|
else
|
||
|
RbConfig::CONFIG.delete('BASERUBY')
|
||
|
end
|
||
|
RbConfig::CONFIG['arch'] = @orig_arch
|
||
|
if defined? Gem::RemoteFetcher then
|
||
|
Gem::RemoteFetcher.fetcher = nil
|
||
| ... | ... | |
|
# Set the platform to +arch+
|
||
|
def util_set_arch(arch)
|
||
|
Gem::ConfigMap[:arch] = arch
|
||
|
RbConfig::CONFIG['arch'] = arch
|
||
|
platform = Gem::Platform.new arch
|
||
|
Gem.instance_variable_set :@platforms, nil
|
||
| ... | ... | |
|
class StaticSet
|
||
|
##
|
||
|
# A StaticSet ignores remote because it has a fixed set of gems.
|
||
|
attr_accessor :remote
|
||
|
##
|
||
|
# Creates a new StaticSet for the given +specs+
|
||
|
def initialize(specs)
|
||
|
@specs = specs
|
||
|
@remote = true
|
||
|
end
|
||
|
##
|
||
| lib/rubygems/uninstaller.rb (working copy) | ||
|---|---|---|
|
unless path_ok?(@gem_home, spec) or
|
||
|
(@user_install and path_ok?(Gem.user_dir, spec)) then
|
||
|
e = Gem::GemNotInHomeException.new \
|
||
|
"Gem is not installed in directory #{@gem_home}"
|
||
|
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
|
||
|
e.spec = spec
|
||
|
raise e
|
||
| lib/rubygems/version.rb (working copy) | ||
|---|---|---|
|
# 3. 1.0.a.2
|
||
|
# 4. 0.9
|
||
|
#
|
||
|
# If you want to specify a version restriction that includes both prereleases
|
||
|
# and regular releases of the 1.x series this is the best way:
|
||
|
#
|
||
|
# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0'
|
||
|
#
|
||
|
# == How Software Changes
|
||
|
#
|
||
|
# Users expect to be able to specify a version constraint that gives them
|
||
| ... | ... | |
|
#
|
||
|
# * Any "public" release of a gem should have a different version. Normally
|
||
|
# that means incrementing the build number. This means a developer can
|
||
|
# generate builds all day long for himself, but as soon as he/she makes a
|
||
|
# public release, the version must be updated.
|
||
|
# generate builds all day long, but as soon as they make a public release,
|
||
|
# the version must be updated.
|
||
|
#
|
||
|
# === Examples
|
||
|
#
|
||
| ... | ... | |
|
# Version 1.1.1:: Fixed a bug in the linked list implementation.
|
||
|
# Version 1.1.2:: Fixed a bug introduced in the last fix.
|
||
|
#
|
||
|
# Client A needs a stack with basic push/pop capability. He writes to the
|
||
|
# original interface (no <tt>top</tt>), so his version constraint looks
|
||
|
# like:
|
||
|
# Client A needs a stack with basic push/pop capability. They write to the
|
||
|
# original interface (no <tt>top</tt>), so their version constraint looks like:
|
||
|
#
|
||
|
# gem 'stack', '~> 0.0'
|
||
|
#
|
||
|
# Essentially, any version is OK with Client A. An incompatible change to
|
||
|
# the library will cause him grief, but he is willing to take the chance (we
|
||
|
# call Client A optimistic).
|
||
|
# the library will cause them grief, but they are willing to take the chance
|
||
|
# (we call Client A optimistic).
|
||
|
#
|
||
|
# Client B is just like Client A except for two things: (1) He uses the
|
||
|
# <tt>depth</tt> method and (2) he is worried about future
|
||
|
# incompatibilities, so he writes his version constraint like this:
|
||
|
# Client B is just like Client A except for two things: (1) They use the
|
||
|
# <tt>depth</tt> method and (2) they are worried about future
|
||
|
# incompatibilities, so they write their version constraint like this:
|
||
|
#
|
||
|
# gem 'stack', '~> 0.1'
|
||
|
#
|
||
|
# The <tt>depth</tt> method was introduced in version 0.1.0, so that version
|
||
|
# or anything later is fine, as long as the version stays below version 1.0
|
||
|
# where incompatibilities are introduced. We call Client B pessimistic
|
||
|
# because he is worried about incompatible future changes (it is OK to be
|
||
|
# because they are worried about incompatible future changes (it is OK to be
|
||
|
# pessimistic!).
|
||
|
#
|
||
|
# == Preventing Version Catastrophe:
|
||
| ... | ... | |
|
@@all = {}
|
||
|
def self.new version # :nodoc:
|
||
|
return super unless Gem::VERSION == self.class
|
||
|
@@all[version] ||= super
|
||
|
end
|
||
| lib/rubygems.rb (working copy) | ||
|---|---|---|
|
require 'rbconfig'
|
||
|
module Gem
|
||
|
VERSION = '2.2.0'
|
||
|
VERSION = '2.2.2'
|
||
|
end
|
||
|
# Must be first since it unloads the prelude from 1.9.2
|
||
| ... | ... | |
|
# gem's paths are inserted before site lib directory by default.
|
||
|
def self.load_path_insert_index
|
||
|
index = $LOAD_PATH.index ConfigMap[:sitelibdir]
|
||
|
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
|
||
|
index
|
||
|
end
|
||
| ... | ... | |
|
def self.prefix
|
||
|
prefix = File.dirname RUBYGEMS_DIR
|
||
|
if prefix != File.expand_path(ConfigMap[:sitelibdir]) and
|
||
|
prefix != File.expand_path(ConfigMap[:libdir]) and
|
||
|
if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and
|
||
|
prefix != File.expand_path(RbConfig::CONFIG['libdir']) and
|
||
|
'lib' == File.basename(RUBYGEMS_DIR) then
|
||
|
prefix
|
||
|
end
|
||
| ... | ... | |
|
f.flock(File::LOCK_EX)
|
||
|
f.read
|
||
|
end
|
||
|
rescue Errno::EACCES
|
||
|
open path, 'rb' do |f|
|
||
|
f.read
|
||
|
end
|
||
|
end
|
||
|
##
|
||
| ... | ... | |
|
def self.ruby
|
||
|
if @ruby.nil? then
|
||
|
@ruby = File.join(ConfigMap[:bindir],
|
||
|
"#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}")
|
||
|
@ruby = File.join(RbConfig::CONFIG['bindir'],
|
||
|
"#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}")
|
||
|
@ruby = "\"#{@ruby}\"" if @ruby =~ /\s/
|
||
|
end
|
||
| ... | ... | |
|
# Returns a String containing the API compatibility version of Ruby
|
||
|
def self.ruby_api_version
|
||
|
@ruby_api_version ||=
|
||
|
"#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}"
|
||
|
@ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup
|
||
|
end
|
||
|
##
|
||
| test/rubygems/test_gem.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def test_self_default_exec_format
|
||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
|
||
|
Gem::ConfigMap[:ruby_install_name] = 'ruby'
|
||
|
assert_equal '%s', Gem.default_exec_format
|
||
|
ensure
|
||
|
Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
|
||
|
ruby_install_name 'ruby' do
|
||
|
assert_equal '%s', Gem.default_exec_format
|
||
|
end
|
||
|
end
|
||
|
def test_self_default_exec_format_18
|
||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
|
||
|
Gem::ConfigMap[:ruby_install_name] = 'ruby18'
|
||
|
assert_equal '%s18', Gem.default_exec_format
|
||
|
ensure
|
||
|
Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
|
||
|
ruby_install_name 'ruby18' do
|
||
|
assert_equal '%s18', Gem.default_exec_format
|
||
|
end
|
||
|
end
|
||
|
def test_self_default_exec_format_jruby
|
||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
|
||
|
Gem::ConfigMap[:ruby_install_name] = 'jruby'
|
||
|
assert_equal 'j%s', Gem.default_exec_format
|
||
|
ensure
|
||
|
Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
|
||
|
ruby_install_name 'jruby' do
|
||
|
assert_equal 'j%s', Gem.default_exec_format
|
||
|
end
|
||
|
end
|
||
|
def test_self_default_sources
|
||
| ... | ... | |
|
end
|
||
|
def test_self_detect_gemdeps
|
||
|
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
|
||
|
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
|
||
|
FileUtils.mkdir_p 'detect/a/b'
|
||
| ... | ... | |
|
end
|
||
|
def test_self_extension_dir_shared
|
||
|
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
||
|
RbConfig::CONFIG['ENABLE_SHARED'], 'yes'
|
||
|
assert_equal Gem.ruby_api_version, Gem.extension_api_version
|
||
|
ensure
|
||
|
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
||
|
enable_shared 'yes' do
|
||
|
assert_equal Gem.ruby_api_version, Gem.extension_api_version
|
||
|
end
|
||
|
end
|
||
|
def test_self_extension_dir_static
|
||
|
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
||
|
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
|
||
|
assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
|
||
|
ensure
|
||
|
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
||
|
enable_shared 'no' do
|
||
|
assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
|
||
|
end
|
||
|
end
|
||
|
def test_self_find_files
|
||
| ... | ... | |
|
end
|
||
|
def test_self_prefix_libdir
|
||
|
orig_libdir = Gem::ConfigMap[:libdir]
|
||
|
Gem::ConfigMap[:libdir] = @@project_dir
|
||
|
orig_libdir = RbConfig::CONFIG['libdir']
|
||
|
RbConfig::CONFIG['libdir'] = @@project_dir
|
||
|
assert_nil Gem.prefix
|
||
|
ensure
|
||
|
Gem::ConfigMap[:libdir] = orig_libdir
|
||
|
RbConfig::CONFIG['libdir'] = orig_libdir
|
||
|
end
|
||
|
def test_self_prefix_sitelibdir
|
||
|
orig_sitelibdir = Gem::ConfigMap[:sitelibdir]
|
||
|
Gem::ConfigMap[:sitelibdir] = @@project_dir
|
||
|
orig_sitelibdir = RbConfig::CONFIG['sitelibdir']
|
||
|
RbConfig::CONFIG['sitelibdir'] = @@project_dir
|
||
|
assert_nil Gem.prefix
|
||
|
ensure
|
||
|
Gem::ConfigMap[:sitelibdir] = orig_sitelibdir
|
||
|
RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir
|
||
|
end
|
||
|
def test_self_read_binary
|
||
|
open 'test', 'w' do |io|
|
||
|
io.write "\xCF\x80"
|
||
|
end
|
||
|
assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
|
||
|
skip 'chmod not supported' if Gem.win_platform?
|
||
|
begin
|
||
|
File.chmod 0444, 'test'
|
||
|
assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
|
||
|
ensure
|
||
|
File.chmod 0644, 'test'
|
||
|
end
|
||
|
end
|
||
|
def test_self_refresh
|
||
|
skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
|
||
|
util_make_gems
|
||
|
a1_spec = @a1.spec_file
|
||
| ... | ... | |
|
end
|
||
|
def test_self_refresh_keeps_loaded_specs_activated
|
||
|
skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
|
||
|
util_make_gems
|
||
|
a1_spec = @a1.spec_file
|
||
| ... | ... | |
|
def test_self_ruby_escaping_spaces_in_path
|
||
|
orig_ruby = Gem.ruby
|
||
|
orig_bindir = Gem::ConfigMap[:bindir]
|
||
|
orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
|
||
|
orig_exe_ext = Gem::ConfigMap[:EXEEXT]
|
||
|
Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin"
|
||
|
Gem::ConfigMap[:ruby_install_name] = "ruby"
|
||
|
Gem::ConfigMap[:EXEEXT] = ".exe"
|
||
|
orig_bindir = RbConfig::CONFIG['bindir']
|
||
|
orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
|
||
|
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
|
||
|
RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin"
|
||
|
RbConfig::CONFIG['ruby_install_name'] = "ruby"
|
||
|
RbConfig::CONFIG['EXEEXT'] = ".exe"
|
||
|
Gem.instance_variable_set("@ruby", nil)
|
||
|
assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
|
||
|
ensure
|
||
|
Gem.instance_variable_set("@ruby", orig_ruby)
|
||
|
Gem::ConfigMap[:bindir] = orig_bindir
|
||
|
Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
|
||
|
Gem::ConfigMap[:EXEEXT] = orig_exe_ext
|
||
|
RbConfig::CONFIG['bindir'] = orig_bindir
|
||
|
RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
|
||
|
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
|
||
|
end
|
||
|
def test_self_ruby_path_without_spaces
|
||
|
orig_ruby = Gem.ruby
|
||
|
orig_bindir = Gem::ConfigMap[:bindir]
|
||
|
orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
|
||
|
orig_exe_ext = Gem::ConfigMap[:EXEEXT]
|
||
|
Gem::ConfigMap[:bindir] = "C:/Ruby18/bin"
|
||
|
Gem::ConfigMap[:ruby_install_name] = "ruby"
|
||
|
Gem::ConfigMap[:EXEEXT] = ".exe"
|
||
|
orig_bindir = RbConfig::CONFIG['bindir']
|
||
|
orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
|
||
|
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
|
||
|
RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin"
|
||
|
RbConfig::CONFIG['ruby_install_name'] = "ruby"
|
||
|
RbConfig::CONFIG['EXEEXT'] = ".exe"
|
||
|
Gem.instance_variable_set("@ruby", nil)
|
||
|
assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
|
||
|
ensure
|
||
|
Gem.instance_variable_set("@ruby", orig_ruby)
|
||
|
Gem::ConfigMap[:bindir] = orig_bindir
|
||
|
Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
|
||
|
Gem::ConfigMap[:EXEEXT] = orig_exe_ext
|
||
|
RbConfig::CONFIG['bindir'] = orig_bindir
|
||
|
RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
|
||
|
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
|
||
|
end
|
||
|
def test_self_ruby_api_version
|
||
|
orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1'
|
||
|
orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2'
|
||
|
orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3'
|
||
|
orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3'
|
||
|
Gem.instance_variable_set :@ruby_api_version, nil
|
||
| ... | ... | |
|
ensure
|
||
|
Gem.instance_variable_set :@ruby_api_version, nil
|
||
|
Gem::ConfigMap[:MAJOR] = orig_MAJOR
|
||
|
Gem::ConfigMap[:MINOR] = orig_MINOR
|
||
|
Gem::ConfigMap[:TEENY] = orig_TEENY
|
||
|
RbConfig::CONFIG['ruby_version'] = orig_ruby_version
|
||
|
end
|
||
|
def test_self_ruby_version_1_8_5
|
||
| ... | ... | |
|
def test_self_user_dir
|
||
|
parts = [@userhome, '.gem', Gem.ruby_engine]
|
||
|
parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty?
|
||
|
parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
|
||
|
assert_equal File.join(parts), Gem.user_dir
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
def test_self_needs_picks_up_unresolved_deps
|
||
|
skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7"
|
||
|
save_loaded_features do
|
||
|
util_clear_gems
|
||
|
a = util_spec "a", "1"
|
||
| ... | ... | |
|
end
|
||
|
def test_load_plugins
|
||
|
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
|
||
|
plugin_path = File.join "lib", "rubygems_plugin.rb"
|
||
|
Dir.chdir @tempdir do
|
||
| ... | ... | |
|
end
|
||
|
def test_auto_activation_of_detected_gemdeps_file
|
||
|
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
|
||
|
util_clear_gems
|
||
|
a = new_spec "a", "1", nil, "lib/a.rb"
|
||
| ... | ... | |
|
end
|
||
|
def test_use_gemdeps_automatic
|
||
|
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
|
||
|
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
|
||
|
spec = util_spec 'a', 1
|
||
| ... | ... | |
|
end
|
||
|
def test_use_gemdeps_specific
|
||
|
skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
|
||