Sha256: ed630692f15be4830cfae841ed00750c2b062f1384a4ab2304a94bc872583793
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
# -*- coding: utf-8 -*- module Gemirro ## # The Gem class contains data about a Gem such as the name, requirement as # well as providing some methods to more easily extract the specific version # number. # # @!attribute [r] name # @return [String] # @!attribute [r] number # @return [Integer] # @!attribute [r] platform # @return [String] # @!attribute [r] version # @return [Gem::Version] # class GemVersion include Comparable attr_reader :name, :number, :platform, :version ## # @param [String] name # @param [String] number # @param [String] platform # def initialize(name, number, platform) @name = name @number = number @platform = platform end ## # Is for ruby # # @return [Boolean] # def ruby? !(@platform =~ /^ruby$/i).nil? end ## # Retrieve gem version # # @return [Gem::Version] # def version @version ||= ::Gem::Version.create(number) end ## # Compare gem to another # # @return [Integer] # def <=>(other) sort = other.name <=> @name sort = version <=> other.version if sort.zero? sort = (other.ruby? && !ruby?) ? 1 : -1 if sort.zero? && ruby? != other.ruby? sort = other.platform <=> @platform if sort.zero? sort end ## # Gemfile name # # @return [String] # def gemfile_name platform = ruby? ? nil : @platform [@name, @number, platform].compact.join('-') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gemirro-0.13.3 | lib/gemirro/gem_version.rb |
gemirro-0.13.2 | lib/gemirro/gem_version.rb |
gemirro-0.13.1 | lib/gemirro/gem_version.rb |
gemirro-0.12.0 | lib/gemirro/gem_version.rb |