Don't require rubygems/defaults from gem_prelude.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2008-10-31 22:27:35 +00:00
Родитель ff5a076e7e
Коммит af0221e728
5 изменённых файлов: 139 добавлений и 9 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Sat Nov 1 07:09:40 2008 Eric Hodel <drbrain@segment7.net>
* gem_prelude.rb: Don't require rubygems/defaults.rb.
Fri Oct 31 21:58:50 2008 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/converter.rb (RSS::Converter): use String#encode.

Просмотреть файл

@ -1,4 +1,6 @@
# depends on: array.rb dir.rb env.rb file.rb hash.rb module.rb regexp.rb
# vim: filetype=ruby
# THIS FILE WAS AUTOGENERATED, DO NOT EDIT
if defined?(Gem) then
@ -75,6 +77,97 @@ if defined?(Gem) then
def self.ensure_gem_subdirectories(path)
end
@post_install_hooks ||= []
@post_uninstall_hooks ||= []
@pre_uninstall_hooks ||= []
@pre_install_hooks ||= []
##
# An Array of the default sources that come with RubyGems
def self.default_sources
%w[http://gems.rubyforge.org/]
end
##
# Default home directory path to be used if an alternate value is not
# specified in the environment
def self.default_dir
if defined? RUBY_FRAMEWORK_VERSION then
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
ConfigMap[:ruby_version]
elsif RUBY_VERSION > '1.9' then
File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
ConfigMap[:ruby_version])
else
File.join(ConfigMap[:libdir], ruby_engine, 'gems',
ConfigMap[:ruby_version])
end
end
##
# Path for gems in the user's home directory
def self.user_dir
File.join(Gem.user_home, '.gem', ruby_engine,
ConfigMap[:ruby_version])
end
##
# Default gem load path
def self.default_path
[user_dir, default_dir]
end
##
# Deduce Ruby's --program-prefix and --program-suffix from its install name
def self.default_exec_format
baseruby = ConfigMap[:BASERUBY] || 'ruby'
ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
end
##
# The default directory for binaries
def self.default_bindir
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
'/usr/bin'
else # generic install
ConfigMap[:bindir]
end
end
##
# The default system-wide source info cache directory
def self.default_system_source_cache_dir
File.join Gem.dir, 'source_cache'
end
##
# The default user-specific source info cache directory
def self.default_user_source_cache_dir
File.join Gem.user_home, '.gem', 'source_cache'
end
##
# A wrapper around RUBY_ENGINE const that may not be defined
def self.ruby_engine
if defined? RUBY_ENGINE then
RUBY_ENGINE
else
'ruby'
end
end
# Methods before this line will be removed when QuickLoader is replaced
# with the real RubyGems
@ -82,8 +175,7 @@ if defined?(Gem) then
begin
verbose, debug = $VERBOSE, $DEBUG
$VERBOSE = $DEBUG = nil
require 'rubygems/defaults'
$DEBUG = $VERBOSE = nil
begin
require 'rubygems/defaults/operating_system'
@ -113,7 +205,8 @@ if defined?(Gem) then
undef_method :gem if method_defined? :gem
end
$".delete File.join(Gem::ConfigMap[:libdir], Gem::ConfigMap[:ruby_install_name],
$".delete File.join(Gem::ConfigMap[:libdir],
Gem::ConfigMap[:ruby_install_name],
Gem::ConfigMap[:ruby_version], 'rubygems.rb')
require 'rubygems'
@ -190,8 +283,12 @@ if defined?(Gem) then
require_paths = []
GemPaths.each_value do |path|
if File.exist?(file = File.join(path, ".require_paths"))
require_paths.concat(File.read(file).split.map {|require_path| File.join(path, require_path)})
if File.exist?(file = File.join(path, ".require_paths")) then
paths = File.read(file).split.map do |require_path|
File.join path, require_path
end
require_paths.concat paths
else
require_paths << file if File.exist?(file = File.join(path, "bin"))
require_paths << file if File.exist?(file = File.join(path, "lib"))

Просмотреть файл

@ -718,6 +718,7 @@ module Gem
@gem_path.uniq!
@gem_path.each do |path|
if 0 == File.expand_path(path).index(Gem.user_home)
next unless File.directory? Gem.user_home
unless win_platform? then
# only create by matching user
next if Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid

Просмотреть файл

@ -20,9 +20,12 @@ module Gem
if defined? RUBY_FRAMEWORK_VERSION then
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
ConfigMap[:ruby_version]
else
elsif RUBY_VERSION > '1.9' then
File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
ConfigMap[:ruby_version])
else
File.join(ConfigMap[:libdir], ruby_engine, 'gems',
ConfigMap[:ruby_version])
end
end

Просмотреть файл

@ -11,7 +11,11 @@ class TestGem < RubyGemTestCase
super
@additional = %w[a b].map { |d| File.join @tempdir, d }
@default_dir_re = %r|/\.*?[Rr]uby.*?/[Gg]ems/[0-9.]+|
@default_dir_re = if RUBY_VERSION > '1.9' then
%r|/.*?[Rr]uby.*?/[Gg]ems/[0-9.]+|
else
%r|/[Rr]uby/[Gg]ems/[0-9.]+|
end
end
def test_self_all_load_paths
@ -475,6 +479,27 @@ class TestGem < RubyGemTestCase
assert_kind_of Gem::GemPathSearcher, Gem.searcher
end
def test_self_set_paths
other = File.join @tempdir, 'other'
path = [@userhome, other].join File::PATH_SEPARATOR
Gem.send :set_paths, path
assert File.exist?(File.join(@userhome, 'gems'))
assert File.exist?(File.join(other, 'gems'))
end
def test_self_set_paths_nonexistent_home
Gem.clear_paths
other = File.join @tempdir, 'other'
ENV['HOME'] = other
Gem.send :set_paths, other
refute File.exist?(File.join(other, 'gems'))
end
def test_self_source_index
assert_kind_of Gem::SourceIndex, Gem.source_index
end