Class: Gem::Commands::CheckCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::CheckCommand
- Includes:
- VersionOption
- Defined in:
- lib/rubygems/commands/check_command.rb
Instance Attribute Summary
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
- #check_gems ⇒ Object
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #doctor ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ CheckCommand
constructor
A new instance of CheckCommand.
-
#usage ⇒ Object
:nodoc:.
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option, #get_platform_from_requirements
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #deprecate_option, #deprecated?, extra_args, extra_args=, #extract_gem_name_and_version, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Constructor Details
#initialize ⇒ CheckCommand
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubygems/commands/check_command.rb', line 11 def initialize super "check", "Check a gem repository for added or missing files", alien: true, doctor: false, dry_run: false, gems: true add_option("-a", "--[no-]alien", 'Report "unmanaged" or rogue files in the', "gem repository") do |value, | [:alien] = value end add_option("--[no-]doctor", "Clean up uninstalled gems and broken", "specifications") do |value, | [:doctor] = value end add_option("--[no-]dry-run", "Do not remove files, only report what", "would be removed") do |value, | [:dry_run] = value end add_option("--[no-]gems", "Check installed gems for problems") do |value, | [:gems] = value end add_version_option "check" end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
79 80 81 |
# File 'lib/rubygems/commands/check_command.rb', line 79 def arguments # :nodoc: "GEMNAME name of gem to check" end |
#check_gems ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rubygems/commands/check_command.rb', line 41 def check_gems say "Checking gems..." say gems = begin get_all_gem_names rescue StandardError [] end Gem::Validator.new.alien(gems).sort.each do |key, val| if val.empty? say "#{key} is error-free" if Gem.configuration.verbose else say "#{key} has #{val.size} problems" val.each do |error_entry| say " #{error_entry.path}:" say " #{error_entry.problem}" end end say end end |
#defaults_str ⇒ Object
:nodoc:
83 84 85 |
# File 'lib/rubygems/commands/check_command.rb', line 83 def defaults_str # :nodoc: "--gems --alien" end |
#description ⇒ Object
:nodoc:
87 88 89 90 91 92 |
# File 'lib/rubygems/commands/check_command.rb', line 87 def description # :nodoc: <<-EOF The check command can list and repair problems with installed gems and specifications and will clean up gems that have been partially uninstalled. EOF end |
#doctor ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/rubygems/commands/check_command.rb', line 64 def doctor say "Checking for files from uninstalled gems..." say Gem.path.each do |gem_repo| doctor = Gem::Doctor.new gem_repo, [:dry_run] doctor.doctor end end |
#execute ⇒ Object
74 75 76 77 |
# File 'lib/rubygems/commands/check_command.rb', line 74 def execute check_gems if [:gems] doctor if [:doctor] end |
#usage ⇒ Object
:nodoc:
94 95 96 |
# File 'lib/rubygems/commands/check_command.rb', line 94 def usage # :nodoc: "#{program_name} [OPTIONS] [GEMNAME ...]" end |