Sha256: dbf7c3931a55d05dd32f0910cb19fadaae78dadc81e3d7be3cc320dc94f92e7a

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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
        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 # rubocop:todo Lint/DuplicateMethods
        @namespaces ||= {}
      end

      def authors
        @authors ||= {}
      end

      def revisions # rubocop:todo Lint/DuplicateMethods
        @revisions ||= []
      end

      def titles # rubocop:todo Lint/DuplicateMethods
        @titles ||= []
      end

      def excluded_pages
        []
      end

      def convert_markup?(to_markup)
        markup != to_markup
      end

      def filters
        @options[:filters]
      end

      def latest_revisions
        @latest_revisions ||= titles.map { |title| revisions_by_title(title).last }.compact
      end

      def markup
        @options[:markup]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-1.2.1 lib/caramelize/input_wiki/wiki.rb