module Gollum::Redirects

Public Instance Methods

dump(commit=nil) click to toggle source
# File lib/gollum-lib/redirects.rb, line 32
def dump(commit=nil)
  commit = {} if commit.nil?
  @wiki.overwrite_file(REDIRECTS_FILE, self.to_yaml, commit)
end
get_head_sha() click to toggle source
# File lib/gollum-lib/redirects.rb, line 37
def get_head_sha
  @wiki.repo.head ? @wiki.repo.head.commit.sha : nil
end
init(wiki) click to toggle source
# File lib/gollum-lib/redirects.rb, line 13
def init(wiki)
  @wiki = wiki
  @current_head = get_head_sha
end
load() click to toggle source
# File lib/gollum-lib/redirects.rb, line 18
def load
  file = @wiki.file(REDIRECTS_FILE)
  redirects = {}
  if file
    begin
      redirects = YAML.load(file.raw_data)
    rescue YAML::Error
      # TODO handle error
    end
  end
  self.clear
  self.merge!(redirects)
end
stale?() click to toggle source
# File lib/gollum-lib/redirects.rb, line 9
def stale?
  @current_head != get_head_sha
end