class Autoversion::CLI

Attributes

pwd[RW]
version_file_contents[RW]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/autoversion/cli.rb, line 12
def initialize(*args)
  super *args
  version_file_contents = CLI::version_file_contents || File.read(File.join(Dir.pwd, "Versionfile"))
  @versioner = Autoversion::Versioner.new version_file_contents, CLI::pwd
end

Public Instance Methods

increment_version(type, simulate=false, force=false) click to toggle source
# File lib/autoversion/cli.rb, line 51
def increment_version type, simulate=false, force=false
  if force or yes? "Do you want to increment #{type.to_s} to #{@versioner.next_version(type)}? (y/N)"
    outcome = simulate ? "would change" : "changed"

    begin
      @versioner.increment! type, simulate
      say "Version #{outcome} to #{@versioner.current_version}", simulate ? :cyan : :green
    rescue Autoversion::Gitter::DirtyStaging
      say "Autoversion error: The git workspace is in a dirty state.", :red
    rescue Autoversion::Gitter::NotOnStableBranch => e
      say "Autoversion error: Major version increments can only happen on your configured stable branch (#{e.message}).", :red
    end
  else
    say "No changes were made."
  end
end
major() click to toggle source
# File lib/autoversion/cli.rb, line 40
def major
  increment_version :major, options[:simulate], options[:force]
end
minor() click to toggle source
# File lib/autoversion/cli.rb, line 33
def minor
  increment_version :minor, options[:simulate], options[:force]
end
patch() click to toggle source
# File lib/autoversion/cli.rb, line 26
def patch
  increment_version :patch, options[:simulate], options[:force]
end
read_version() click to toggle source
# File lib/autoversion/cli.rb, line 19
def read_version
  say @versioner.current_version.to_s, :cyan
end
special() click to toggle source
# File lib/autoversion/cli.rb, line 46
def special
  create_build_version
end