Sha256: 4fb760049c4262db2264d8c1d48fb33fe7d909932663dddbfa23c1fce19dfca4

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Caramelize
  autoload :DatabaseConnector, 'caramelize/database_connector'
  class Wiki
    include DatabaseConnector
    attr_accessor :revisions, :wiki_title, :titles, :description
    
    def initialize options={}
      @options = options
    end
    
    def revisions_by_title title
      if @titles.index title
        # new array only containing pages by this name sorted by time
        # TODO this is probably bad for renamed pages if supported
        return @revisions.reject { |revision| revision.title != title }.sort { |x,y| x.time <=> y.time }
      end
    end
    
    # return an empty array in case this action was not overridden
    def read_authors
      return []
    end
    
    def convert_markup? to_markup
      markup != to_markup
    end
    
    def latest_revisions
      @latest_revisions = []
      for title in @titles
        # 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

3 entries across 3 versions & 1 rubygems

Version Path
caramelize-0.1.2 lib/caramelize/wiki/wiki.rb
caramelize-0.1.1 lib/caramelize/wiki/wiki.rb
caramelize-0.1.0 lib/caramelize/wiki/wiki.rb