Sha256: f3fde8e6f8e2fa56e204239557bccb47845c0380bdfc21cefea27dfb95028502

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

module Gem
  class Specification

    ##
    # Provides retrieving only the latest versions of all gems on
    # your system regardless of multiple versions of a gem installed.
    #
    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
  end
end

##
# Extends the functionality of a Gem::Specification to be able to retrieve the latest version of gems
# currently on your system.
#
# == Usage
#
#     Gem::Specification.latest_versions.each do |spec|
#       puts "#{spec.name} (#{spec.version})"
#     end
#
module GemSpecification
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-development-toolbox-1.3.1 lib/toolbox/gem_specification.rb
ruby-development-toolbox-1.3.0 lib/toolbox/gem_specification.rb
ruby-development-toolbox-1.2.0 lib/toolbox/gem_specification.rb