Sha256: ff897be80a06dd1eaf6371cac51631cfe6d844a72c2729723e6ba638f2494d14

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

module Caramelize
  module InputWiki
    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
        # this does not support renamed pages
        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
        []
      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
        titles.map { |title| revisions_by_title(title).last }.compact
      end

      def markup
        @options[:markup]
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caramelize-1.0.0 lib/caramelize/input_wiki/wiki.rb
caramelize-0.4.0 lib/caramelize/input_wiki/wiki.rb