method

remove_old_lib_files

Importance_0
Ruby latest stable (v2_5_5) - 0 notes - Class: SetupCommand
remove_old_lib_files(lib_dir) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rubygems/commands/setup_command.rb, line 512
  def remove_old_lib_files lib_dir
    lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
    lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler' if Gem::USE_BUNDLER_FOR_GEMDEPS
    lib_dirs.each do |old_lib_dir, new_lib_dir|
      lib_files = rb_files_in(new_lib_dir)
      lib_files.concat(template_files_in(new_lib_dir)) if new_lib_dir =~ /bundler/

      old_lib_files = rb_files_in(old_lib_dir)
      old_lib_files.concat(template_files_in(old_lib_dir)) if old_lib_dir =~ /bundler/

      to_remove = old_lib_files - lib_files

      to_remove.delete_if do |file|
        file.start_with? 'defaults'
      end

      Dir.chdir old_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
  end
Register or log in to add new notes.