ruby-changes:8552
From: drbrain <ko1@a...>
Date: Sat, 1 Nov 2008 07:27:56 +0900 (JST)
Subject: [ruby-changes:8552] Ruby:r20085 (trunk): Don't require rubygems/defaults from gem_prelude.rb.
drbrain 2008-11-01 07:27:35 +0900 (Sat, 01 Nov 2008) New Revision: 20085 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20085 Log: Don't require rubygems/defaults from gem_prelude.rb. Modified files: trunk/ChangeLog trunk/gem_prelude.rb trunk/lib/rubygems/defaults.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20084) +++ ChangeLog (revision 20085) @@ -1,3 +1,7 @@ +Sat Nov 1 07:09:40 2008 Eric Hodel <drbrain@s...> + + * gem_prelude.rb: Don't require rubygems/defaults.rb. + Fri Oct 31 21:58:50 2008 Kouhei Sutou <kou@c...> * lib/rss/converter.rb (RSS::Converter): use String#encode. Index: gem_prelude.rb =================================================================== --- gem_prelude.rb (revision 20084) +++ gem_prelude.rb (revision 20085) @@ -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 @@ 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 @@ begin verbose, debug = $VERBOSE, $DEBUG - $VERBOSE = $DEBUG = nil - require 'rubygems/defaults' + $DEBUG = $VERBOSE = nil begin require 'rubygems/defaults/operating_system' @@ -113,7 +205,8 @@ 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' @@ -125,7 +218,7 @@ def push_gem_version_on_load_path(gem_name, *version_requirements) if version_requirements.empty? unless GemPaths.has_key?(gem_name) - raise LoadError.new("Could not find RubyGem #{gem_name} (>= 0)\n") + raise LoadError.new("Could not find RubyGem #{gem_name} (>= 0)\n") end # highest version gems already active @@ -141,7 +234,7 @@ if requirement == ">" || requirement == ">=" if (GemVersions[gem_name] <=> Gem.calculate_integers_for_gem_version(version)) >= 0 - return false + return false end elsif requirement == "~>" loaded_version = GemVersions[gem_name] @@ -190,8 +283,12 @@ 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")) Index: lib/rubygems/defaults.rb =================================================================== --- lib/rubygems/defaults.rb (revision 20084) +++ lib/rubygems/defaults.rb (revision 20085) @@ -20,9 +20,12 @@ 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 Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 20084) +++ lib/rubygems.rb (revision 20085) @@ -718,6 +718,7 @@ @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 Index: test/rubygems/test_gem.rb =================================================================== --- test/rubygems/test_gem.rb (revision 20084) +++ test/rubygems/test_gem.rb (revision 20085) @@ -11,7 +11,11 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/