Sha256: f3d4ae8c236b36b20f6c4981d675a42dce2a3a4aaa52484543c06122e6dfbefe

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

require 'yaml'

REDIRECTS_FILE = '.redirects.gollum'

module Gollum
  
  module Redirects
        
    def stale?
      @current_head != @wiki.repo.head.commit.sha
    end

    def init(wiki)
      @wiki = wiki
      @current_head = @wiki.repo.head.commit.sha
    end

    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
    
    def dump
      @wiki.overwrite_file(REDIRECTS_FILE, self.to_yaml, {})
    end
    
  end # Redirects Module

end # Gollum Module

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gollum-lib-5.0.1-java lib/gollum-lib/redirects.rb
gollum-lib-5.0.1 lib/gollum-lib/redirects.rb
gollum-lib-5.0 lib/gollum-lib/redirects.rb