Class: BumpGemVersion::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/bump_gem_version.rb

Overview

All the CLI commands are defined here

Constant Summary collapse

BUMPS =
%w[major minor patch pre].freeze
PRERELEASE =
["alpha", "beta", "rc", nil].freeze
VERSION_REGEX =
/(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join("|")}))?)/

Instance Method Summary collapse

Instance Method Details

#currentObject



14
# File 'lib/bump_gem_version.rb', line 14

def current = puts(current_version[0])

#exact(version) ⇒ Object



42
# File 'lib/bump_gem_version.rb', line 42

def exact(version) = bump_exact_version(version)

#labels(labels = ) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bump_gem_version.rb', line 28

def labels(labels = options[:default])
  bump_type = labels&.split(",")&.find { |label| BUMPS.include?(label) }

  if bump_type.nil? && !BUMPS.include?(options[:default])
    say_error("Unable to find a valid bump label or default label.", :red)
    exit 1
  end

  return bump_gem_version(bump_type) unless bump_type.nil?

  bump_gem_version(options[:default])
end

#majorObject



17
# File 'lib/bump_gem_version.rb', line 17

def major = bump_gem_version("major")

#minorObject



20
# File 'lib/bump_gem_version.rb', line 20

def minor = bump_gem_version("minor")

#patchObject



23
# File 'lib/bump_gem_version.rb', line 23

def patch = bump_gem_version("patch")