Repository URL to install this package:
|
Version:
1.0.4 ▾
|
module Buildgem
class Version
include ForwardGemMethodsToConfig
class << self
attr_accessor :mode
def increment!(mode = nil)
@mode = mode
instance.increment!
end
def instance
version_class.new
end
def version_class
eval "Buildgem::#{version_type.capitalize}Version"
end
def version_type
mode || 'patch'
end
def get_potential_new_version(mode = nil)
@mode = mode
instance.new_version.gsub('"', '')
end
def method_missing(method_name, *args)
instance.send(method_name, *args)
end
end
attr_accessor :file_content
def initialize
@file_content = File.read(gem_version_full_file_path)
end
def increment!
content = file_content.gsub(current_version, new_version)
File.open(gem_version_full_file_path, 'w') do |f|
f.write(content)
end
end
def current_version
file_content.match(/VERSION = (".+")/) { |m| m[1] }
end
def new_version
raise "Please implement #{self.name}#new_version"
end
end
end
require 'buildgem/version/major_version'
require 'buildgem/version/minor_version'
require 'buildgem/version/patch_version'