diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/lib/rubygems/commands/pristine_command.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/lib/rubygems/commands/pristine_command.rb')
-rw-r--r-- | trunk/lib/rubygems/commands/pristine_command.rb | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/trunk/lib/rubygems/commands/pristine_command.rb b/trunk/lib/rubygems/commands/pristine_command.rb deleted file mode 100644 index 3e55a1bb30..0000000000 --- a/trunk/lib/rubygems/commands/pristine_command.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'fileutils' -require 'rubygems/command' -require 'rubygems/format' -require 'rubygems/installer' -require 'rubygems/version_option' - -class Gem::Commands::PristineCommand < Gem::Command - - include Gem::VersionOption - - def initialize - super 'pristine', - 'Restores installed gems to pristine condition from files located in the gem cache', - :version => Gem::Requirement.default - - add_option('--all', - 'Restore all installed gems to pristine', - 'condition') do |value, options| - options[:all] = value - end - - add_version_option('restore to', 'pristine condition') - end - - def arguments # :nodoc: - "GEMNAME gem to restore to pristine condition (unless --all)" - end - - def defaults_str # :nodoc: - "--all" - end - - def description # :nodoc: - <<-EOF -The pristine command compares the installed gems with the contents of the -cached gem and restores any files that don't match the cached gem's copy. - -If you have made modifications to your installed gems, the pristine command -will revert them. After all the gem's files have been checked all bin stubs -for the gem are regenerated. - -If the cached gem cannot be found, you will need to use `gem install` to -revert the gem. - EOF - end - - def usage # :nodoc: - "#{program_name} [args]" - end - - def execute - gem_name = nil - - specs = if options[:all] then - Gem::SourceIndex.from_installed_gems.map do |name, spec| - spec - end - else - gem_name = get_one_gem_name - Gem::SourceIndex.from_installed_gems.search(gem_name, - options[:version]) - end - - if specs.empty? then - raise Gem::Exception, - "Failed to find gem #{gem_name} #{options[:version]}" - end - - install_dir = Gem.dir # TODO use installer option - - raise Gem::FilePermissionError.new(install_dir) unless - File.writable?(install_dir) - - say "Restoring gem(s) to pristine condition..." - - specs.each do |spec| - gem = Dir[File.join(Gem.dir, 'cache', "#{spec.full_name}.gem")].first - - if gem.nil? then - alert_error "Cached gem for #{spec.full_name} not found, use `gem install` to restore" - next - end - - # TODO use installer options - installer = Gem::Installer.new gem, :wrappers => true, :force => true - installer.install - - say "Restored #{spec.full_name}" - end - end - -end - |