Module: Versionomy::Format::Rubygems::ExtraMethods

Defined in:
lib/versionomy/format_definitions/rubygems.rb

Overview

Extra methods added to version values that use the rubygems schema.

Instance Method Summary collapse

Instance Method Details

#partsObject

Returns a list of the field values, in field order, with trailing zeroes stripped off.

This behaves the same as the Gem::Version#parts method in rubygems.



103
104
105
106
107
108
109
# File 'lib/versionomy/format_definitions/rubygems.rb', line 103

def parts
  unless defined?(@parts)
    @parts = values_array
    @parts.pop while @parts.size > 1 && @parts.last == 0
  end
  @parts
end

#prerelease?Boolean

Returns true if the version is a prerelease version– that is, if any of the fields is non-numeric.

This behaves the same as the Gem::Version#prerelease? method in rubygems.

Returns:

  • (Boolean)


75
76
77
# File 'lib/versionomy/format_definitions/rubygems.rb', line 75

def prerelease?
  values_array.any?{ |val_| val_.kind_of?(::String) }
end

#releaseObject

Returns the release for this version. For example, converts “1.2.0.a.1” to “1.2.0”. Non-prerelease versions return themselves.

This behaves the same as the Gem::Version#release method in rubygems.



87
88
89
90
91
92
93
94
# File 'lib/versionomy/format_definitions/rubygems.rb', line 87

def release
  values_ = []
  self.each_field_object do |field_, val_|
    break unless val_.kind_of?(::Integer)
    values_ << val_
  end
  Value.new(values_, self.format, self.unparse_params)
end