Sha256: b9555c9a576ad1d081aebff4a133947a82a6f40684302257be23cfbbe31aa81a

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module Caramelize
  class Wiki
    include DatabaseConnector

    attr_accessor :revisions, :wiki_title, :titles, :description, :namespaces, :options

    def initialize options={}
      @options = options
      @options[:filters] = []
      @namespaces = []
    end

    def revisions_by_title(title)
      # new array only containing pages by this name sorted by time asc
      # TODO this is probably bad for renamed pages if supported
      return revisions.select { |revision| revision.title == title }.sort { |x,y| x.time <=> y.time }
      []
    end

    # return an empty array in case this action was not overridden
    def read_authors
      return []
    end

    def namespaces
      @namespaces ||= {}
    end

    def authors
      @authors ||= {}
    end

    def revisions
      @revisions ||= []
    end

    def titles
      @titles ||= []
    end

    def convert_markup?(to_markup)
      markup != to_markup
    end

    def filters
      @options[:filters]
    end

    def latest_revisions
      @latest_revisions = []
      titles.each do |title|
        # pick first revision by descending date
        @latest_revisions << revisions_by_title(title).last
      end
      @latest_revisions
    end

    def markup
      @options[:markup]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-0.3.0 lib/caramelize/wiki/wiki.rb