# File lib/rubygems/commands/pristine_command.rb, line 11 11: def initialize 12: super 'pristine', 13: 'Restores installed gems to pristine condition from files located in the gem cache', 14: :version => Gem::Requirement.default 15: 16: add_option('--all', 17: 'Restore all installed gems to pristine', 18: 'condition') do |value, options| 19: options[:all] = value 20: end 21: 22: add_version_option('restore to', 'pristine condition') 23: end
# File lib/rubygems/commands/pristine_command.rb, line 51 51: def execute 52: gem_name = nil 53: 54: specs = if options[:all] then 55: Gem::SourceIndex.from_installed_gems.map do |name, spec| 56: spec 57: end 58: else 59: gem_name = get_one_gem_name 60: Gem::SourceIndex.from_installed_gems.find_name(gem_name, 61: options[:version]) 62: end 63: 64: if specs.empty? then 65: raise Gem::Exception, 66: "Failed to find gem #{gem_name} #{options[:version]}" 67: end 68: 69: install_dir = Gem.dir # TODO use installer option 70: 71: raise Gem::FilePermissionError.new(install_dir) unless 72: File.writable?(install_dir) 73: 74: say "Restoring gem(s) to pristine condition..." 75: 76: specs.each do |spec| 77: gem = Dir[File.join(Gem.dir, 'cache', spec.file_name)].first 78: 79: if gem.nil? then 80: alert_error "Cached gem for #{spec.full_name} not found, use `gem install` to restore" 81: next 82: end 83: 84: # TODO use installer options 85: installer = Gem::Installer.new gem, :wrappers => true, :force => true 86: installer.install 87: 88: say "Restored #{spec.full_name}" 89: end 90: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.