module Cuprum::Collections::Version

@api private

The current version of the gem.

@see semver.org/

Constants

BUILD

Build metadata.

MAJOR

Major version.

MINOR

Minor version.

PATCH

Patch version.

PRERELEASE

Prerelease version.

Public Class Methods

to_gem_version() click to toggle source

Generates the gem version string from the Version constants.

Inlined here because dependencies may not be loaded when processing a gemspec, which results in the user being unable to install the gem for the first time.

@see SleepingKingStudios::Tools::SemanticVersion#to_gem_version

# File lib/cuprum/collections/version.rb, line 30
def to_gem_version
  str = +"#{MAJOR}.#{MINOR}.#{PATCH}"

  prerelease = value_of(:PRERELEASE)
  str << ".#{prerelease}" if prerelease

  build = value_of(:BUILD)
  str << ".#{build}" if build

  str
end

Private Class Methods

value_of(constant) click to toggle source
# File lib/cuprum/collections/version.rb, line 44
def value_of(constant)
  return nil unless const_defined?(constant)

  value = const_get(constant)

  return nil if value.respond_to?(:empty?) && value.empty?

  value
end