module New::Version

Public Instance Methods

bump_version(part) click to toggle source
# File lib/new/version.rb, line 14
def bump_version part
  case part
  when :major
    version.major += 1
  when :minor
    version.minor += 1
  when :patch
    version.patch += 1
  end

  version
end
get_part() click to toggle source
# File lib/new/version.rb, line 27
def get_part
  New.say "            Current Version: #{version}", type: :success
  New.say " Specify which part to bump: [#{'Mmp'.green}] (#{'M'.green}ajor / #{'m'.green}inor / #{'p'.green}atch)"
  part = STDIN.gets.chomp!

  case part
  when 'M'
    :major
  when 'm'
    :minor
  when 'p'
    :patch
  end
end
version() click to toggle source
# File lib/new/version.rb, line 12
def version; @version; end
version=(string) click to toggle source
# File lib/new/version.rb, line 4
def version= string
  @version ||= begin
    Semantic::Version.new string
  rescue
    New.say "#{string} is not a semantic version.  Use format `1.2.3`", type: :fail
    exit
  end
end