class Builderator::Control::Version
Version
management tools
Initial version boosted shamelessly from github.com/RiotGamesMinions/thor-scmversion
Constants
- DEFAULT_PRERELEASE_NAME
- FORMAT
- RELEASE_TYPES
Order of precedence for release types
Attributes
build[RW]
is_prerelease[RW]
major[RW]
minor[RW]
patch[RW]
prerelease_iteration[RW]
prerelease_name[RW]
ref[RW]
Public Class Methods
bump(type = nil, prerelease_name = nil)
click to toggle source
Alias `bump` to the current version
# File lib/builderator/control/version.rb, line 59 def bump(type = nil, prerelease_name = nil) @current = current.clone current.bump(type, prerelease_name) SCM.tags << current current end
current()
click to toggle source
# File lib/builderator/control/version.rb, line 33 def current @current ||= SCM.tags.last if @current.nil? && Util.relative_path('VERSION').exist? @current = Version.from_string(Util.relative_path('VERSION').read) end if @current.nil? fail 'No current version found! Create a VERSION file or set a version tag in your SCM.' end @current end
from_string(arg, options = {})
click to toggle source
Parse a SemVer string into a Version
# File lib/builderator/control/version.rb, line 69 def from_string(arg, options = {}) matchdata = arg.match(FORMAT) return nil if matchdata.nil? new(matchdata[:major], matchdata[:minor], matchdata[:patch], matchdata[:build], options).tap do |version| version.is_prerelease = !matchdata[:prerelease].nil? if version.is_prerelease version.prerelease_name = matchdata[:prerelease_name] version.prerelease_iteration = matchdata[:prerelease_iteration].to_i end end end
new(major, minor, patch, build = nil, **options)
click to toggle source
# File lib/builderator/control/version.rb, line 83 def initialize(major, minor, patch, build = nil, **options) @major = major.to_i @minor = minor.to_i @patch = patch.to_i @build = build.to_i unless build.nil? @ref = options[:ref] end
set_config_version()
click to toggle source
# File lib/builderator/control/version.rb, line 47 def set_config_version Config.defaults.version = current.to_s Config.recompile end
write()
click to toggle source
# File lib/builderator/control/version.rb, line 52 def write current.write end
Public Instance Methods
prerelease(name = nil)
click to toggle source
Create or bump a new prerelease train
# File lib/builderator/control/version.rb, line 109 def prerelease(name = nil) self.build = nil ## Reset the build counter ## Increment current prerelease train if is_prerelease && (name.nil? || name == prerelease_name) self.prerelease_iteration += 1 return self end ## New prerelease train self.is_prerelease = true self.prerelease_name = name.nil? ? DEFAULT_PRERELEASE_NAME : name self.prerelease_iteration = 0 self end
to_s()
click to toggle source
# File lib/builderator/control/version.rb, line 130 def to_s string = [major, minor, patch].join('.') string << "-#{prerelease_name}.#{prerelease_iteration}" if is_prerelease string << "+build.#{build}" unless build.nil? string end
write()
click to toggle source
# File lib/builderator/control/version.rb, line 126 def write Util.relative_path('VERSION').write(to_s) end