Class: FeduxOrgStdlib::Rake::VersionBumpTask

Inherits:
Task
  • Object
show all
Includes:
FeduxOrgStdlib::Roles::Versionable
Defined in:
lib/fedux_org_stdlib/rake/version_bump_task.rb

Overview

Version Bump Task

Examples:

Create new version task for bumping the major number X.0.0

FeduxOrgStdlib::Rake::VersionBumpTask.new(
  name: 'version:bump:major',
  description: 'Bump major version part'
) { |t| t.bump_version :major }

Create new version task for bumping the minor number 0.X.0

FeduxOrgStdlib::Rake::VersionBumpTask.new(
  name: 'version:bump:minor',
  description: 'Bump minor version part'
) { |t| t.bump_version :minor }

Create new version task for bumping the tiny number 0.0.X

FeduxOrgStdlib::Rake::VersionBumpTask.new(
  name: 'version:bump:tiny',
  description: 'Bump tiny version part'
) { |t| t.bump_version :tiny }

See Also:

  • Rakefile

Instance Attribute Summary

Attributes inherited from Task

#description, #name, #verbose, #verbose (true)

Instance Method Summary collapse

Methods included from FeduxOrgStdlib::Roles::Versionable

#version_file

Methods inherited from Task

#include, #instance_binding

Instance Method Details

#bump_version(type) ⇒ Object



33
34
35
36
37
# File 'lib/fedux_org_stdlib/rake/version_bump_task.rb', line 33

def bump_version(type)
  version_update do |file|
    file.bump(type)
  end
end

#version(new_version) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fedux_org_stdlib/rake/version_bump_task.rb', line 40

def version(new_version)
  fail Exception, "You need to define a version via \"VERSION=<version>\" or \"version=<version>\"." if new_version.blank?

  begin
    version_update do |file|
      file.version = new_version
    end
  rescue StandardError => e
    logger.fatal("Nothing has changed since your last commit or has been added to the index. Therefor nothing needs to be commited: #{e.message}.")
  end
end