diff options
26 files changed, 165 insertions, 85 deletions
@@ -1,3 +1,8 @@ Sun Feb 10 15:07:23 2008 Nobuyoshi Nakada <[email protected]> * {bcc32,win32,wince}/Makefile.sub (MISSING): added cbrt.obj. @@ -8,7 +8,7 @@ require 'rubygems' require 'rubygems/gem_runner' -required_version = Gem::Requirement.new ">= 1.8.2" unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}" @@ -166,7 +166,13 @@ module Gem require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib")) end end - # gem directories must come after -I and ENV['RUBYLIB'] $:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths end @@ -290,6 +290,24 @@ module Gem @ruby end # Activate a gem (i.e. add it to the Ruby load path). The gem # must satisfy all the specified version constraints. If # +autorequire+ is true, then automatically require the specified @@ -345,11 +363,13 @@ module Gem end sitelibdir = ConfigMap[:sitelibdir] - sitelibdir_index = $LOAD_PATH.index sitelibdir - if sitelibdir_index then # gem directories must come after -I and ENV['RUBYLIB'] - $LOAD_PATH.insert(sitelibdir_index, *require_paths) else # we are probably testing in core, -I and RUBYLIB don't apply $LOAD_PATH.unshift(*require_paths) @@ -136,7 +136,7 @@ module Gem execute end end - # Call the given block when invoked. # # Normal command invocations just executes the +execute+ method of @@ -146,7 +146,7 @@ module Gem def when_invoked(&block) @when_invoked = block end - # Add a command-line option and handler to the command. # # See OptionParser#make_switch for an explanation of +opts+. @@ -165,7 +165,7 @@ module Gem option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } } end end - # Merge a set of command options with the set of default options # (without modifying the default option hash). def merge_options(new_options) @@ -191,7 +191,7 @@ module Gem parser.parse!(args) @options[:args] = args end - def add_extra_args(args) result = [] s_extra = Command.specific_extra_args(@command) @@ -291,7 +291,7 @@ module Gem def common_options @common_options ||= [] end - def add_common_option(*args, &handler) Gem::Command.common_options << [args, handler] end @@ -315,7 +315,7 @@ module Gem def specific_extra_args(cmd) specific_extra_args_hash[cmd] end - # Add a list of extra arguments for the given command. +args+ # may be an array or a string to be split on white space. def add_specific_extra_args(cmd,args) @@ -334,7 +334,7 @@ module Gem # ---------------------------------------------------------------- # Add the options common to all commands. - add_common_option('-h', '--help', 'Get help on this command') do |value, options| options[:help] = true @@ -358,11 +358,11 @@ module Gem # commands. Both options are actually handled before the other # options get parsed. - add_common_option('--config-file FILE', "Use this config file instead of default") do end - add_common_option('--backtrace', 'Show stack backtrace on errors') do end @@ -58,7 +58,11 @@ class Gem::Commands::EnvironmentCommand < Gem::Command end out << " - GEM PATHS:\n" - Gem.path.each do |p| out << " - #{p}\n" end @@ -18,18 +18,23 @@ module Gem options[:all] = value end - add_option('-i', '--[no-]ignore-dependencies', - 'Ignore dependency requirements while', - 'uninstalling') do |value, options| options[:ignore] = value end - add_option('-x', '--[no-]executables', 'Uninstall applicable executables without', 'confirmation') do |value, options| options[:executables] = value end add_version_option add_platform_option end @@ -39,7 +44,8 @@ module Gem end def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --no-force" end def usage # :nodoc: @@ -11,8 +11,12 @@ class Gem::DependencyError < Gem::Exception; end class Gem::DependencyRemovalException < Gem::Exception; end class Gem::DocumentError < Gem::Exception; end - ## # Potentially raised when a specification is validated. class Gem::EndOfYAMLException < Gem::Exception; end @@ -37,7 +37,7 @@ module Gem::InstallUpdateOptions options[:generate_ri] = value end - add_option(:"Install/Update", '-E', '--env-shebang', "Rewrite the shebang line on installed", "scripts to use /usr/bin/env") do |value, options| options[:env_shebang] = value @@ -63,6 +63,7 @@ class Gem::Installer :force => false, :install_dir => Gem.dir, :exec_format => false, }.merge options @env_shebang = options[:env_shebang] @@ -614,14 +614,16 @@ module Gem::Package # this method would use the String IO approach on all platforms at all # times. And that's the way it is. def zipped_stream(entry) - # This is Jamis Buck's ZLib workaround. The original code is - # commented out while we evaluate this . - entry.read(10) # skip the gzip header - zis = Zlib::Inflate.new(-Zlib::MAX_WBITS) - is = StringIO.new(zis.inflate(entry.read)) - # zis = Zlib::GzipReader.new entry - # dis = zis.read - # is = StringIO.new(dis) ensure zis.finish if zis end @@ -46,7 +46,7 @@ module Gem if deprecated.empty? from_gems_in(*installed_spec_directories) else - from_gems_in(*deprecated) end end @@ -118,6 +118,7 @@ module Gem def load_gems_in(*spec_dirs) @gems.clear specs = Dir.glob File.join("{#{spec_dirs.join(',')}}", "*.gemspec") specs.each do |file_name| gemspec = self.class.load_specification(file_name.untaint) add_spec(gemspec) if gemspec @@ -457,7 +457,7 @@ module Gem overwrite_accessor :default_executable do begin - if defined? @default_executable and @default_executable result = @default_executable elsif @executables and @executables.size == 1 result = Array(@executables).first @@ -471,14 +471,12 @@ module Gem end def add_bindir(executables) - if not defined? @executables || @executables.nil? - return nil - end - if defined? @bindir and @bindir then - Array(@executables).map {|e| File.join(@bindir, e) } else - @executables end rescue return nil @@ -511,7 +509,7 @@ module Gem @test_files = [@test_suite_file].flatten @test_suite_file = nil end - if defined? @test_files and @test_files then @test_files else @test_files = [] @@ -903,7 +901,7 @@ module Gem # Also, the summary and description are converted to a normal # format. def normalize - if defined? @extra_rdoc_files and @extra_rdoc_files then @extra_rdoc_files.uniq! @files ||= [] @files.concat(@extra_rdoc_files) @@ -25,6 +25,8 @@ class Gem::Uninstaller def initialize(gem, options) @gem = gem @version = options[:version] || Gem::Requirement.default @force_executables = options[:executables] @force_all = options[:all] @force_ignore = options[:ignore] @@ -71,31 +73,38 @@ class Gem::Uninstaller # def remove_executables(gemspec) return if gemspec.nil? - if(gemspec.executables.size > 0) - raise Gem::FilePermissionError.new(Gem.bindir) unless - File.writable?(Gem.bindir) list = Gem.source_index.search(gemspec.name).delete_if { |spec| spec.version == gemspec.version } executables = gemspec.executables.clone list.each do |spec| spec.executables.each do |exe_name| executables.delete(exe_name) end end return if executables.size == 0 answer = @force_executables || ask_yes_no( - "Remove executables and scripts for\n" + - "'#{gemspec.executables.join(", ")}' in addition to the gem?", true) # " # appease ruby-mode - don't ask - unless answer say "Executables and scripts will remain installed." - return else gemspec.executables.each do |exe_name| say "Removing #{exe_name}" - File.unlink File.join(Gem.bindir, exe_name) rescue nil - File.unlink File.join(Gem.bindir, exe_name + ".bat") rescue nil end end end @@ -119,11 +128,18 @@ class Gem::Uninstaller # uninstalled a gem, it is removed from that list. # def remove(spec, list) - unless ok_to_remove? spec then raise Gem::DependencyRemovalException, "Uninstallation aborted due to dependent gem(s)" end raise Gem::FilePermissionError, spec.installation_path unless File.writable?(spec.installation_path) @@ -157,7 +173,13 @@ class Gem::Uninstaller list.delete spec end - def ok_to_remove?(spec) return true if @force_ignore srcindex = Gem::SourceIndex.from_installed_gems @@ -75,7 +75,7 @@ module Gem ui.#{methname}(*args) end } - end end #################################################################### @@ -1,4 +1,3 @@ -require 'test/unit' require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require 'rubygems' require 'rubygems/gem_openssl' @@ -75,6 +74,8 @@ class TestGem < RubyGemTestCase install_gem foo end gem 'foo' expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo' @@ -280,9 +281,7 @@ class TestGem < RubyGemTestCase def test_self_prefix file_name = File.expand_path __FILE__ - expected = File.dirname File.dirname(file_name) - expected = File.dirname expected if expected =~ %r|/test| # for Ruby trunk - assert_equal expected, Gem.prefix end def test_self_required_location @@ -3,6 +3,10 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require 'rubygems/commands/cert_command' class TestGemCommandsCertCommand < RubyGemTestCase def setup @@ -118,5 +122,5 @@ class TestGemCommandsCertCommand < RubyGemTestCase # HACK this test sucks end -end @@ -25,7 +25,8 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output assert_match %r|- #{Gem::Platform.local}|, @ui.output assert_match %r|GEM PATHS:|, @ui.output @@ -1,5 +1,7 @@ require 'test/unit' require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require 'rubygems/commands/fetch_command' class TestGemCommandsFetchCommand < RubyGemTestCase @@ -85,7 +85,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase @cmd.execute end - assert_equal "#{foo.to_yaml}\n", @ui.output assert_equal "WARNING: Remote information is not complete\n\n", @ui.error end @@ -288,19 +288,21 @@ class TestGemDependencyInstaller < RubyGemTestCase assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name } end - def test_install_security_policy - FileUtils.mv @a1_gem, @cache_dir - FileUtils.mv @b1_gem, @cache_dir - policy = Gem::Security::HighSecurity - inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy - - e = assert_raise Gem::Exception do - inst.install - end - assert_equal 'Unsigned gem', e.message - assert_equal %w[], inst.installed_gems.map { |s| s.full_name } end def test_install_wrappers @@ -271,7 +271,7 @@ gems: fetcher.fetch_path 'uri' end - assert_match %r|\AErrno::ECONNREFUSED: .* - connect\(2\) reading uri\z|, e.message end @@ -53,10 +53,10 @@ class TestGemServer < RubyGemTestCase assert_equal 200, @res.status, @res.body assert @res['date'] assert_equal 'text/plain', @res['content-type'] - yaml = Zlib::Inflate.inflate(@res.body) - assert_match %r|Gem::Specification|, yaml - assert_match %r|name: a|, yaml - assert_match %r|version: "1"|, yaml end def test_quick_a_1_mswin32_gemspec_rz @@ -72,10 +72,11 @@ class TestGemServer < RubyGemTestCase assert_equal 200, @res.status, @res.body assert @res['date'] assert_equal 'text/plain', @res['content-type'] - yaml = Zlib::Inflate.inflate(@res.body) - assert_match %r|Gem::Specification|, yaml - assert_match %r|name: a|, yaml - assert_match %r|version: "1"|, yaml end def test_quick_common_substrings @@ -91,10 +92,10 @@ class TestGemServer < RubyGemTestCase assert_equal 200, @res.status, @res.body assert @res['date'] assert_equal 'text/plain', @res['content-type'] - yaml = Zlib::Inflate.inflate @res.body - assert_match %r|Gem::Specification|, yaml - assert_match %r|name: a$|, yaml - assert_match %r|version: "1"|, yaml end def test_quick_z_9_gemspec_rz @@ -401,7 +401,7 @@ class TestGemSourceIndex < RubyGemTestCase def test_update_with_missing marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}", "#{@gem3.full_name}.gemspec.rz" - dumped = Marshal.dump(@gem3) @fetcher.data[marshal_uri] = util_zip(dumped) use_ui @ui do @@ -185,7 +185,7 @@ class TestGemVersion < RubyGemTestCase def assert_adequate(version, requirement) ver = Gem::Version.new(version) - req = Gem::Version::Requirement.new(requirement) assert req.satisfied_by?(ver), "Version #{version} should be adequate for Requirement #{requirement}" end @@ -7,6 +7,7 @@ require 'test/unit' require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') class TestKernel < RubyGemTestCase |