Class: Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/toolbox/gem_specification.rb

Class Method Summary collapse

Class Method Details

.latest_versionsObject

Provides retrieving only the latest versions of all gems on your system regardless of multiple versions of a gem installed.


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/toolbox/gem_specification.rb', line 8

def self.latest_versions
  specs = Gem::Specification.find_all.map.inject({}) do |result, spec|
    if result.has_key?(spec.name) && result[spec.name].version < spec.version
      result[spec.name] = spec
    elsif !result.has_key?(spec.name)
      result[spec.name] = spec
    end
    result
  end
  specs.values
end