Sha256: 57ca08df08b48af3339de321bf67d2d9ad453eeedce1f45918bb157c24d48f98

Contents?: true

Size: 797 Bytes

Versions: 20

Compression:

Stored size: 797 Bytes

Contents

require 'yaml'

REDIRECTS_FILE = '.redirects.gollum'

module Gollum
  
  module Redirects
        
    def stale?
      @current_head != get_head_sha
    end

    def init(wiki)
      @wiki = wiki
      @current_head = get_head_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(commit=nil)
      commit = {} if commit.nil?
      @wiki.overwrite_file(REDIRECTS_FILE, self.to_yaml, commit)
    end
    
    def get_head_sha
      @wiki.repo.head ? @wiki.repo.head.commit.sha : nil
    end
    
  end # Redirects Module

end # Gollum Module

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
gollum-lib-6.0-java lib/gollum-lib/redirects.rb
gollum-lib-6.0 lib/gollum-lib/redirects.rb
gollum-lib-5.2.4-java lib/gollum-lib/redirects.rb
gollum-lib-5.2.4 lib/gollum-lib/redirects.rb
gollum-lib-5.2.3-java lib/gollum-lib/redirects.rb
gollum-lib-5.2.3 lib/gollum-lib/redirects.rb
gollum-lib-5.2.2-java lib/gollum-lib/redirects.rb
gollum-lib-5.2.2 lib/gollum-lib/redirects.rb
gollum-lib-5.2.1-java lib/gollum-lib/redirects.rb
gollum-lib-5.2.1 lib/gollum-lib/redirects.rb
gollum-lib-5.2-java lib/gollum-lib/redirects.rb
gollum-lib-5.2 lib/gollum-lib/redirects.rb
gollum-lib-5.1.3-java lib/gollum-lib/redirects.rb
gollum-lib-5.1.3 lib/gollum-lib/redirects.rb
gollum-lib-5.1.2-java lib/gollum-lib/redirects.rb
gollum-lib-5.1.2 lib/gollum-lib/redirects.rb
gollum-lib-5.1.1-java lib/gollum-lib/redirects.rb
gollum-lib-5.1.1 lib/gollum-lib/redirects.rb
gollum-lib-5.1-java lib/gollum-lib/redirects.rb
gollum-lib-5.1 lib/gollum-lib/redirects.rb