lib/caramelize/input_wiki/wikkawiki.rb in caramelize-1.0.0 vs lib/caramelize/input_wiki/wikkawiki.rb in caramelize-1.1.0

- old
+ new

@@ -1,14 +1,16 @@ -require 'caramelize/input_wiki/wiki' require 'caramelize/database_connector' require 'caramelize/filters/wikka_to_markdown' module Caramelize module InputWiki class WikkaWiki < Wiki include DatabaseConnector + SQL_PAGES = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'.freeze + SQL_AUTHORS = 'SELECT name, email FROM wikka_users;'.freeze + def initialize(options = {}) super(options) @options[:markup] = :wikka @options[:filters] << Caramelize::Wikka2Markdown end @@ -25,22 +27,28 @@ revisions end def read_authors - sql = 'SELECT name, email FROM wikka_users;' - results = database.query(sql) + results = database.query(authors_query) results.each do |row| authors[row['name']] = OpenStruct.new(name: row['name'], email: row['email'] ) end end private + def pages_query + SQL_PAGES + end + + def authors_query + SQL_AUTHORS + end + def pages - sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;' - @pages ||= database.query(sql) + @pages ||= database.query(pages_query) end def build_properties(row) author = authors[row['user']] {