Module: Gollum::Redirects

Defined in:
lib/gollum-lib/redirects.rb

Instance Method Summary collapse

Instance Method Details

#dump(commit = nil) ⇒ Object



32
33
34
35
# 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_shaObject



37
38
39
# File 'lib/gollum-lib/redirects.rb', line 37

def get_head_sha
  @wiki.repo.head ? @wiki.repo.head.commit.sha : nil
end

#init(wiki) ⇒ Object



13
14
15
16
# File 'lib/gollum-lib/redirects.rb', line 13

def init(wiki)
  @wiki = wiki
  @current_head = get_head_sha
end

#loadObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# 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?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/gollum-lib/redirects.rb', line 9

def stale?
  @current_head != get_head_sha
end