Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Gem::DocManager is no longer used by RubyGems. Gem::RDoc is now used.

- Gem::FilePermissionError now has an a #directory accessor.

The "Successfully installed foo-1.0" message is now printed by a post_install hook.
  • Loading branch information...
commit bfafdb46e31503eff2046978e75bee91d969d042 1 parent 1146b29
@drbrain drbrain authored
View
5 Manifest.txt
@@ -68,6 +68,7 @@ lib/rubygems/gem_path_searcher.rb
lib/rubygems/gem_runner.rb
lib/rubygems/gemcutter_utilities.rb
lib/rubygems/indexer.rb
+lib/rubygems/install_message.rb
lib/rubygems/install_update_options.rb
lib/rubygems/installer.rb
lib/rubygems/installer_test_case.rb
@@ -86,6 +87,7 @@ lib/rubygems/package/tar_writer.rb
lib/rubygems/package_task.rb
lib/rubygems/path_support.rb
lib/rubygems/platform.rb
+lib/rubygems/rdoc.rb
lib/rubygems/remote_fetcher.rb
lib/rubygems/require_paths_builder.rb
lib/rubygems/requirement.rb
@@ -104,12 +106,14 @@ lib/rubygems/version.rb
lib/rubygems/version_option.rb
lib/ubygems.rb
setup.rb
+test/rubygems/bad_rake.rb
test/rubygems/bogussources.rb
test/rubygems/data/gem-private_key.pem
test/rubygems/data/gem-public_cert.pem
test/rubygems/fake_certlib/openssl.rb
test/rubygems/fix_openssl_warnings.rb
test/rubygems/foo/discover.rb
+test/rubygems/good_rake.rb
test/rubygems/insure_session.rb
test/rubygems/plugin/exception/rubygems_plugin.rb
test/rubygems/plugin/load/rubygems_plugin.rb
@@ -176,6 +180,7 @@ test/rubygems/test_gem_package_tar_writer.rb
test/rubygems/test_gem_package_task.rb
test/rubygems/test_gem_path_support.rb
test/rubygems/test_gem_platform.rb
+test/rubygems/test_gem_rdoc.rb
test/rubygems/test_gem_remote_fetcher.rb
test/rubygems/test_gem_requirement.rb
test/rubygems/test_gem_security.rb
View
5 diff
@@ -0,0 +1,5 @@
+- Gem::DocManager is no longer used by RubyGems. Gem::RDoc is now used.
+
+- Gem::FilePermissionError now has an a #directory accessor.
+
+The "Successfully installed foo-1.0" message is now printed by a post_install hook.
View
21 lib/rubygems/commands/install_command.rb
@@ -1,10 +1,11 @@
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
@@ -13,6 +14,8 @@
class Gem::Commands::InstallCommand < Gem::Command
+ attr_reader :installed_specs # :nodoc:
+
include Gem::VersionOption
include Gem::LocalRemoteOptions
include Gem::InstallUpdateOptions
@@ -30,6 +33,8 @@ 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:
@@ -104,7 +109,7 @@ def execute
alert "use --ignore-dependencies to install only the gems you list"
end
- installed_gems = []
+ @installed_specs = []
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
@@ -123,11 +128,7 @@ def execute
inst = Gem::DependencyInstaller.new options
inst.install gem_name, options[:version]
- inst.installed_gems.each do |spec|
- say "Successfully installed #{spec.full_name}"
- end
-
- installed_gems.push(*inst.installed_gems)
+ @installed_specs.push(*inst.installed_gems)
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
@@ -138,9 +139,9 @@ def execute
end
end
- unless installed_gems.empty? then
- gems = installed_gems.length == 1 ? 'gem' : 'gems'
- say "#{installed_gems.length} #{gems} installed"
+ unless @installed_specs.empty? then
+ gems = @installed_specs.length == 1 ? 'gem' : 'gems'
+ say "#{@installed_specs.length} #{gems} installed"
end
raise Gem::SystemExitException, exit_code
View
43 lib/rubygems/commands/rdoc_command.rb
@@ -1,6 +1,6 @@
require 'rubygems/command'
require 'rubygems/version_option'
-require 'rubygems/doc_manager'
+require 'rubygems/rdoc'
class Gem::Commands::RdocCommand < Gem::Command
include Gem::VersionOption
@@ -54,37 +54,26 @@ def usage # :nodoc:
end
def execute
- 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
+ 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
end
- if specs.empty?
- raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
- end
-
- if options[:include_ri]
- specs.sort.each do |spec|
- doc = Gem::DocManager.new(spec)
- doc.generate_ri if options[:overwrite] || !doc.ri_installed?
- end
+ specs.each do |spec|
+ doc = Gem::RDoc.new spec, options[:include_rdoc], options[:include_ri]
- Gem::DocManager.update_ri_cache
- end
+ doc.force = options[:overwrite]
- if options[:include_rdoc]
- specs.sort.each do |spec|
- doc = Gem::DocManager.new(spec)
- doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
- end
+ doc.generate
end
-
- true
end
end
View
5 lib/rubygems/commands/update_command.rb
@@ -1,10 +1,12 @@
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/commands/install_command'
+require 'rubygems/install_message' # must come before rdoc for messaging
+require 'rubygems/rdoc'
class Gem::Commands::UpdateCommand < Gem::Command
@@ -96,7 +98,6 @@ 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
View
3  lib/rubygems/dependency_installer.rb
@@ -15,8 +15,7 @@ class Gem::DependencyInstaller
attr_reader :installed_gems
##
- # Arguments for use by RDoc. Used to generate documentation by
- # Gem::DocManager
+ # Arguments for use by RDoc to generate documentation
attr_reader :rdoc_args
View
11 lib/rubygems/doc_manager.rb
@@ -7,9 +7,14 @@
require 'rubygems'
##
-# The documentation manager generates RDoc and RI for RubyGems.
+# The documentation manager formerly generated RDoc and RI for RubyGems.
+#
+# This file is no longer used, see rubygems/rdoc.rb for details of modern
+# usage.
+#
+# Require 'rubygems/rdoc' and use Gem::RDoc now.
-class Gem::DocManager
+class Gem::DocManager # :nodoc: all
include Gem::UserInteraction
@@ -268,5 +273,3 @@ def uninstall_doc
end
-Gem.post_installs(&Gem::DocManager.method(:generation_hook))
-
View
13 lib/rubygems/exceptions.rb
@@ -26,11 +26,18 @@ class Gem::EndOfYAMLException < Gem::Exception; end
##
# Signals that a file permission error is preventing the user from
-# installing in the requested directories.
+# operating on the given directory.
+
class Gem::FilePermissionError < Gem::Exception
- def initialize(path)
- super("You don't have write permissions into the #{path} directory.")
+
+ attr_reader :directory
+
+ def initialize directory
+ @directory = directory
+
+ super "You don't have write permissions for the #{directory} directory."
end
+
end
##
View
5 lib/rubygems/gem_runner.rb
@@ -4,10 +4,9 @@
# See LICENSE.txt for permissions.
#++
-require "rubygems"
+require 'rubygems'
require 'rubygems/command_manager'
require 'rubygems/config_file'
-require 'rubygems/doc_manager'
##
# Load additional plugins from $LOAD_PATH
@@ -29,7 +28,6 @@ def initialize(options={})
# TODO: nuke these options
@command_manager_class = options[:command_manager] || Gem::CommandManager
@config_file_class = options[:config_file] || Gem::ConfigFile
- @doc_manager_class = options[:doc_manager] || Gem::DocManager
end
##
@@ -78,7 +76,6 @@ def do_configuration(args)
Gem.configuration = @config_file_class.new(args)
Gem.use_paths Gem.configuration[:gemhome], Gem.configuration[:gempath]
Gem::Command.extra_args = Gem.configuration[:gem]
- @doc_manager_class.configured_args = Gem.configuration[:rdoc]
end
end
View
8 lib/rubygems/install_message.rb
@@ -0,0 +1,8 @@
+require 'rubygems'
+require 'rubygems/user_interaction'
+
+Gem.post_install do |installer|
+ ui = Gem::DefaultUserInteraction.ui
+ ui.say "Successfully installed #{installer.spec.full_name}"
+end
+
View
310 lib/rubygems/rdoc.rb
@@ -0,0 +1,310 @@
+require 'rubygems'
+require 'rubygems/user_interaction'
+require 'fileutils'
+
+begin
+ gem 'rdoc'
+rescue Gem::LoadError
+end
+
+loaded_hook = false
+
+begin
+ require 'rdoc/rubygems_hook'
+ loaded_hook = true
+rescue LoadError
+end
+
+##
+# Gem::RDoc provides methods to generate RDoc and ri data for installed gems.
+# It works for RDoc 1.0.1 (in Ruby 1.8) up to RDoc 3.6.
+#
+# This implementation is considered obsolete. The RDoc project is the
+# appropriate location to find this functionality. This file provides the
+# hooks to load RDoc generation code from the "rdoc" gem and a fallback in
+# case the installed version of RDoc does not have them.
+
+class Gem::RDoc
+
+ include Gem::UserInteraction
+
+ @rdoc_version = nil
+ @specs = []
+
+ ##
+ # Documentation dir for this specification
+
+ attr_reader :doc_dir
+
+ ##
+ # Force installation of documentation?
+
+ attr_accessor :force
+
+ ##
+ # Generate rdoc?
+
+ attr_accessor :generate_rdoc
+
+ ##
+ # Generate ri data?
+
+ attr_accessor :generate_ri
+
+ attr_reader :rdoc_dir
+ attr_reader :ri_dir
+
+ ##
+ # Specification to be documented
+
+ attr_reader :spec
+
+ class << self
+
+ ##
+ # Loaded version of RDoc. Set by ::load_rdoc
+
+ attr_reader :rdoc_version
+
+ end
+
+ ##
+ # Post installs hook that generates documentation for each specification in
+ # +specs+
+
+ def self.generation_hook installer, specs
+ rdoc_args = installer.rdoc_args
+ types = installer.document
+
+ generate_rdoc = types.include? 'rdoc'
+ generate_ri = types.include? 'ri'
+
+ specs.each do |spec|
+ new(spec, generate_rdoc, generate_ri).generate
+ end
+ end
+
+ ##
+ # Loads the RDoc generator
+
+ def self.load_rdoc
+ return if @rdoc_version
+
+ begin
+ require 'rdoc/rdoc'
+
+ @rdoc_version = if ::RDoc.const_defined? :VERSION then
+ Gem::Version.new ::RDoc::VERSION
+ else
+ Gem::Version.new '1.0.1'
+ end
+
+ rescue LoadError => e
+ raise Gem::DocumentError, "RDoc is not installed: #{e}"
+ end
+ end
+
+ ##
+ # Creates a new documentation generator for +spec+. RDoc and ri data
+ # generation can be disabled through +generate_rdoc+ and +generate_ri+
+ # respectively.
+
+ def initialize spec, generate_rdoc = true, generate_ri = true
+ @doc_dir = spec.doc_dir
+ @file_info = nil
+ @force = false
+ @rdoc = nil
+ @spec = spec
+
+ @generate_ri = generate_ri
+ @generate_rdoc = generate_rdoc
+
+ @ri_dir = File.join @doc_dir, 'ri' # TODO Gem::Specification#doc_dir 'ri'
+ @rdoc_dir = File.join @doc_dir, 'rdoc'
+ end
+
+ ##
+ # Removes legacy rdoc arguments from +args+
+
+ def delete_legacy_args args
+ args.delete '--inline-source'
+ args.delete '--promiscuous'
+ args.delete '-p'
+ args.delete '--one-file'
+ end
+
+ ##
+ # Generates documentation using the named +generator+ ("darkfish" or "ri")
+ # and following the given +options+.
+ #
+ # Documentation will be generated into +destination+
+
+ def document generator, options, destination
+ options = options.dup
+ options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
+ options.setup_generator generator
+ options.op_dir = destination
+ options.finish
+
+ @rdoc.options = options
+ @rdoc.generator = options.generator.new options
+
+ say "Installing #{generator} documentation for #{@spec.full_name}"
+
+ FileUtils.mkdir_p options.op_dir
+
+ Dir.chdir options.op_dir do
+ begin
+ @rdoc.class.current = @rdoc
+ @rdoc.generator.generate @file_info
+ ensure
+ @rdoc.class.current = nil
+ end
+ end
+ end
+
+ ##
+ # Generates RDoc and ri data
+
+ def generate
+ return unless @generate_ri or @generate_rdoc
+
+ setup
+
+ if Gem::Requirement.new('< 3').satisfied_by? self.class.rdoc_version then
+ generate_legacy
+ else
+ ::RDoc::TopLevel.reset # TODO ::RDoc::RDoc.reset
+ ::RDoc::Parser::C.reset
+
+ options = ::RDoc::Options.new
+ options.default_title = "#{@spec.full_name} Documentation"
+ options.files = []
+ options.files.push(*@spec.require_paths)
+ options.files.push(*@spec.extra_rdoc_files)
+
+ args = @spec.rdoc_options
+ delete_legacy_args args
+ # TODO Gem.configuration[:rdoc]
+ options.parse args
+ options.quiet = !Gem.configuration.really_verbose
+
+ @rdoc = new_rdoc
+ @rdoc.options = options
+
+ Dir.chdir @spec.full_gem_path do
+ @file_info = @rdoc.parse_files options.files
+ end
+
+ document 'ri', options, @ri_dir if
+ @generate_ri and (@force or not File.exist? @ri_dir)
+
+ document 'darkfish', options, @rdoc_dir if
+ @generate_rdoc and (@force or not File.exist? @rdoc_dir)
+ end
+ end
+
+ ##
+ # Generates RDoc and ri data for legacy RDoc versions
+
+ def generate_legacy
+ if @generate_rdoc then
+ FileUtils.rm_rf @rdoc_dir
+ say "Installing RDoc documentation for #{@spec.full_name}"
+ legacy_rdoc '--op', @rdoc_dir
+ end
+
+ if @generate_ri then
+ FileUtils.rm_rf @ri_dir
+ say "Installing ri documentation for #{@spec.full_name}"
+ legacy_rdoc '--ri', '--op', @ri_dir
+ end
+ end
+
+ ##
+ # Generates RDoc using a legacy version of RDoc from the ARGV-like +args+
+
+ def legacy_rdoc *args
+ args << @spec.rdoc_options
+ args << '--quiet'
+ args << @spec.require_paths.clone
+ args << @spec.extra_rdoc_files
+ args << '--title' << "#{@spec.full_name} Documentation"
+ args = args.flatten.map do |arg| arg.to_s end
+
+ delete_legacy_args args if
+ Gem::Requirement.new('>= 2.4.0') =~ self.class.rdoc_version
+
+ r = new_rdoc
+ say "rdoc #{args.join ' '}" if Gem.configuration.really_verbose
+
+ Dir.chdir @spec.full_gem_path do
+ begin
+ r.document args
+ rescue Errno::EACCES => e
+ dirname = File.dirname e.message.split("-")[1].strip
+ raise Gem::FilePermissionError, dirname
+ rescue Interrupt => e
+ raise e
+ rescue Exception => ex
+ alert_error "While generating documentation for #{@spec.full_name}"
+ ui.errs.puts "... MESSAGE: #{ex}"
+ ui.errs.puts "... RDOC args: #{args.join(' ')}"
+ ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
+ Gem.configuration.backtrace
+ ui.errs.puts "(continuing with the rest of the installation)"
+ ensure
+ end
+ end
+ end
+
+ ##
+ # #new_rdoc creates a new RDoc instance. This method is provided only to
+ # make testing easier.
+
+ def new_rdoc # :nodoc:
+ ::RDoc::RDoc.new
+ end
+
+ ##
+ # Is rdoc documentation installed?
+
+ def rdoc_installed?
+ File.exist? @rdoc_dir
+ end
+
+ ##
+ # Removes generated RDoc and ri data
+
+ def remove
+ base_dir = @spec.base_dir
+
+ raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
+
+ FileUtils.rm_rf @doc_dir
+ FileUtils.rm_rf @ri_dir
+ end
+
+ ##
+ # Is ri data installed?
+
+ def ri_installed?
+ File.exist? @ri_dir
+ end
+
+ ##
+ # Prepares the spec for documentation generation
+
+ def setup
+ self.class.load_rdoc
+
+ raise Gem::FilePermissionError, @doc_dir if
+ File.exist?(@doc_dir) and not File.writable?(@doc_dir)
+
+ FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
+ end
+
+end unless loaded_hook
+
+Gem.post_installs(&Gem::RDoc.method(:generation_hook)) unless loaded_hook
+
View
4 lib/rubygems/server.rb
@@ -3,7 +3,7 @@
require 'erb'
require 'rubygems'
-require 'rubygems/doc_manager'
+require 'rubygems/rdoc'
##
# Gem::Server and allows users to serve gems for consumption by
@@ -621,7 +621,7 @@ def root(req, res)
"has_deps" => !deps.empty?,
"homepage" => spec.homepage,
"name" => spec.name,
- "rdoc_installed" => Gem::DocManager.new(spec).rdoc_installed?,
+ "rdoc_installed" => Gem::RDoc.new(spec).rdoc_installed?,
"summary" => spec.summary,
"version" => spec.version.to_s,
}
View
4 lib/rubygems/uninstaller.rb
@@ -7,7 +7,7 @@
require 'fileutils'
require 'rubygems'
require 'rubygems/dependency_list'
-require 'rubygems/doc_manager'
+require 'rubygems/rdoc'
require 'rubygems/user_interaction'
##
@@ -220,7 +220,7 @@ def remove(spec)
FileUtils.rm_rf gem
- Gem::DocManager.new(spec).uninstall_doc
+ Gem::RDoc.new(spec).remove
say "Successfully uninstalled #{spec.full_name}"
View
35 test/rubygems/test_gem_commands_install_command.rb
@@ -1,12 +1,6 @@
require 'rubygems/test_case'
require 'rubygems/commands/install_command'
-begin
- gem "rdoc"
-rescue Gem::LoadError
- # ignore
-end
-
class TestGemCommandsInstallCommand < Gem::TestCase
def setup
@@ -34,8 +28,7 @@ def test_execute_exclude_prerelease
assert_equal 0, e.exit_code, @ui.error
end
- assert_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
- refute_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
end
def test_execute_explicit_version_includes_prerelease
@@ -59,8 +52,7 @@ def test_execute_explicit_version_includes_prerelease
assert_equal 0, e.exit_code, @ui.error
end
- refute_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
- assert_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
+ assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
end
def test_execute_include_dependencies
@@ -73,6 +65,8 @@ def test_execute_include_dependencies
end
end
+ assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
+
output = @ui.output.split "\n"
assert_equal "INFO: `gem install -y` is now default and will be removed",
output.shift
@@ -102,8 +96,9 @@ def test_execute_local
end
end
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
+
out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
assert_equal "1 gem installed", out.shift
assert out.empty?, out.inspect
end
@@ -235,14 +230,13 @@ def test_execute_prerelease
assert_equal 0, e.exit_code, @ui.error
end
- refute_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
- assert_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
+ assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
end
def test_execute_rdoc
util_setup_fake_fetcher
- Gem.post_installs(&Gem::DocManager.method(:generation_hook))
+ Gem.post_installs(&Gem::RDoc.method(:generation_hook))
@cmd.options[:document] = %w[rdoc ri]
@cmd.options[:domain] = :local
@@ -290,8 +284,9 @@ def test_execute_remote
assert_equal 0, e.exit_code
end
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
+
out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
assert_equal "1 gem installed", out.shift
assert out.empty?, out.inspect
end
@@ -328,8 +323,9 @@ def test_execute_remote_ignores_files
end
end
+ assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
+
out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@a1.full_name}", out.shift
assert_equal "1 gem installed", out.shift
assert out.empty?, out.inspect
@@ -361,9 +357,9 @@ def test_execute_two
end
end
+ assert_equal %w[a-2 b-2], @cmd.installed_specs.map { |spec| spec.full_name }
+
out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
assert_equal "2 gems installed", out.shift
assert out.empty?, out.inspect
end
@@ -393,9 +389,10 @@ def test_execute_conservative
end
end
+ assert_equal %w[b-2], @cmd.installed_specs.map { |spec| spec.full_name }
+
out = @ui.output.split "\n"
assert_equal "", @ui.error
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
assert_equal "1 gem installed", out.shift
assert out.empty?, out.inspect
end
View
12 test/rubygems/test_gem_commands_update_command.rb
@@ -46,7 +46,6 @@ def test_execute
out = @ui.output.split "\n"
assert_equal "Updating installed gems", out.shift
assert_equal "Updating #{@a2.name}", out.shift
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
assert_equal "Gems updated: #{@a2.name}", out.shift
assert_empty out
end
@@ -98,7 +97,6 @@ def test_execute_system
out = @ui.output.split "\n"
assert_equal "Updating rubygems-update", out.shift
- assert_equal "Successfully installed rubygems-update-9", out.shift
assert_equal "Installing RubyGems 9", out.shift
assert_equal "RubyGems system software updated", out.shift
@@ -141,7 +139,6 @@ def test_execute_system_multiple
out = @ui.output.split "\n"
assert_equal "Updating rubygems-update", out.shift
- assert_equal "Successfully installed rubygems-update-9", out.shift
assert_equal "Installing RubyGems 9", out.shift
assert_equal "RubyGems system software updated", out.shift
@@ -164,7 +161,6 @@ def test_execute_system_specific
out = @ui.output.split "\n"
assert_equal "Updating rubygems-update", out.shift
- assert_equal "Successfully installed rubygems-update-8", out.shift
assert_equal "Installing RubyGems 8", out.shift
assert_equal "RubyGems system software updated", out.shift
@@ -187,7 +183,6 @@ def test_execute_system_specifically_to_latest_version
out = @ui.output.split "\n"
assert_equal "Updating rubygems-update", out.shift
- assert_equal "Successfully installed rubygems-update-9", out.shift
assert_equal "Installing RubyGems 9", out.shift
assert_equal "RubyGems system software updated", out.shift
@@ -258,9 +253,6 @@ def test_execute_dependencies
out = @ui.output.split "\n"
assert_equal "Updating installed gems", out.shift
assert_equal "Updating #{@a2.name}", out.shift
- assert_equal "Successfully installed #{@c2.full_name}", out.shift
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
assert_equal "Gems updated: #{@c2.name}, #{@b2.name}, #{@a2.name}",
out.shift
@@ -268,7 +260,7 @@ def test_execute_dependencies
end
def test_execute_rdoc
- Gem.post_installs(&Gem::DocManager.method(:generation_hook))
+ Gem.post_installs(&Gem::RDoc.method(:generation_hook))
@cmd.options[:document] = %w[rdoc ri]
@@ -300,7 +292,6 @@ def test_execute_named
out = @ui.output.split "\n"
assert_equal "Updating installed gems", out.shift
assert_equal "Updating #{@a2.name}", out.shift
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
assert_equal "Gems updated: #{@a2.name}", out.shift
assert_empty out
@@ -339,7 +330,6 @@ def test_execute_named_up_to_date_prerelease
out = @ui.output.split "\n"
assert_equal "Updating installed gems", out.shift
assert_equal "Updating #{@a3a.name}", out.shift
- assert_equal "Successfully installed #{@a3a.full_name}", out.shift
assert_equal "Gems updated: #{@a3a.name}", out.shift
assert_empty out
View
1  test/rubygems/test_gem_gem_runner.rb
@@ -27,7 +27,6 @@ def test_do_configuration
assert_equal [other_gem_path, other_gem_home], Gem.path
assert_equal %w[--commands], Gem::Command.extra_args
- assert_equal %w[--all], Gem::DocManager.configured_args
end
def test_build_args__are_handled
View
199 test/rubygems/test_gem_rdoc.rb
@@ -0,0 +1,199 @@
+require 'rubygems/test_case'
+require 'rubygems'
+require 'rubygems/rdoc'
+
+class TestGemRDoc < Gem::TestCase
+
+ def setup
+ super
+
+ @a = quick_spec 'a'
+
+ @rdoc = Gem::RDoc.new @a
+
+ begin
+ Gem::RDoc.load_rdoc
+ rescue Gem::DocumentError => e
+ skip e.message
+ end
+ end
+
+ def rdoc_3?
+ Gem::Requirement.new('>= 3').satisfied_by? @rdoc.class.rdoc_version
+ end
+
+ def test_initialize
+ assert @rdoc.generate_rdoc
+ assert @rdoc.generate_ri
+
+ assert_equal "#{@a.doc_dir}/rdoc", @rdoc.rdoc_dir
+ assert_equal "#{@a.doc_dir}/ri", @rdoc.ri_dir
+
+ rdoc = Gem::RDoc.new @a, false, false
+
+ refute rdoc.generate_rdoc
+ refute rdoc.generate_ri
+ end
+
+ def test_delete_legacy_args
+ args = %w[
+ --inline-source
+ --one-file
+ --promiscuous
+ -p
+ ]
+
+ @rdoc.delete_legacy_args args
+
+ assert_empty args
+ end
+
+ def test_document
+ skip 'RDoc 3+ required' unless rdoc_3?
+
+ options = RDoc::Options.new
+ options.files = []
+
+ @rdoc.instance_variable_set :@rdoc, @rdoc.new_rdoc
+ @rdoc.instance_variable_set :@file_info, []
+
+ @rdoc.document 'darkfish', options, @rdoc.rdoc_dir
+
+ assert @rdoc.rdoc_installed?
+ end
+
+ def test_generate
+ skip 'RDoc 3+ required' unless rdoc_3?
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @rdoc.generate
+
+ assert @rdoc.rdoc_installed?
+ assert @rdoc.ri_installed?
+ end
+
+ def test_generate_disabled
+ @rdoc.generate_rdoc = false
+ @rdoc.generate_ri = false
+
+ @rdoc.generate
+
+ refute @rdoc.rdoc_installed?
+ refute @rdoc.ri_installed?
+ end
+
+ def test_generate_force
+ skip 'RDoc 3+ required' unless rdoc_3?
+
+ FileUtils.mkdir_p @rdoc.rdoc_dir
+ FileUtils.mkdir_p @rdoc.ri_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @rdoc.force = true
+
+ @rdoc.generate
+
+ assert_path_exists File.join(@rdoc.rdoc_dir, 'index.html')
+ assert_path_exists File.join(@rdoc.ri_dir, 'cache.ri')
+ end
+
+ def test_generate_no_overwrite
+ skip 'RDoc 3+ required' unless rdoc_3?
+
+ FileUtils.mkdir_p @rdoc.rdoc_dir
+ FileUtils.mkdir_p @rdoc.ri_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @rdoc.generate
+
+ refute_path_exists File.join(@rdoc.rdoc_dir, 'index.html')
+ refute_path_exists File.join(@rdoc.ri_dir, 'created.rid')
+ end
+
+ def test_generate_legacy
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @rdoc.generate_legacy
+
+ assert @rdoc.rdoc_installed?
+ assert @rdoc.ri_installed?
+ end
+
+ def test_legacy_rdoc
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @rdoc.legacy_rdoc '--op', @rdoc.rdoc_dir
+
+ assert @rdoc.rdoc_installed?
+ end
+
+ def test_new_rdoc
+ assert_kind_of RDoc::RDoc, @rdoc.new_rdoc
+ end
+
+ def test_rdoc_installed?
+ refute @rdoc.rdoc_installed?
+
+ FileUtils.mkdir_p @rdoc.rdoc_dir
+
+ assert @rdoc.rdoc_installed?
+ end
+
+ def test_remove
+ FileUtils.mkdir_p @rdoc.rdoc_dir
+ FileUtils.mkdir_p @rdoc.ri_dir
+
+ @rdoc.remove
+
+ refute @rdoc.rdoc_installed?
+ refute @rdoc.ri_installed?
+ end
+
+ def test_remove_unwritable
+ skip 'chmod not supported' if Gem.win_platform?
+ FileUtils.mkdir_p @a.base_dir
+ FileUtils.chmod 0, @a.base_dir
+
+ e = assert_raises Gem::FilePermissionError do
+ @rdoc.remove
+ end
+
+ assert_equal @a.base_dir, e.directory
+ ensure
+ FileUtils.chmod 0755, @a.base_dir
+ end
+
+ def test_ri_installed?
+ refute @rdoc.ri_installed?
+
+ FileUtils.mkdir_p @rdoc.ri_dir
+
+ assert @rdoc.ri_installed?
+ end
+
+ def test_setup
+ @rdoc.setup
+
+ assert_path_exists @a.doc_dir
+ end
+
+ def test_setup_unwritable
+ skip 'chmod not supported' if Gem.win_platform?
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.chmod 0, @a.doc_dir
+
+ e = assert_raises Gem::FilePermissionError do
+ @rdoc.setup
+ end
+
+ assert_equal @a.doc_dir, e.directory
+ ensure
+ FileUtils.chmod 0755, @a.doc_dir
+ end
+
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.