class Caramelize::InputWiki::WikkaWiki

Constants

SQL_AUTHORS
SQL_PAGES

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Caramelize::InputWiki::Wiki::new
# File lib/caramelize/input_wiki/wikkawiki.rb, line 12
def initialize(options = {})
  super(options)
  @options[:markup] = :wikka
  @options[:filters] << Caramelize::Wikka2Markdown
end

Public Instance Methods

read_authors() click to toggle source
# File lib/caramelize/input_wiki/wikkawiki.rb, line 31
def read_authors
  results = database.query(authors_query)
  results.each do |row|
    authors[row['name']] = OpenStruct.new(name:  row['name'],
                                          email: row['email'] )
  end
end
read_pages() click to toggle source

after calling this action, titles and @revisions are expected to be filled

# File lib/caramelize/input_wiki/wikkawiki.rb, line 19
def read_pages
  pages.each do |row|
    titles << row['tag']
    page = Page.new(build_properties(row))
    revisions << page
  end
  titles.uniq!
  #revisions.sort! { |a,b| a.time <=> b.time }

  revisions
end

Private Instance Methods

authors_query() click to toggle source
# File lib/caramelize/input_wiki/wikkawiki.rb, line 45
def authors_query
  SQL_AUTHORS
end
build_properties(row) click to toggle source
# File lib/caramelize/input_wiki/wikkawiki.rb, line 53
def build_properties(row)
  author = authors[row['user']]
  {
    id: row["id"],
    title: row["tag"],
    body: row["body"],
    markup: :wikka,
    latest: row["latest"] == "Y",
    time: row["time"],
    message: row["note"],
    author: author,
    author_name: row["user"]
  }
end
pages() click to toggle source
# File lib/caramelize/input_wiki/wikkawiki.rb, line 49
def pages
  @pages ||= database.query(pages_query)
end
pages_query() click to toggle source
# File lib/caramelize/input_wiki/wikkawiki.rb, line 41
def pages_query
  SQL_PAGES
end