class RakeRack::Version

Constants

HISTORY_FILE

Public Class Methods

add_history_header(version, history_file = HISTORY_FILE) click to toggle source
# File lib/version.rb, line 31
def self.add_history_header(version, history_file = HISTORY_FILE)
  history = current_history history_file
  File.open history_file, "w" do |f|
    f.puts "== #{version} (#{Time.now.strftime "%d %B %Y"})"
    f.puts
    f.print history
  end
  puts "Added version to history.rdoc"
end
commit(version) click to toggle source
# File lib/version.rb, line 50
def self.commit version
  `git add . && git commit -m 'increment version to #{version}'`
  puts "Committed change"
end
current_history(history_file) click to toggle source
# File lib/version.rb, line 4
def self.current_history history_file
  unless File.exists? history_file
     File.open history_file, "w" do |f|
       f.puts "== 0.0.0 (#{Time.now.strftime "%d %B %Y"})"
     end
  end
  File.read history_file
end
gem?() click to toggle source
# File lib/version.rb, line 60
def self.gem?
  !Dir.glob('*.gemspec').empty?
end
latest_version() click to toggle source
# File lib/version.rb, line 13
def self.latest_version
  latest_version_string = current_history(HISTORY_FILE)[/== ([\d\.]*)/, 1] || "0.0.0"
  @latest_version ||= latest_version_string.split(".").map(&:to_i)
  def @latest_version.to_s
    join "."
  end
  @latest_version
end
tag(version) click to toggle source
# File lib/version.rb, line 55
def self.tag version
  `git tag #{version}`
  puts "Tagged with #{version}"
end
update_gem(version) click to toggle source
# File lib/version.rb, line 41
def self.update_gem version
  path = Dir.glob('*.gemspec').first
  text = File.read path
  File.open(path, "w") do |file|
    file.puts text.sub(/(.*version\s*=\s*)(['|"].*['|"])/, "\\1'#{version}'")
  end
  puts "Added version to .gemfile"
end
update_to(version) click to toggle source
# File lib/version.rb, line 22
def self.update_to version
  add_history_header version
  update_gem version if gem?
  commit version
  tag version
  branch = `git symbolic-ref HEAD`[%r{.*/(.*)}, 1]
  puts "To push the new tag, use 'git push origin #{branch} --tags'"
end