| Class | Gem::Commands::CheckCommand |
| In: |
lib/rubygems/commands/check_command.rb
|
| Parent: | Gem::Command |
# File lib/rubygems/commands/check_command.rb, line 9
9: def initialize
10: super 'check', 'Check installed gems',
11: :verify => false, :alien => false
12:
13: add_option( '--verify FILE',
14: 'Verify gem file against its internal',
15: 'checksum') do |value, options|
16: options[:verify] = value
17: end
18:
19: add_option('-a', '--alien', "Report 'unmanaged' or rogue files in the",
20: "gem repository") do |value, options|
21: options[:alien] = true
22: end
23:
24: add_version_option 'check'
25: end
# File lib/rubygems/commands/check_command.rb, line 27
27: def execute
28: if options[:alien]
29: say "Performing the 'alien' operation"
30: say
31: gems = get_all_gem_names rescue []
32: Gem::Validator.new.alien(gems).sort.each do |key, val|
33: unless val.empty? then
34: say "#{key} has #{val.size} problems"
35: val.each do |error_entry|
36: say " #{error_entry.path}:"
37: say " #{error_entry.problem}"
38: end
39: else
40: say "#{key} is error-free" if Gem.configuration.verbose
41: end
42: say
43: end
44: end
45:
46: if options[:verify]
47: gem_name = options[:verify]
48: unless gem_name
49: alert_error "Must specify a .gem file with --verify NAME"
50: return
51: end
52: unless File.exist?(gem_name)
53: alert_error "Unknown file: #{gem_name}."
54: return
55: end
56: say "Verifying gem: '#{gem_name}'"
57: begin
58: Gem::Validator.new.verify_gem_file(gem_name)
59: rescue Exception
60: alert_error "#{gem_name} is invalid."
61: end
62: end
63: end