mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/rubygems/commands/setup_command.rb: Remove old files on install
of RubyGems. (not by rbinstall.rb). * test/rubygems/test_gem_commands_setup_command.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									3c4633a3a1
								
							
						
					
					
						commit
						42968fe65a
					
				
					 3 changed files with 78 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Fri Nov 30 13:11:53 2012  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/rubygems/commands/setup_command.rb:  Remove old files on install
 | 
			
		||||
	  of RubyGems.  (not by rbinstall.rb).
 | 
			
		||||
	* test/rubygems/test_gem_commands_setup_command.rb:  Test for above.
 | 
			
		||||
 | 
			
		||||
Fri Nov 30 12:47:59 2012  Akinori MUSHA  <knu@iDaemons.org>
 | 
			
		||||
 | 
			
		||||
	* lib/abbrev.rb (Abbrev#abbrev): A fixed string prefix pattern
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,6 +137,8 @@ By default, this RubyGems will install gem as:
 | 
			
		|||
 | 
			
		||||
    remove_old_bin_files bin_dir
 | 
			
		||||
 | 
			
		||||
    remove_old_lib_files lib_dir
 | 
			
		||||
 | 
			
		||||
    say "RubyGems #{Gem::VERSION} installed"
 | 
			
		||||
 | 
			
		||||
    uninstall_old_gemcutter
 | 
			
		||||
| 
						 | 
				
			
			@ -280,9 +282,9 @@ TEXT
 | 
			
		|||
  def install_lib(lib_dir)
 | 
			
		||||
    say "Installing RubyGems" if @verbose
 | 
			
		||||
 | 
			
		||||
    Dir.chdir 'lib' do
 | 
			
		||||
      lib_files = Dir[File.join('**', '*rb')]
 | 
			
		||||
    lib_files = rb_files_in 'lib'
 | 
			
		||||
 | 
			
		||||
    Dir.chdir 'lib' do
 | 
			
		||||
      lib_files.each do |lib_file|
 | 
			
		||||
        dest_file = File.join lib_dir, lib_file
 | 
			
		||||
        dest_dir = File.dirname dest_file
 | 
			
		||||
| 
						 | 
				
			
			@ -379,6 +381,12 @@ TEXT
 | 
			
		|||
    [lib_dir, bin_dir]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def rb_files_in dir
 | 
			
		||||
    Dir.chdir dir do
 | 
			
		||||
      Dir[File.join('**', '*rb')]
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def remove_old_bin_files(bin_dir)
 | 
			
		||||
    old_bin_files = {
 | 
			
		||||
      'gem_mirror' => 'gem mirror',
 | 
			
		||||
| 
						 | 
				
			
			@ -411,6 +419,23 @@ abort "#{deprecation_message}"
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def remove_old_lib_files lib_dir
 | 
			
		||||
    lib_files = rb_files_in 'lib'
 | 
			
		||||
 | 
			
		||||
    old_lib_files = rb_files_in lib_dir
 | 
			
		||||
 | 
			
		||||
    to_remove = old_lib_files - lib_files
 | 
			
		||||
 | 
			
		||||
    Dir.chdir lib_dir do
 | 
			
		||||
      to_remove.each do |file|
 | 
			
		||||
        FileUtils.rm_f file
 | 
			
		||||
 | 
			
		||||
        warn "unable to remove old file #{file} please remove it by hand" if
 | 
			
		||||
          File.exist? file
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def uninstall_old_gemcutter
 | 
			
		||||
    require 'rubygems/uninstaller'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										45
									
								
								test/rubygems/test_gem_commands_setup_command.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								test/rubygems/test_gem_commands_setup_command.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
require 'rubygems/test_case'
 | 
			
		||||
require 'rubygems/commands/setup_command'
 | 
			
		||||
 | 
			
		||||
class TestGemCommandsSetupCommand < Gem::TestCase
 | 
			
		||||
 | 
			
		||||
  def setup
 | 
			
		||||
    super
 | 
			
		||||
 | 
			
		||||
    @install_dir = File.join @tempdir, 'install'
 | 
			
		||||
    @cmd = Gem::Commands::SetupCommand.new
 | 
			
		||||
    @cmd.options[:prefix] = @install_dir
 | 
			
		||||
 | 
			
		||||
    FileUtils.mkdir_p 'bin'
 | 
			
		||||
    FileUtils.mkdir_p 'lib/rubygems'
 | 
			
		||||
 | 
			
		||||
    open 'bin/gem',                   'w' do |io| io.puts '# gem'          end
 | 
			
		||||
    open 'lib/rubygems.rb',           'w' do |io| io.puts '# rubygems.rb'  end
 | 
			
		||||
    open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_rb_files_in
 | 
			
		||||
    assert_equal %w[rubygems.rb rubygems/test_case.rb],
 | 
			
		||||
                 @cmd.rb_files_in('lib').sort
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_remove_old_lib_files
 | 
			
		||||
    lib            = File.join @install_dir, 'lib'
 | 
			
		||||
    lib_rubygems   = File.join lib, 'rubygems'
 | 
			
		||||
 | 
			
		||||
    old_builder_rb = File.join lib_rubygems, 'builder.rb'
 | 
			
		||||
    old_format_rb  = File.join lib_rubygems, 'format.rb'
 | 
			
		||||
 | 
			
		||||
    FileUtils.mkdir_p lib_rubygems
 | 
			
		||||
 | 
			
		||||
    open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
 | 
			
		||||
    open old_format_rb,  'w' do |io| io.puts '# format.rb'  end
 | 
			
		||||
 | 
			
		||||
    @cmd.remove_old_lib_files lib
 | 
			
		||||
 | 
			
		||||
    refute_path_exists old_builder_rb
 | 
			
		||||
    refute_path_exists old_format_rb
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue