Sha256: a2d2333efd6f1e97542b00694717b5ee06a1c14f496eeb17ffbb768476fb9240

Contents?: true

Size: 825 Bytes

Versions: 9

Compression:

Stored size: 825 Bytes

Contents

class Geminabox::GemVersion
  attr_accessor :name, :number, :platform

  def initialize(name, number, platform)
    @name = name
    @number = number
    @platform = platform
  end

  def ruby?
    !!(platform =~ /ruby/i)
  end

  def version
    Gem::Version.create(number)
  end

  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

  def ==(other)
    return false unless other.class == self.class
    [name, number, platform] == [other.name, other.number, other.platform]
  end

  def gemfile_name
    included_platform = ruby? ? nil : platform
    [name, number, included_platform].compact.join('-')
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
geminabox-0.11.1 lib/geminabox/gem_version.rb
geminabox-inflection-0.12.0 lib/geminabox/gem_version.rb
geminabox-inflection-0.11.0 lib/geminabox/gem_version.rb
geminabox-0.11.0 lib/geminabox/gem_version.rb
geminabox-bootstrap-0.10.3 lib/geminabox/gem_version.rb
geminabox-0.10.1 lib/geminabox/gem_version.rb
geminabox-0.10.0 lib/geminabox/gem_version.rb
geminabox-0.9.0 lib/geminabox/gem_version.rb
geminabox-0.8.0 lib/geminabox/gem_version.rb