class GitSemverCop::VersionFile

Attributes

path[RW]

Public Class Methods

exist?() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 8
def exist?
  path && File.exist?(path)
end

Public Instance Methods

path() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 19
def path
  self.class.path
end
update() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 13
def update
  update_version
  write_update
  add_to_git
end

Private Instance Methods

add_to_git() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 38
def add_to_git
  system "git add #{path}"
end
contents() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 25
def contents
  @contents ||= File.read(path)
end
current_version() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 29
def current_version
  SemVer.find.to_s[1..-1]
end
write_update() click to toggle source
# File lib/git-semver-cop/version_files/version_file.rb, line 33
def write_update
  puts "Changing #{path} version"
  File.write(path, contents)
end