Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix all remaining references to site_ruby and gems/1.8.

  • Loading branch information...
commit 90985cbc41cf18986e9e6de44824d84ab6441cd6 1 parent ac62dd8
@headius headius authored
Showing with 1,257 additions and 1,823 deletions.
  1. +6 −8 build.xml
  2. +2 −2 default.build.properties
  3. +50 −122 lib/ruby/shared/rubygems.rb
  4. +0 −2  lib/ruby/shared/rubygems/builder.rb
  5. +3 −3 lib/ruby/shared/rubygems/command.rb
  6. +7 −23 lib/ruby/shared/rubygems/command_manager.rb
  7. +0 −2  lib/ruby/shared/rubygems/commands/environment_command.rb
  8. +5 −15 lib/ruby/shared/rubygems/commands/fetch_command.rb
  9. +30 −16 lib/ruby/shared/rubygems/commands/install_command.rb
  10. +5 −9 lib/ruby/shared/rubygems/commands/owner_command.rb
  11. +3 −1 lib/ruby/shared/rubygems/commands/pristine_command.rb
  12. +1 −12 lib/ruby/shared/rubygems/commands/push_command.rb
  13. +26 −21 lib/ruby/shared/rubygems/commands/rdoc_command.rb
  14. +8 −32 lib/ruby/shared/rubygems/commands/setup_command.rb
  15. +2 −11 lib/ruby/shared/rubygems/commands/specification_command.rb
  16. +6 −15 lib/ruby/shared/rubygems/commands/uninstall_command.rb
  17. +28 −17 lib/ruby/shared/rubygems/commands/update_command.rb
  18. +36 −68 lib/ruby/shared/rubygems/config_file.rb
  19. +18 −62 lib/ruby/shared/rubygems/custom_require.rb
  20. +2 −3 lib/ruby/shared/rubygems/defaults.rb
  21. +2 −18 lib/ruby/shared/rubygems/dependency.rb
  22. +22 −97 lib/ruby/shared/rubygems/dependency_installer.rb
  23. +3 −9 lib/ruby/shared/rubygems/dependency_list.rb
  24. +40 −40 lib/ruby/shared/rubygems/deprecate.rb
  25. +18 −51 lib/ruby/shared/rubygems/doc_manager.rb
  26. +6 −7 lib/ruby/shared/rubygems/errors.rb
  27. +4 −19 lib/ruby/shared/rubygems/exceptions.rb
  28. +1 −1  lib/ruby/shared/rubygems/ext/builder.rb
  29. +3 −8 lib/ruby/shared/rubygems/format.rb
  30. +0 −1  lib/ruby/shared/rubygems/gem_openssl.rb
  31. +0 −2  lib/ruby/shared/rubygems/gem_path_searcher.rb
  32. +4 −3 lib/ruby/shared/rubygems/gem_runner.rb
  33. +6 −21 lib/ruby/shared/rubygems/gemcutter_utilities.rb
  34. +0 −2  lib/ruby/shared/rubygems/indexer.rb
  35. +12 −51 lib/ruby/shared/rubygems/install_update_options.rb
  36. +33 −154 lib/ruby/shared/rubygems/installer.rb
  37. +16 −24 lib/ruby/shared/rubygems/installer_test_case.rb
  38. +6 −6 lib/ruby/shared/rubygems/local_remote_options.rb
  39. +377 −0 lib/ruby/shared/rubygems/maven_gemify.rb
  40. +0 −17 lib/ruby/shared/rubygems/mock_gem_ui.rb
  41. +19 −15 lib/ruby/shared/rubygems/package/tar_input.rb
  42. +18 −14 lib/ruby/shared/rubygems/path_support.rb
  43. +22 −61 lib/ruby/shared/rubygems/remote_fetcher.rb
  44. +10 −48 lib/ruby/shared/rubygems/requirement.rb
  45. +2 −2 lib/ruby/shared/rubygems/server.rb
  46. +1 −1  lib/ruby/shared/rubygems/source_index.rb
  47. +49 −23 lib/ruby/shared/rubygems/spec_fetcher.rb
  48. +287 −578 lib/ruby/shared/rubygems/specification.rb
  49. +4 −0 lib/ruby/shared/rubygems/syck_hack.rb
  50. +21 −35 lib/ruby/shared/rubygems/test_case.rb
  51. +1 −16 lib/ruby/shared/rubygems/test_utilities.rb
  52. +19 −37 lib/ruby/shared/rubygems/uninstaller.rb
  53. +2 −5 lib/ruby/shared/rubygems/version.rb
  54. +5 −5 nbproject/project.xml
  55. +1 −1  netbeans-ant.xml
  56. +2 −2 spec/java_integration/utilities/jar_glob_spec.rb
  57. +2 −3 test/org/jruby/embed/MultipleScriptsRunner.java
  58. +1 −2  test/org/jruby/embed/ReaderInputStreamTest.java
View
14 build.xml
@@ -526,12 +526,12 @@
</classpath>
<sysproperty key="jruby.home" value="${jar-stdlib-home}"/>
<env key="RUBYOPT" value=""/>
- <env key="GEM_HOME" value="${jar-stdlib-home}/lib/ruby/gems/1.8"/>
+ <env key="GEM_HOME" value="${basedir}${jar-stdlib-home}/lib/ruby/gems/shared"/>
<jvmarg line="${java.opts}"/>
<arg line="-S gem install ${complete.jar.gems}"/>
<arg line="--no-ri --no-rdoc --ignore-dependencies --env-shebang"/>
</java>
- <delete dir="${jar-stdlib-home}/lib/ruby/gems/1.8/cache"/>
+ <delete dir="${jar-stdlib-home}/lib/ruby/gems/shared/cache"/>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0.jar"/>
<jarjar destfile="${dest.lib.dir}/${filename}">
@@ -580,12 +580,12 @@
</classpath>
<sysproperty key="jruby.home" value="${jar-complete-home}"/>
<env key="RUBYOPT" value=""/>
- <env key="GEM_HOME" value="${jar-complete-home}/lib/ruby/gems/1.8"/>
+ <env key="GEM_HOME" value="${basedir}/${jar-complete-home}/lib/ruby/gems/shared"/>
<jvmarg line="${java.opts}"/>
<arg line="-S gem install ${complete.jar.gems}"/>
<arg line="--no-ri --no-rdoc --ignore-dependencies --env-shebang"/>
</java>
- <delete dir="${jar-complete-home}/lib/ruby/gems/1.8/cache"/>
+ <delete dir="${jar-complete-home}/lib/ruby/gems/shared/cache"/>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0.jar"/>
<jarjar destfile="${dest.lib.dir}/${filename}">
@@ -825,7 +825,7 @@
<classpath refid="build.classpath"/>
<classpath path="${jruby.classes.dir}"/>
<sysproperty key="jruby.home" value="${basedir}"/>
- <env key="PATH" value="${basedir}/lib/ruby/gems/1.8/bin:${env.PATH}"/>
+ <env key="PATH" value="${basedir}/lib/ruby/gems/shared/bin:${env.PATH}"/>
<env key="GEM_PATH" value=""/> <!-- to ignore any gems installed in ~/.gem -->
<arg line="-S gem install ${jruby.launcher.gem}"/>
</java>
@@ -1361,9 +1361,7 @@
<patternset id="dist.lib.files">
<include name="lib/ruby/1.8/**"/>
<include name="lib/ruby/1.9/**"/>
- <include name="lib/ruby/site_ruby/**"/>
- <include name="lib/ruby/gems/1.8/specifications/sources-0.0.1.gemspec"/>
- <include name="lib/ruby/gems/1.8/gems/sources-0.0.1/**"/>
+ <include name="lib/ruby/shared/**"/>
</patternset>
<patternset id="dist.files">
View
4 default.build.properties
@@ -85,7 +85,7 @@ tzdata.distributed.version=2010k
tzdata.latest.version=2011k
jline.version=1.0
asm.version=4.0
-shared.lib.dir=lib/ruby/site_ruby/shared
+shared.lib.dir=lib/ruby/shared
asm.jar=${build.lib.dir}/asm-${asm.version}.jar
asm.commons.jar=${build.lib.dir}/asm-commons-${asm.version}.jar
asm.util.jar=${build.lib.dir}/asm-util-${asm.version}.jar
@@ -94,5 +94,5 @@ asm.tree.jar=${build.lib.dir}/asm-tree-${asm.version}.jar
mac.dist=${build.dir}/jruby-${version.jruby}
dist.zip=${dist.dir}/jruby-bin-${version.jruby}.zip
gems.dist.dir=${build.dir}/gems_dist
-gems.defaults.dir=${mac.dist}/lib/ruby/site_ruby/1.8/rubygems/defaults
+gems.defaults.dir=${mac.dist}/lib/ruby/shared/rubygems/defaults
jruby.default.ruby.version=1.8
View
172 lib/ruby/shared/rubygems.rb
@@ -5,6 +5,30 @@
# See LICENSE.txt for permissions.
#++
+module Gem
+ QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
+ GEM_PRELUDE_SUCKAGE = false
+end
+
+if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
+ Gem::QuickLoader.remove
+
+ $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
+
+ if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
+ # TODO path does not exist here
+ raise LoadError, "another rubygems is already loaded from #{path}"
+ end
+
+ class << Gem
+ remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+ end
+end
+
+require 'rubygems/defaults'
+require 'rbconfig'
+require "rubygems/deprecate"
+
##
# RubyGems is the Ruby standard for publishing and managing third party
# libraries.
@@ -46,8 +70,8 @@
# For RubyGems packagers, provide lib/rubygems/operating_system.rb and
# override any defaults from lib/rubygems/defaults.rb.
#
-# For Ruby implementers, provide lib/rubygems/defaults/#{RUBY_ENGINE}.rb and
-# override any defaults from lib/rubygems/defaults.rb.
+# For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override
+# any defaults from lib/rubygems/defaults.rb.
#
# If you need RubyGems to perform extra work on install or uninstall, your
# defaults override file can set pre and post install and uninstall hooks.
@@ -57,8 +81,8 @@
# == Bugs
#
# You can submit bugs to the
-# {RubyGems bug tracker}[https://github.com/rubygems/rubygems/issues]
-# on GitHub
+# {RubyGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126]
+# on RubyForge
#
# == Credits
#
@@ -86,8 +110,6 @@
# * Daniel Berger -- djberg96(at)gmail.com
# * Phil Hagelberg -- technomancy(at)gmail.com
# * Ryan Davis -- ryand-ruby(at)zenspider.com
-# * Evan Phoenix -- evan(at)fallingsnow.net
-# * Steve Klabnik -- steve(at)steveklabnik.com
#
# (If your name is missing, PLEASE let us know!)
#
@@ -95,41 +117,8 @@
#
# -The RubyGems Team
-# Ruby 1.9.x has introduced some things that are awkward, and we need to
-# support them, so we define some constants to use later.
-module Gem
- QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
- GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/
-end
-
-# Gem::QuickLoader exists in the gem prelude code in ruby 1.9.2 itself.
-# We gotta get rid of it if it's there, before we do anything else.
-#
-# REFACTOR: Pulling this kind of thing out into some sort of file with
-# all of the hacks would be a Good Idea.
-if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
- Gem::QuickLoader.remove
-
- $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
-
- if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
- # TODO path does not exist here
- raise LoadError, "another rubygems is already loaded from #{path}"
- end
-
- class << Gem
- remove_method :try_activate if Gem.respond_to?(:try_activate, true)
- end
-end
-
-require 'rubygems/defaults'
-require 'rbconfig'
-require "rubygems/deprecate"
-
-
module Gem
- VERSION = '1.8.10'
- DEFAULT_HOST = "https://rubygems.org"
+ VERSION = '1.8.13'
##
# Raised when RubyGems is unable to load or activate a gem. Contains the
@@ -143,12 +132,7 @@ class LoadError < ::LoadError
# Version requirement of gem
attr_accessor :requirement
end
-
- # REFACTOR: Things like stopdoc tend to indicate that something might not
- # be particularly well factored, and in this case, this is true. We're
- # sort of patching over weirdness with RbConfig. This should be pulled
- # out into some sort of file with all the compatibility hacks in it.
-
+
# :stopdoc:
RubyGemsVersion = VERSION
@@ -259,10 +243,8 @@ def self.activate_spec spec # :nodoc:
spec.activate
end
- # DOC: This needs to be documented or nodoc'd.
-
def self.unresolved_deps
- Gem::Specification.unresolved_deps
+ @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n }
end
##
@@ -406,12 +388,10 @@ def self.deflate(data)
Zlib::Deflate.deflate data
end
- # DOC: needs doc'd or :nodoc'd
def self.paths
@paths ||= Gem::PathSupport.new
end
- # DOC: needs doc'd or :nodoc'd
def self.paths=(env)
clear_paths
@paths = Gem::PathSupport.new env
@@ -465,7 +445,7 @@ def self.ensure_gem_subdirectories dir = Gem.dir
require 'fileutils'
old_umask = File.umask
- File.umask old_umask | 002
+ File.umask old_umask | 022
%w[cache doc gems specifications].each do |name|
subdir = File.join dir, name
@@ -589,7 +569,7 @@ def self.inflate(data)
def self.host
# TODO: move to utils
- @host ||= Gem::DEFAULT_HOST
+ @host ||= "https://rubygems.org"
end
## Set the default RubyGems API host.
@@ -648,7 +628,8 @@ def self.load_path_insert_index
if QUICKLOADER_SUCKAGE then
$LOAD_PATH.each_with_index do |path, i|
- if path.instance_variable_defined?(:@gem_prelude_index) then
+ if path.instance_variables.include?(:@gem_prelude_index) or
+ path.instance_variables.include?('@gem_prelude_index') then
index = i
break
end
@@ -760,15 +741,6 @@ def self.post_install(&hook)
end
##
- # Adds a post-installs hook that will be passed a Gem::DependencyInstaller
- # and a list of installed specifications when
- # Gem::DependencyInstaller#install is complete
-
- def self.done_installing(&hook)
- @done_installing_hooks << hook
- end
-
- ##
# Adds a hook that will get run after Gem::Specification.reset is
# run.
@@ -927,7 +899,6 @@ def self.ruby
@ruby
end
- # DOC: needs doc'd or :nodoc'd
def self.latest_spec_for name
dependency = Gem::Dependency.new name
fetcher = Gem::SpecFetcher.fetcher
@@ -942,16 +913,13 @@ def self.latest_spec_for name
match and fetcher.fetch_spec(*match)
end
- # DOC: needs doc'd or :nodoc'd
def self.latest_version_for name
spec = latest_spec_for name
spec and spec.version
end
- # DOC: needs doc'd or :nodoc'd
def self.latest_rubygems_version
- latest_version_for("rubygems-update") or
- raise "Can't find 'rubygems-update' in any repo. Check `gem source list`."
+ latest_version_for "rubygems-update"
end
##
@@ -971,14 +939,6 @@ def self.ruby_version
end
##
- # A Gem::Version for the currently running RubyGems
-
- def self.rubygems_version
- return @rubygems_version if defined? @rubygems_version
- @rubygems_version = Gem::Version.new Gem::VERSION
- end
-
- ##
# The GemPathSearcher object used to search for matching installed gems.
def self.searcher
@@ -1006,9 +966,6 @@ def self.sources
##
# Need to be able to set the sources without calling
# Gem.sources.replace since that would cause an infinite loop.
- #
- # DOC: This comment is not documentation about the method itself, it's
- # more of a code comment about the implementation.
def self.sources= new_sources
@sources = new_sources
@@ -1021,6 +978,12 @@ def self.suffix_pattern
@suffix_pattern ||= "{#{suffixes.join(',')}}"
end
+ def self.loaded_path? path
+ # TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9
+ re = /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
+ $LOADED_FEATURES.any? { |s| s =~ re }
+ end
+
##
# Suffixes for require-able paths.
@@ -1075,7 +1038,7 @@ def self.use_paths(home, *paths)
# The home directory for the user.
def self.user_home
- @user_home ||= find_home.untaint
+ @user_home ||= find_home
end
##
@@ -1134,9 +1097,6 @@ def self.load_env_plugins
load_plugin_files files
end
- # FIX: Almost everywhere else we use the `def self.` way of defining class
- # methods, and then we switch over to `class << self` here. Pick one or the
- # other.
class << self
##
@@ -1145,36 +1105,29 @@ class << self
attr_reader :loaded_specs
##
- # The list of hooks to be run after Gem::Installer#install extracts files
- # and builds extensions
+ # The list of hooks to be run before Gem::Install#install finishes
+ # installation
attr_reader :post_build_hooks
##
- # The list of hooks to be run after Gem::Installer#install completes
- # installation
+ # The list of hooks to be run before Gem::Install#install does any work
attr_reader :post_install_hooks
##
- # The list of hooks to be run after Gem::DependencyInstaller installs a
- # set of gems
-
- attr_reader :done_installing_hooks
-
- ##
# The list of hooks to be run after Gem::Specification.reset is run.
attr_reader :post_reset_hooks
##
- # The list of hooks to be run after Gem::Uninstaller#uninstall completes
- # installation
+ # The list of hooks to be run before Gem::Uninstall#uninstall does any
+ # work
attr_reader :post_uninstall_hooks
##
- # The list of hooks to be run before Gem::Installer#install does any work
+ # The list of hooks to be run after Gem::Install#install is finished
attr_reader :pre_install_hooks
@@ -1184,8 +1137,7 @@ class << self
attr_reader :pre_reset_hooks
##
- # The list of hooks to be run before Gem::Uninstaller#uninstall does any
- # work
+ # The list of hooks to be run after Gem::Uninstall#uninstall is finished
attr_reader :pre_uninstall_hooks
end
@@ -1212,14 +1164,10 @@ def self.cache # :nodoc:
autoload :Platform, 'rubygems/platform'
autoload :Builder, 'rubygems/builder'
autoload :ConfigFile, 'rubygems/config_file'
-
- require "rubygems/specification"
end
-# REFACTOR: All these patches should be pulled out into their own file.
module Kernel
- # REFACTOR: This should be pulled out into some kind of hacks file.
remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
##
@@ -1251,18 +1199,6 @@ module Kernel
def gem(gem_name, *requirements) # :doc:
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
-
- if gem_name.kind_of? Gem::Dependency
- unless Gem::Deprecate.skip
- warn "#{Gem.location_of_caller.join ':'}:Warning: Kernel.gem no longer "\
- "accepts a Gem::Dependency object, please pass the name "\
- "and requirements directly"
- end
-
- requirements = gem_name.requirement
- gem_name = gem_name.name
- end
-
spec = Gem::Dependency.new(gem_name, *requirements).to_spec
spec.activate if spec
end
@@ -1276,11 +1212,6 @@ def gem(gem_name, *requirements) # :doc:
# the package is loaded as a gem, return the gem specific data directory.
# Otherwise return a path to the share area as define by
# "#{ConfigMap[:datadir]}/#{package_name}".
-#
-# REFACTOR: This should be pulled out into some kind of compatiblity file
-# with all the hacks to other stuff.
-#
-# FIX: This has both a comment and nodoc. Which is right?
def RbConfig.datadir(package_name) # :nodoc:
warn "#{Gem.location_of_caller.join ':'}:Warning: " \
@@ -1295,7 +1226,6 @@ def RbConfig.datadir(package_name) # :nodoc:
require 'rubygems/exceptions'
-# REFACTOR: This should be pulled out into some kind of hacks file.
gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
begin
@@ -1322,7 +1252,6 @@ def RbConfig.datadir(package_name) # :nodoc:
require 'rubygems/custom_require'
-# REFACTOR: This should be pulled out into some kind of file.
module Gem
class << self
extend Gem::Deprecate
@@ -1343,6 +1272,5 @@ class << self
deprecate :required_location, :none, 2011, 11
deprecate :searcher, "Specification", 2011, 11
deprecate :source_index, "Specification", 2011, 11
- deprecate :unresolved_deps, "Specification.unresolved_deps", 2011, 12
end
end
View
2  lib/ruby/shared/rubygems/builder.rb
@@ -4,8 +4,6 @@
# See LICENSE.txt for permissions.
#++
-# TODO: Merge with Gem::Format
-
require 'rubygems'
require 'rubygems/user_interaction'
View
6 lib/ruby/shared/rubygems/command.rb
@@ -9,7 +9,7 @@
##
# Base class for all Gem commands. When creating a new gem command, define
-# #initialize, #execute, #arguments, #defaults_str, #description and #usage
+# #new, #execute, #arguments, #defaults_str, #description and #usage
# (as appropriate). See the above mentioned methods for details.
#
# A very good example to look at is Gem::Commands::ContentsCommand
@@ -344,7 +344,7 @@ def handles?(args)
def handle_options(args)
args = add_extra_args(args)
- @options = Marshal.load Marshal.dump @defaults # deep copy
+ @options = @defaults.clone
parser.parse!(args)
@options[:args] = args
end
@@ -529,7 +529,7 @@ def wrap(text, width) # :doc:
end
##
-# \Commands will be placed in this namespace
+# This is where Commands will be placed in the namespace
module Gem::Commands
end
View
30 lib/ruby/shared/rubygems/command_manager.rb
@@ -18,15 +18,12 @@
# # file rubygems_plugin.rb
# require 'rubygems/command_manager'
#
-# Gem::CommandManager.instance.register_command :edit
-#
-# You should put the implementation of your command in rubygems/commands.
-#
-# # file rubygems/commands/edit_command.rb
# class Gem::Commands::EditCommand < Gem::Command
# # ...
# end
#
+# Gem::CommandManager.instance.register_command :edit
+#
# See Gem::Command for instructions on writing gem commands.
class Gem::CommandManager
@@ -66,7 +63,6 @@ def initialize
register_command :install
register_command :list
register_command :lock
- register_command :mirror
register_command :outdated
register_command :owner
register_command :pristine
@@ -99,7 +95,7 @@ def unregister_command(command)
end
##
- # Returns a Command instance for +command_name+
+ # Return the registered command from the command name.
def [](command_name)
command_name = command_name.intern
@@ -108,14 +104,14 @@ def [](command_name)
end
##
- # Return a sorted list of all command names as strings.
+ # Return a sorted list of all command names (as strings).
def command_names
@commands.keys.collect {|key| key.to_s}.sort
end
##
- # Run the command specified by +args+.
+ # Run the config specified by +args+.
def run(args)
process_args(args)
@@ -123,17 +119,6 @@ def run(args)
alert_error "While executing gem ... (#{ex.class})\n #{ex.to_s}"
ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
Gem.configuration.backtrace
-
- if Gem.configuration.really_verbose and \
- ex.kind_of?(Gem::Exception) and ex.source_exception
- e = ex.source_exception
-
- ui.errs.puts "Because of: (#{e.class})\n #{e.to_s}"
- if Gem.configuration.backtrace
- ui.errs.puts "\t#{e.backtrace.join "\n\t"}"
- end
- end
-
terminate_interaction(1)
rescue Interrupt
alert_error "Interrupted"
@@ -165,8 +150,7 @@ def process_args(args)
def find_command(cmd_name)
possibilities = find_command_possibilities cmd_name
- if possibilities.size > 1 then # TODO if there's an exact match, pick it
- # TODO raise Gem::Exception subclass
+ if possibilities.size > 1 then
raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
elsif possibilities.size < 1 then
raise "Unknown command #{cmd_name}"
@@ -202,7 +186,7 @@ def load_and_instantiate(command_name)
ui.errs.puts "\t#{e.backtrace.join "\n\t"}" if
Gem.configuration.backtrace
end
- retry # TODO: ugh. remove the clevar
+ retry
end
end
View
2  lib/ruby/shared/rubygems/commands/environment_command.rb
@@ -34,7 +34,6 @@ def description # :nodoc:
:update_sources: Enable/disable automatic updating of repository metadata
:backtrace: Print backtrace when RubyGems encounters an error
:gempath: The paths in which to look for gems
- :disable_default_gem_server: Force specification of gem server host on push
gem_command: A string containing arguments for the specified gem command
Example:
@@ -42,7 +41,6 @@ def description # :nodoc:
:verbose: false
install: --no-wrappers
update: --no-wrappers
- :disable_default_gem_server: true
RubyGems' default local repository can be overridden with the GEM_PATH and
GEM_HOME environment variables. GEM_HOME sets the default repository to
View
20 lib/ruby/shared/rubygems/commands/fetch_command.rb
@@ -42,20 +42,9 @@ def execute
dep = Gem::Dependency.new gem_name, version
dep.prerelease = options[:prerelease]
- # Because of the madness that is SpecFetcher, you can't
- # set both all and prerelease to true. If you do, prerelease
- # is ignored.
-
- if dep.prerelease? and all
- specs_and_sources, errors =
- Gem::SpecFetcher.fetcher.fetch_with_errors(dep, false, true,
- dep.prerelease?)
- else
- specs_and_sources, errors =
- Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
- dep.prerelease?)
- end
-
+ specs_and_sources, errors =
+ Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
+ dep.prerelease?)
if platform then
filtered = specs_and_sources.select { |s,| s.platform == platform }
@@ -69,7 +58,8 @@ def execute
next
end
- Gem::RemoteFetcher.fetcher.download spec, source_uri, Dir.pwd
+ path = Gem::RemoteFetcher.fetcher.download spec, source_uri
+ FileUtils.mv path, File.basename(spec.cache_file)
say "Downloaded #{spec.full_name}"
end
View
46 lib/ruby/shared/rubygems/commands/install_command.rb
@@ -1,11 +1,10 @@
require 'rubygems/command'
+require 'rubygems/doc_manager'
require 'rubygems/install_update_options'
require 'rubygems/dependency_installer'
require 'rubygems/local_remote_options'
require 'rubygems/validator'
require 'rubygems/version_option'
-require 'rubygems/install_message' # must come before rdoc for messaging
-require 'rubygems/rdoc'
##
# Gem installer command line tool
@@ -14,14 +13,14 @@
class Gem::Commands::InstallCommand < Gem::Command
- attr_reader :installed_specs # :nodoc:
-
include Gem::VersionOption
include Gem::LocalRemoteOptions
include Gem::InstallUpdateOptions
def initialize
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
+ :generate_rdoc => true,
+ :generate_ri => true,
:format_executable => false,
:version => Gem::Requirement.default,
})
@@ -33,8 +32,6 @@ def initialize
add_platform_option
add_version_option
add_prerelease_option "to be installed. (Only for listed gems)"
-
- @installed_specs = nil
end
def arguments # :nodoc:
@@ -109,15 +106,10 @@ def execute
alert "use --ignore-dependencies to install only the gems you list"
end
- @installed_specs = []
+ installed_gems = []
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
- if options[:install_dir] and options[:user_install]
- alert_error "Use --install-dir or --user-install but not both"
- terminate_interaction 1
- end
-
exit_code = 0
get_all_gem_names.each do |gem_name|
@@ -128,7 +120,11 @@ def execute
inst = Gem::DependencyInstaller.new options
inst.install gem_name, options[:version]
- @installed_specs.push(*inst.installed_gems)
+ inst.installed_gems.each do |spec|
+ say "Successfully installed #{spec.full_name}"
+ end
+
+ installed_gems.push(*inst.installed_gems)
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
@@ -139,9 +135,27 @@ def execute
end
end
- unless @installed_specs.empty? then
- gems = @installed_specs.length == 1 ? 'gem' : 'gems'
- say "#{@installed_specs.length} #{gems} installed"
+ unless installed_gems.empty? then
+ gems = installed_gems.length == 1 ? 'gem' : 'gems'
+ say "#{installed_gems.length} #{gems} installed"
+
+ # NOTE: *All* of the RI documents must be generated first. For some
+ # reason, RI docs cannot be generated after any RDoc documents are
+ # generated.
+
+ if options[:generate_ri] then
+ installed_gems.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
+ end
+
+ Gem::DocManager.update_ri_cache
+ end
+
+ if options[:generate_rdoc] then
+ installed_gems.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
+ end
+ end
end
raise Gem::SystemExitException, exit_code
View
14 lib/ruby/shared/rubygems/commands/owner_command.rb
@@ -63,16 +63,12 @@ def remove_owners name, owners
def manage_owners method, name, owners
owners.each do |owner|
- begin
- response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
- request.set_form_data 'email' => owner
- request.add_field "Authorization", api_key
- end
-
- with_response response
- rescue
- # ignore
+ response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
+ request.set_form_data 'email' => owner
+ request.add_field "Authorization", api_key
end
+
+ with_response response
end
end
View
4 lib/ruby/shared/rubygems/commands/pristine_command.rb
@@ -94,10 +94,12 @@ def execute
end
# TODO use installer options
+ # Modified for JRUBY-5031, to propagate --env-shebang if set
installer = Gem::Installer.new(gem,
:wrappers => true,
:force => true,
- :install_dir => spec.base_dir)
+ :install_dir => spec.base_dir,
+ :env_shebang => !Gem::ConfigFile::PLATFORM_DEFAULTS['install'].to_s['--env-shebang'].nil?)
installer.install
say "Restored #{spec.full_name}"
View
13 lib/ruby/shared/rubygems/commands/push_command.rb
@@ -1,7 +1,6 @@
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
-require 'rubygems/format'
class Gem::Commands::PushCommand < Gem::Command
include Gem::LocalRemoteOptions
@@ -40,23 +39,13 @@ def execute
def send_gem name
args = [:post, "api/v1/gems"]
+ args << options[:host] if options[:host]
if Gem.latest_rubygems_version < Gem::Version.new(Gem::VERSION) then
alert_error "Using beta/unreleased version of rubygems. Not pushing."
terminate_interaction 1
end
- host = options[:host]
- unless host
- if gem_data = Gem::Format.from_file_by_path(name)
- host = gem_data.spec.metadata['default_gem_server']
- end
- end
-
- args << host if host
-
- say "Pushing gem to #{host || Gem.host}..."
-
response = rubygems_api_request(*args) do |request|
request.body = Gem.read_binary name
request.add_field "Content-Length", request.body.size
View
47 lib/ruby/shared/rubygems/commands/rdoc_command.rb
@@ -1,6 +1,6 @@
require 'rubygems/command'
require 'rubygems/version_option'
-require 'rubygems/rdoc'
+require 'rubygems/doc_manager'
class Gem::Commands::RdocCommand < Gem::Command
include Gem::VersionOption
@@ -54,32 +54,37 @@ def usage # :nodoc:
end
def execute
- specs = if options[:all] then
- Gem::Specification.to_a
- else
- get_all_gem_names.map do |name|
- Gem::Specification.find_by_name name, options[:version]
- end.flatten.uniq
- end
-
- if specs.empty? then
- alert_error 'No matching gems found'
- terminate_interaction 1
+ if options[:all] then
+ specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec|
+ spec
+ }
+ else
+ gem_name = get_one_gem_name
+ dep = Gem::Dependency.new gem_name, options[:version]
+ specs = Gem::SourceIndex.from_installed_gems.search dep
end
- specs.each do |spec|
- doc = Gem::RDoc.new spec, options[:include_rdoc], options[:include_ri]
+ if specs.empty?
+ raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
+ end
- doc.force = options[:overwrite]
+ if options[:include_ri]
+ specs.sort.each do |spec|
+ doc = Gem::DocManager.new(spec)
+ doc.generate_ri if options[:overwrite] || !doc.ri_installed?
+ end
- begin
- doc.generate
- rescue Errno::ENOENT => e
- e.message =~ / - /
- alert_error "Unable to document #{spec.full_name}, #{$'} is missing, skipping"
- terminate_interaction 1 if specs.length == 1
+ Gem::DocManager.update_ri_cache
+ end
+
+ if options[:include_rdoc]
+ specs.sort.each do |spec|
+ doc = Gem::DocManager.new(spec)
+ doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
end
end
+
+ true
end
end
View
40 lib/ruby/shared/rubygems/commands/setup_command.rb
@@ -5,8 +5,6 @@
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
- HISTORY_HEADER = /^===\s*[\d.]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
- VERSION_MATCHER = /^===\s*([\d.]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
def initialize
require 'tmpdir'
@@ -14,13 +12,7 @@ def initialize
super 'setup', 'Install RubyGems',
:format_executable => true, :rdoc => true, :ri => true,
:site_or_vendor => :sitelibdir,
- :destdir => '', :prefix => '', :previous_version => ''
-
- add_option '--previous-version=VERSION',
- 'Previous version of rubygems',
- 'Used for changelog processing' do |version, options|
- options[:previous_version] = version
- end
+ :destdir => '', :prefix => ''
add_option '--prefix=PREFIX',
'Prefix path for installing RubyGems',
@@ -126,30 +118,14 @@ def execute
say
end
- if options[:previous_version].empty?
- options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, '0')
- end
-
- options[:previous_version] = Gem::Version.new(options[:previous_version])
-
release_notes = File.join Dir.pwd, 'History.txt'
release_notes = if File.exist? release_notes then
- history = File.read release_notes
- history = history.sub(/^# coding:.*?^=/m, '')
-
- text = history.split(HISTORY_HEADER)
- text.shift # correct an off-by-one generated by split
- version_lines = history.scan(HISTORY_HEADER)
- versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) }
-
- history_string = ""
-
- until versions.length == 0 or versions.shift < options[:previous_version]
- history_string += version_lines.shift + text.shift
+ open release_notes do |io|
+ text = io.gets '==='
+ text << io.gets('===')
+ text[0...-3].sub(/^# coding:.*?^=/m, '')
end
-
- history_string
else
"Oh-no! Unable to find release notes!"
end
@@ -277,7 +253,7 @@ def install_rdoc
def make_destination_dirs(install_destdir)
lib_dir, bin_dir = Gem.default_rubygems_dirs
-
+p lib_dir
unless lib_dir
lib_dir, bin_dir = generate_default_dirs(install_destdir)
end
@@ -287,7 +263,7 @@ def make_destination_dirs(install_destdir)
return lib_dir, bin_dir
end
-
+
def generate_default_dirs(install_destdir)
prefix = options[:prefix]
site_or_vendor = options[:site_or_vendor]
@@ -316,7 +292,7 @@ def generate_default_dirs(install_destdir)
lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
end
-
+
[lib_dir, bin_dir]
end
View
13 lib/ruby/shared/rubygems/commands/specification_command.rb
@@ -17,7 +17,6 @@ def initialize
add_version_option('examine')
add_platform_option
- add_prerelease_option
add_option('--all', 'Output specifications for all versions of',
'the gem') do |value, options|
@@ -81,21 +80,13 @@ def execute
end
if remote? then
- if !options[:version] or options[:version].none?
- found = Gem::SpecFetcher.fetcher.fetch dep, false, false,
- options[:prerelease]
- else
- # .fetch is super weird. The last true is there so that
- # prerelease gems are included, otherwise the user can never
- # request them.
- found = Gem::SpecFetcher.fetcher.fetch dep, false, false, true
- end
+ found = Gem::SpecFetcher.fetcher.fetch dep
specs.push(*found.map { |spec,| spec })
end
if specs.empty? then
- alert_error "No gem matching '#{dep}' found"
+ alert_error "Unknown gem '#{gem}'"
terminate_interaction 1
end
View
21 lib/ruby/shared/rubygems/commands/uninstall_command.rb
@@ -54,11 +54,6 @@ def initialize
options[:format_executable] = value
end
- add_option('--[no-]force',
- 'Uninstall all gems according to name, regardless of dependencies upon it.') do |value, options|
- options[:force] = value
- end
-
add_version_option
add_platform_option
end
@@ -78,23 +73,19 @@ def usage # :nodoc:
end
def execute
- # REFACTOR: stolen from cleanup_command
- deplist = Gem::DependencyList.new
- get_all_gem_names.uniq.each do |name|
- Gem::Specification.find_all_by_name(name).each do |spec|
- deplist.add spec
- end
- end
-
- deps = deplist.strongly_connected_components.flatten.reverse
+ original_path = Gem.path
- deps.map(&:name).uniq.each do |gem_name|
+ get_all_gem_names.each do |gem_name|
begin
Gem::Uninstaller.new(gem_name, options).uninstall
+ rescue Gem::InstallError => e
+ alert e.message
rescue Gem::GemNotInHomeException => e
spec = e.spec
alert("In order to remove #{spec.name}, please execute:\n" \
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
+ ensure
+ Gem.use_paths(*original_path)
end
end
end
View
45 lib/ruby/shared/rubygems/commands/update_command.rb
@@ -1,12 +1,10 @@
require 'rubygems/command'
require 'rubygems/command_manager'
-require 'rubygems/dependency_installer'
require 'rubygems/install_update_options'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
require 'rubygems/version_option'
-require 'rubygems/install_message' # must come before rdoc for messaging
-require 'rubygems/rdoc'
+require 'rubygems/commands/install_command'
class Gem::Commands::UpdateCommand < Gem::Command
@@ -15,9 +13,11 @@ class Gem::Commands::UpdateCommand < Gem::Command
include Gem::VersionOption
def initialize
- super 'update', 'Update installed gems to the latest version',
- :document => %w[rdoc ri],
- :force => false
+ super 'update',
+ 'Update the named gems (or all installed gems) in the local repository',
+ :generate_rdoc => true,
+ :generate_ri => true,
+ :force => false
add_install_update_options
@@ -37,9 +37,6 @@ def initialize
add_local_remote_options
add_platform_option
add_prerelease_option "as update targets"
-
- @updated = []
- @installer = Gem::DependencyInstaller.new options
end
def arguments # :nodoc:
@@ -55,6 +52,9 @@ def usage # :nodoc:
end
def execute
+ @installer = Gem::DependencyInstaller.new options
+ @updated = []
+
hig = {}
if options[:system] then
@@ -79,7 +79,21 @@ def execute
if updated.empty? then
say "Nothing to update"
else
- say "Gems updated: #{updated.map { |spec| spec.name }.join ' '}"
+ say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
+
+ if options[:generate_ri] then
+ updated.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
+ end
+
+ Gem::DocManager.update_ri_cache
+ end
+
+ if options[:generate_rdoc] then
+ updated.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
+ end
+ end
end
end
@@ -98,6 +112,7 @@ def update_gem name, version = Gem::Requirement.default
@installer.installed_gems.each do |spec|
@updated << spec
+ say "Successfully installed #{spec.full_name}" if success
end
end
@@ -163,9 +178,8 @@ def update_rubygems
args = []
args << '--prefix' << Gem.prefix if Gem.prefix
- # TODO use --document for >= 1.9 , --no-rdoc --no-ri < 1.9
- args << '--no-rdoc' unless options[:document].include? 'rdoc'
- args << '--no-ri' unless options[:document].include? 'ri'
+ args << '--no-rdoc' unless options[:generate_rdoc]
+ args << '--no-ri' unless options[:generate_ri]
args << '--no-format-executable' if options[:no_format_executable]
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
@@ -191,12 +205,9 @@ def which_to_update highest_installed_gems, gem_names, system = false
gem_names.all? { |name| /#{name}/ !~ l_spec.name }
dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
- dependency.prerelease = options[:prerelease]
fetcher = Gem::SpecFetcher.fetcher
-
- spec_tuples = fetcher.find_matching dependency, false, true,
- options[:prerelease]
+ spec_tuples = fetcher.find_matching dependency
matching_gems = spec_tuples.select do |(name, _, platform),|
name == l_name and Gem::Platform.match platform
View
104 lib/ruby/shared/rubygems/config_file.rb
@@ -129,11 +129,6 @@ class Gem::ConfigFile
attr_reader :api_keys
##
- # True if we want to force specification of gem server when pushing a gem
-
- attr_accessor :disable_default_gem_server
-
- ##
# Create the config file object. +args+ is the list of arguments
# from the command line.
#
@@ -151,27 +146,26 @@ class Gem::ConfigFile
# <tt>--debug</tt>::
# Enable Ruby level debug messages. Handled early for the same reason as
# --backtrace.
- #--
- # TODO: parse options upstream, pass in options directly
- def initialize(args)
+ def initialize(arg_list)
@config_file_name = nil
need_config_file_name = false
- arg_list = []
-
- args.each do |arg|
+ arg_list = arg_list.map do |arg|
if need_config_file_name then
@config_file_name = arg
need_config_file_name = false
+ nil
elsif arg =~ /^--config-file=(.*)/ then
@config_file_name = $1
+ nil
elsif arg =~ /^--config-file$/ then
need_config_file_name = true
+ nil
else
- arg_list << arg
+ arg
end
- end
+ end.compact
@backtrace = DEFAULT_BACKTRACE
@benchmark = DEFAULT_BENCHMARK
@@ -189,14 +183,13 @@ def initialize(args)
@hash = @hash.merge user_config
# HACK these override command-line args, which is bad
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
- @benchmark = @hash[:benchmark] if @hash.key? :benchmark
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- @home = @hash[:gemhome] if @hash.key? :gemhome
- @path = @hash[:gempath] if @hash.key? :gempath
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
- @verbose = @hash[:verbose] if @hash.key? :verbose
- @disable_default_gem_server = @hash[:verbose] if @hash.key? :disable_default_gem_server
+ @backtrace = @hash[:backtrace] if @hash.key? :backtrace
+ @benchmark = @hash[:benchmark] if @hash.key? :benchmark
+ @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
+ @home = @hash[:gemhome] if @hash.key? :gemhome
+ @path = @hash[:gempath] if @hash.key? :gempath
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
+ @verbose = @hash[:verbose] if @hash.key? :verbose
load_api_keys
@@ -217,7 +210,6 @@ def load_api_keys
else
@hash
end
-
if @api_keys.key? :rubygems_api_key then
@rubygems_api_key = @api_keys[:rubygems_api_key]
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems
@@ -243,16 +235,13 @@ def load_file(filename)
Gem.load_yaml
return {} unless filename and File.exist? filename
-
begin
- return YAML.load(File.read(filename))
+ YAML.load(File.read(filename))
rescue ArgumentError
warn "Failed to load #{config_file_name}"
rescue Errno::EACCES
warn "Failed to load #{config_file_name} due to permissions problem."
- end
-
- {}
+ end or {}
end
# True if the backtrace option has been specified, or debug is on.
@@ -306,47 +295,25 @@ def handle_arguments(arg_list)
# Really verbose mode gives you extra output.
def really_verbose
case verbose
- when true, false, nil then
- false
- else
- true
+ when true, false, nil then false
+ else true
end
end
# to_yaml only overwrites things you can't override on the command line.
def to_yaml # :nodoc:
yaml_hash = {}
- yaml_hash[:backtrace] = if @hash.key?(:backtrace)
- @hash[:backtrace]
- else
- DEFAULT_BACKTRACE
- end
-
- yaml_hash[:benchmark] = if @hash.key?(:benchmark)
- @hash[:benchmark]
- else
- DEFAULT_BENCHMARK
- end
-
- yaml_hash[:bulk_threshold] = if @hash.key?(:bulk_threshold)
- @hash[:bulk_threshold]
- else
- DEFAULT_BULK_THRESHOLD
- end
-
+ yaml_hash[:backtrace] = @hash.key?(:backtrace) ? @hash[:backtrace] :
+ DEFAULT_BACKTRACE
+ yaml_hash[:benchmark] = @hash.key?(:benchmark) ? @hash[:benchmark] :
+ DEFAULT_BENCHMARK
+ yaml_hash[:bulk_threshold] = @hash.key?(:bulk_threshold) ?
+ @hash[:bulk_threshold] : DEFAULT_BULK_THRESHOLD
yaml_hash[:sources] = Gem.sources
-
- yaml_hash[:update_sources] = if @hash.key?(:update_sources)
- @hash[:update_sources]
- else
- DEFAULT_UPDATE_SOURCES
- end
-
- yaml_hash[:verbose] = if @hash.key?(:verbose)
- @hash[:verbose]
- else
- DEFAULT_VERBOSITY
- end
+ yaml_hash[:update_sources] = @hash.key?(:update_sources) ?
+ @hash[:update_sources] : DEFAULT_UPDATE_SOURCES
+ yaml_hash[:verbose] = @hash.key?(:verbose) ? @hash[:verbose] :
+ DEFAULT_VERBOSITY
keys = yaml_hash.keys.map { |key| key.to_s }
keys << 'debug'
@@ -380,14 +347,15 @@ def []=(key, value)
def ==(other) # :nodoc:
self.class === other and
- @backtrace == other.backtrace and
- @benchmark == other.benchmark and
- @bulk_threshold == other.bulk_threshold and
- @verbose == other.verbose and
- @update_sources == other.update_sources and
- @hash == other.hash
+ @backtrace == other.backtrace and
+ @benchmark == other.benchmark and
+ @bulk_threshold == other.bulk_threshold and
+ @verbose == other.verbose and
+ @update_sources == other.update_sources and
+ @hash == other.hash
end
+ protected
+
attr_reader :hash
- protected :hash
end
View
80 lib/ruby/shared/rubygems/custom_require.rb
@@ -32,72 +32,28 @@ module Kernel
# that file has already been loaded is preserved.
def require path
- # If there are no unresolved deps, then we can use just try
- # normal require handle loading a gem from the rescue below.
-
- if Gem::Specification.unresolved_deps.empty? then
- return gem_original_require(path)
- end
-
- # If +path+ is for a gem that has already been loaded, don't
- # bother trying to find it in an unresolved gem, just go straight
- # to normal require.
- #--
- # TODO request access to the C implementation of this to speed up RubyGems
-
- spec = Gem::Specification.find { |s|
- s.activated? and s.contains_requirable_file? path
- }
-
- return gem_original_require(path) if spec
-
- # Attempt to find +path+ in any unresolved gems...
-
- found_specs = Gem::Specification.find_in_unresolved path
-
- # If there are no directly unresolved gems, then try and find +path+
- # in any gems that are available via the currently unresolved gems.
- # For example, given:
- #
- # a => b => c => d
- #
- # If a and b are currently active with c being unresolved and d.rb is
- # requested, then find_in_unresolved_tree will find d.rb in d because
- # it's a dependency of c.
- #
- if found_specs.empty? then
- found_specs = Gem::Specification.find_in_unresolved_tree path
-
- found_specs.each do |found_spec|
- found_spec.activate
- end
-
- # We found +path+ directly in an unresolved gem. Now we figure out, of
- # the possible found specs, which one we should activate.
+ if Gem.unresolved_deps.empty? then
+ gem_original_require path
else
-
- # Check that all the found specs are just different
- # versions of the same gem
- names = found_specs.map(&:name).uniq
-
- if names.size > 1 then
- raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
+ spec = Gem::Specification.find { |s|
+ s.activated? and s.contains_requirable_file? path
+ }
+
+ unless spec then
+ found_specs = Gem::Specification.find_in_unresolved path
+ unless found_specs.empty? then
+ found_specs = [found_specs.last]
+ else
+ found_specs = Gem::Specification.find_in_unresolved_tree path
+ end
+
+ found_specs.each do |found_spec|
+ found_spec.activate
+ end
end
- # Ok, now find a gem that has no conflicts, starting
- # at the highest version.
- valid = found_specs.select { |s| s.conflicts.empty? }.last
-
- unless valid then
- le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
- le.name = names.first
- raise le
- end
-
- valid.activate
+ return gem_original_require path
end
-
- gem_original_require path
rescue LoadError => load_error
if load_error.message.end_with?(path) and Gem.try_activate(path) then
return gem_original_require(path)
View
5 lib/ruby/shared/rubygems/defaults.rb
@@ -3,7 +3,6 @@ module Gem
# TODO: move this whole file back into rubygems.rb
@post_install_hooks ||= []
- @done_installing_hooks ||= []
@post_uninstall_hooks ||= []
@pre_uninstall_hooks ||= []
@pre_install_hooks ||= []
@@ -43,10 +42,10 @@ def self.default_dir
@default_dir ||= File.join(*path)
end
-
+
##
# Paths where RubyGems' .rb files and bin files are installed
-
+
def self.default_rubygems_dirs
nil # default to standard layout
end
View
20 lib/ruby/shared/rubygems/dependency.rb
@@ -1,8 +1,8 @@
+require "rubygems/requirement"
+
##
# The Dependency class holds a Gem name and a Gem::Requirement.
-require "rubygems/requirement"
-
class Gem::Dependency
##
@@ -11,9 +11,6 @@ class Gem::Dependency
# When this list is updated, be sure to change
# Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.
- # REFACTOR: This type of constant, TYPES, indicates we might want
- # two classes, used via inheretance or duck typing.
-
TYPES = [
:development,
:runtime,
@@ -115,8 +112,6 @@ def requirement
#
# Children, define explicit marshal and unmarshal behavior for
# public classes. Marshal formats are part of your public API.
-
- # REFACTOR: See above
if defined?(@version_requirement) && @version_requirement
version = @version_requirement.instance_variable_get :@version
@@ -127,7 +122,6 @@ def requirement
@requirement = @version_requirements if defined?(@version_requirements)
end
- # DOC: this method needs documentation or :nodoc''d
def requirements_list
requirement.as_list
end
@@ -185,8 +179,6 @@ def =~ other
requirement.satisfied_by? version
end
- # DOC: this method needs either documented or :nodoc'd
-
def match? name, version
return false unless self.name === name
return true if requirement.none?
@@ -194,8 +186,6 @@ def match? name, version
requirement.satisfied_by? Gem::Version.new(version)
end
- # DOC: this method needs either documented or :nodoc'd
-
def matches_spec? spec
return false unless name === spec.name
return true if requirement.none?
@@ -222,8 +212,6 @@ def merge other
self.class.new name, self_req.as_list.concat(other_req.as_list)
end
- # DOC: this method needs either documented or :nodoc'd
-
def matching_specs platform_only = false
matches = Gem::Specification.find_all { |spec|
self.name === spec.name and # TODO: == instead of ===
@@ -246,8 +234,6 @@ def specific?
@requirement.specific?
end
- # DOC: this method needs either documented or :nodoc'd
-
def to_specs
matches = matching_specs true
@@ -266,8 +252,6 @@ def to_specs
matches
end
- # DOC: this method needs either documented or :nodoc'd
-
def to_spec
matches = self.to_specs
View
119 lib/ruby/shared/rubygems/dependency_installer.rb
@@ -14,14 +14,8 @@ class Gem::DependencyInstaller
attr_reader :gems_to_install
attr_reader :installed_gems
- ##
- # Documentation types. For use by the Gem.done_installing hook
-
- attr_reader :document
-
DEFAULT_OPTIONS = {
:env_shebang => false,
- :document => %w[rdoc ri],
:domain => :both, # HACK dup
:force => false,
:format_executable => false, # HACK dup
@@ -29,7 +23,7 @@ class Gem::DependencyInstaller
:prerelease => false,
:security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
:wrappers => true,
- }.freeze
+ }
##
# Creates a new installer instance.
@@ -53,7 +47,6 @@ def initialize(options = {})
if options[:install_dir] then
@gem_home = options[:install_dir]
- # HACK shouldn't change the global settings
Gem::Specification.dirs = @gem_home
Gem.ensure_gem_subdirectories @gem_home
options[:install_dir] = @gem_home # FIX: because we suck and reuse below
@@ -62,9 +55,7 @@ def initialize(options = {})
options = DEFAULT_OPTIONS.merge options
@bin_dir = options[:bin_dir]
- @dev_shallow = options[:dev_shallow]
@development = options[:development]
- @document = options[:document]
@domain = options[:domain]
@env_shebang = options[:env_shebang]
@force = options[:force]
@@ -75,12 +66,7 @@ def initialize(options = {})
@user_install = options[:user_install]
@wrappers = options[:wrappers]
- # Indicates that we should not try to update any deps unless
- # we absolutely must.
- @minimal_deps = options[:minimal_deps]
-
@installed_gems = []
- @toplevel_specs = nil
@install_dir = options[:install_dir] || Gem.dir
@cache_dir = options[:cache_dir] || @install_dir
@@ -97,15 +83,11 @@ def initialize(options = {})
# local gems preferred over remote gems.
def find_gems_with_sources(dep)
- # HACK Reset the errors.
- # REFACTOR this method is called in a loop, we shouldn't wipe out previous
- # errors.
+ # Reset the errors
@errors = nil
gems_and_sources = []
if @domain == :both or @domain == :local then
- # REFACTOR rather than hardcoding using Dir.pwd, delegate to some config
- # that allows knows the directory to look for local gems.
Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.gem")].each do |gem_file|
spec = Gem::Format.from_file_by_path(gem_file).spec
gems_and_sources << [spec, gem_file] if spec.name == dep.name
@@ -119,7 +101,6 @@ def find_gems_with_sources(dep)
req
end
- # REFACTOR the API for fetch_with_errors sucks thats why +all+ exists.
all = !dep.prerelease? &&
# we only need latest if there's one requirement and it is
# guaranteed to match the newest specs
@@ -131,9 +112,6 @@ def find_gems_with_sources(dep)
gems_and_sources.push(*found)
rescue Gem::RemoteFetcher::FetchError => e
- # FIX if there is a problem talking to the network, we either need to always tell
- # the user (no really_verbose) or fail hard, not silently tell them that we just
- # couldn't find their requested gem.
if Gem.configuration.really_verbose then
say "Error fetching remote data:\t\t#{e.message}"
say "Falling back to local-only install"
@@ -142,9 +120,6 @@ def find_gems_with_sources(dep)
end
end
- # REFACTOR 2 of 3 users of this method call reverse on the results, perhaps
- # we're sorting them wrong. The other calls last, so perhaps it shuold use
- # a different API.
gems_and_sources.sort_by do |gem, source|
[gem, source =~ /^http:\/\// ? 0 : 1] # local gems win
end
@@ -160,17 +135,12 @@ def gather_dependencies
# these gems were listed by the user, always install them
keep_names = specs.map { |spec| spec.full_name }
- if @dev_shallow
- @toplevel_specs = keep_names
- end
-
dependency_list = Gem::DependencyList.new @development
dependency_list.add(*specs)
to_do = specs.dup
+
add_found_dependencies to_do, dependency_list unless @ignore_dependencies
- # REFACTOR maybe abstract away using Gem::Specification.include? so
- # that this isn't dependent only on the currently installed gems
dependency_list.specs.reject! { |spec|
not keep_names.include?(spec.full_name) and
Gem::Specification.include?(spec)
@@ -192,33 +162,15 @@ def add_found_dependencies to_do, dependency_list
until to_do.empty? do
spec = to_do.shift
-
- # HACK why is spec nil?
next if spec.nil? or seen[spec.name]
seen[spec.name] = true
deps = spec.runtime_dependencies
-
- if @development
- if @dev_shallow
- if @toplevel_specs.include? spec.full_name
- deps |= spec.development_dependencies
- end
- else
- deps |= spec.development_dependencies
- end
- end
+ deps |= spec.development_dependencies if @development
deps.each do |dep|
dependencies[dep.name] = dependencies[dep.name].merge dep
- if @minimal_deps
- next if Gem::Specification.any? do |installed_spec|
- dep.name == installed_spec.name and
- dep.requirement.satisfied_by? installed_spec.version
- end
- end
-
results = find_gems_with_sources(dep).reverse
results.reject! do |dep_spec,|
@@ -250,35 +202,29 @@ def add_found_dependencies to_do, dependency_list
def find_spec_by_name_and_version(gem_name,
version = Gem::Requirement.default,
prerelease = false)
-
spec_and_source = nil
- if @domain != :remote
- glob = if File::ALT_SEPARATOR then
- gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
- else
- gem_name
- end
-
- # REFACTOR Don't assume local gems are in the current directory
- local_gems = Dir["#{glob}*"].sort.reverse
-
- local_gems.each do |gem_file|
- next unless gem_file =~ /gem$/
- begin
- spec = Gem::Format.from_file_by_path(gem_file).spec
- spec_and_source = [spec, gem_file]
- break
- rescue SystemCallError, Gem::Package::FormatError
- end
+ glob = if File::ALT_SEPARATOR then
+ gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
+ else
+ gem_name
+ end
+
+ local_gems = Dir["#{glob}*"].sort.reverse
+
+ local_gems.each do |gem_file|
+ next unless gem_file =~ /gem$/
+ begin
+ spec = Gem::Format.from_file_by_path(gem_file).spec
+ spec_and_source = [spec, gem_file]
+ break
+ rescue SystemCallError, Gem::Package::FormatError
end
end
unless spec_and_source then
dep = Gem::Dependency.new gem_name, version
- # HACK Dependency objects should be immutable
dep.prerelease = true if prerelease
-
spec_and_sources = find_gems_with_sources(dep).reverse
spec_and_source = spec_and_sources.find { |spec, source|
Gem::Platform.match spec.platform
@@ -291,7 +237,6 @@ def find_spec_by_name_and_version(gem_name,
gem_name, version, @errors)
end
- # REFACTOR just return spec_and_source
@specs_and_sources = [spec_and_source]
end
@@ -311,7 +256,6 @@ def find_spec_by_name_and_version(gem_name,
def install dep_or_name, version = Gem::Requirement.default
if String === dep_or_name then
- # REFACTOR use return value to set @specs_and_source
find_spec_by_name_and_version dep_or_name, version, @prerelease
else
dep_or_name.prerelease = @prerelease
@@ -322,12 +266,8 @@ def install dep_or_name, version = Gem::Requirement.default
gather_dependencies
- # REFACTOR is the last gem always the one that the user requested?
- # This code assumes that but is that actually validated by the code?
-
last = @gems_to_install.size - 1
@gems_to_install.each_with_index do |spec, index|
- # REFACTOR more current spec set hardcoding, should be abstracted?
next if Gem::Specification.include?(spec) and index != last
# TODO: make this sorta_verbose so other users can benefit from it
@@ -335,27 +275,16 @@ def install dep_or_name, version = Gem::Requirement.default
_, source_uri = @specs_and_sources.assoc spec
begin
- # REFACTOR make the fetcher to use configurable
- local_gem_path = Gem::RemoteFetcher.fetcher.download(spec, source_uri,
- @cache_dir)
+ local_gem_path = Gem::RemoteFetcher.fetcher.download spec, source_uri,
+ @cache_dir
rescue Gem::RemoteFetcher::FetchError
- # TODO I doubt all fetch errors are recoverable, we should at least
- # report the errors probably.
next if @force
raise
end
- if @development
- if @dev_shallow
- is_dev = @toplevel_specs.include? spec.full_name
- else
- is_dev = true
- end
- end
-
inst = Gem::Installer.new local_gem_path,
:bin_dir => @bin_dir,
- :development => is_dev,
+ :development => @development,
:env_shebang => @env_shebang,
:force => @force,
:format_executable => @format_executable,
@@ -370,10 +299,6 @@ def install dep_or_name, version = Gem::Requirement.default
@installed_gems << spec
end
- Gem.done_installing_hooks.each do |hook|
- hook.call self, @installed_gems
- end
-
@installed_gems
end
end
View
12 lib/ruby/shared/rubygems/dependency_list.rb
@@ -10,10 +10,6 @@
##
# Gem::DependencyList is used for installing and uninstalling gems in the
# correct order to avoid conflicts.
-#--
-# TODO: It appears that all but topo-sort functionality is being duplicated
-# (or is planned to be duplicated) elsewhere in rubygems. Is the majority of
-# this class necessary anymore? Especially #ok?, #why_not_ok?
class Gem::DependencyList
attr_reader :specs
@@ -37,8 +33,6 @@ def self.from_specs
##
# Creates a DependencyList from a Gem::SourceIndex +source_index+
- #--
- # TODO: delete per deprecation at bottom of file
def self.from_source_index(ignored=nil)
warn "NOTE: DependencyList.from_source_index ignores it's arg" if ignored
@@ -219,7 +213,7 @@ def tsort_each_node(&block)
@specs.each(&block)
end
- def tsort_each_child(node)
+ def tsort_each_child(node, &block)
specs = @specs.sort.reverse
dependencies = node.runtime_dependencies
@@ -248,11 +242,11 @@ def tsort_each_child(node)
def active_count(specs, ignored)
specs.count { |spec| ignored[spec.full_name].nil? }
end
+end
+class Gem::DependencyList
class << self
extend Gem::Deprecate
deprecate :from_source_index, "from_specs", 2011, 11
end
-
end
-
View
80 lib/ruby/shared/rubygems/deprecate.rb
@@ -20,51 +20,51 @@
# end
# end
-module Gem::Deprecate
+module Gem
+ module Deprecate
- def self.skip # :nodoc:
- @skip ||= false
- end
+ def self.skip # :nodoc:
+ @skip ||= false
+ end
- def self.skip= v # :nodoc:
- @skip = v
- end
+ def self.skip= v # :nodoc:
+ @skip = v
+ end
- ##
- # Temporarily turn off warnings. Intended for tests only.
+ ##
+ # Temporarily turn off warnings. Intended for tests only.
- def skip_during
- Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
- yield
- ensure
- Gem::Deprecate.skip = original
- end
+ def skip_during
+ Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
+ yield
+ ensure
+ Gem::Deprecate.skip = original
+ end
- ##
- # Simple deprecation method that deprecates +name+ by wrapping it up
- # in a dummy method. It warns on each call to the dummy method
- # telling the user of +repl+ (unless +repl+ is :none) and the
- # year/month that it is planned to go away.
+ ##
+ # Simple deprecation method that deprecates +name+ by wrapping it up
+ # in a dummy method. It warns on each call to the dummy method
+ # telling the user of +repl+ (unless +repl+ is :none) and the
+ # year/month that it is planned to go away.
- def deprecate name, repl, year, month
- class_eval {
- old = "_deprecated_#{name}"
- alias_method old, name
- define_method name do |*args, &block| # TODO: really works on 1.8.7?
- klass = self.kind_of? Module
- target = klass ? "#{self}." : "#{self.class}#"
- msg = [ "NOTE: #{target}#{name} is deprecated",
- repl == :none ? " with no replacement" : "; use #{repl} instead",
- ". It will be removed on or after %4d-%02d-01." % [year, month],
- "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
- ]
- warn "#{msg.join}." unless Gem::Deprecate.skip
- send old, *args, &block
- end
- }
- end
-
- module_function :deprecate, :skip_during
+ def deprecate name, repl, year, month
+ class_eval {
+ old = "_deprecated_#{name}"
+ alias_method old, name
+ define_method name do |*args, &block| # TODO: really works on 1.8.7?
+ klass = self.kind_of? Module
+ target = klass ? "#{self}." : "#{self.class}#"
+ msg = [ "NOTE: #{target}#{name} is deprecated",
+ repl == :none ? " with no replacement" : ", use #{repl}",
+ ". It will be removed on or after %4d-%02d-01." % [year, month],
+ "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
+ ]