Method: Gem::Dependency#to_spec

Defined in:
lib/rubygems/dependency.rb

#to_specObject



312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/rubygems/dependency.rb', line 312

def to_spec
  matches = to_specs.compact

  active = matches.find(&:activated?)
  return active if active

  unless prerelease?
    # Consider prereleases only as a fallback
    pre, matches = matches.partition {|spec| spec.version.prerelease? }
    matches = pre if matches.empty?
  end

  matches.first
end