class Gem::Doctor
清理部分失败的卸载操作或无效的 Gem::Specification。
如果一个规范被手动删除,这将删除所有剩余的文件。
如果安装了一个损坏的规范,这将通过删除错误的规范来清理警告。
Public Class Methods
Source
# File lib/rubygems/doctor.rb, line 45 def initialize(gem_repository, dry_run = false) @gem_repository = gem_repository @dry_run = dry_run @installed_specs = nil end
创建一个新的 Gem::Doctor 来清理 gem_repository。一次只能清理一个 gem 仓库。
如果 dry_run 为 true,则不会删除任何文件或目录。
Public Instance Methods
Source
# File lib/rubygems/doctor.rb, line 69 def doctor @orig_home = Gem.dir @orig_path = Gem.path say "Checking #{@gem_repository}" Gem.use_paths @gem_repository.to_s unless gem_repository? say "This directory does not appear to be a RubyGems repository, " \ "skipping" say return end doctor_children say ensure Gem.use_paths @orig_home, *@orig_path end
清理已卸载的文件和无效的 gem 规范
Source
# File lib/rubygems/doctor.rb, line 62 def gem_repository? !installed_specs.empty? end
我们正在清理 gem 仓库吗?