class GemspecVersioner

Constants

DATE_REGEX
VERSION_REGEX

Public Instance Methods

get_current_version() click to toggle source
# File lib/rake-extensions.rb, line 115
def get_current_version()
  current_version_with_regex(FileList['*.gemspec'], VERSION_REGEX)
end
update_version(new_version) click to toggle source
# File lib/rake-extensions.rb, line 118
def update_version(new_version)
  FileUtils.cd @version_dir, :verbose => false do
    FileList['*.gemspec'].each do |file|
      text = File.read(file)
      today = Time.now.strftime("%Y-%m-%d")
      correct_date_contents = text.gsub(DATE_REGEX, "\\1#{today}\\3")
      new_contents = correct_date_contents.gsub(VERSION_REGEX, "\\1#{new_version}\\3")
      File.open(file, "w") { |f| f.write new_contents }
    end
  end
end