# File lib/rubygems/commands/lock_command.rb, line 5 5: def initialize 6: super 'lock', 'Generate a lockdown list of gems', 7: :strict => false 8: 9: add_option '-s', '--[no-]strict', 10: 'fail if unable to satisfy a dependency' do |strict, options| 11: options[:strict] = strict 12: end 13: end
# File lib/rubygems/commands/lock_command.rb, line 60 60: def complain(message) 61: if options[:strict] then 62: raise Gem::Exception, message 63: else 64: say "# #{message}" 65: end 66: end
# File lib/rubygems/commands/lock_command.rb, line 68 68: def execute 69: say "require 'rubygems'" 70: 71: locked = {} 72: 73: pending = options[:args] 74: 75: until pending.empty? do 76: full_name = pending.shift 77: 78: spec = Gem::SourceIndex.load_specification spec_path(full_name) 79: 80: if spec.nil? then 81: complain "Could not find gem #{full_name}, try using the full name" 82: next 83: end 84: 85: say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name] 86: locked[spec.name] = true 87: 88: spec.runtime_dependencies.each do |dep| 89: next if locked[dep.name] 90: candidates = Gem.source_index.search dep 91: 92: if candidates.empty? then 93: complain "Unable to satisfy '#{dep}' from currently installed gems" 94: else 95: pending << candidates.last.full_name 96: end 97: end 98: end 99: end
# File lib/rubygems/commands/lock_command.rb, line 101 101: def spec_path(gem_full_name) 102: gemspecs = Gem.path.map do |path| 103: File.join path, "specifications", "#{gem_full_name}.gemspec" 104: end 105: 106: gemspecs.find { |gemspec| File.exist? gemspec } 107: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.