class Caramelize::InputWiki::RedmineWiki
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 11 def initialize(options = {}) super(options) @options[:markup] = :textile @options[:filters] << ::Caramelize::SwapWikiLinks @options[:filters] << ::Caramelize::RemoveTableTabLineEndings @options[:create_namespace_overview] = true end
Public Instance Methods
read_pages()
click to toggle source
after calling this action, I expect the titles and revisions to be filled
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 20 def read_pages add_projects_as_namespaces pages.each do |row_page| build_page(row_page) end titles.uniq! revisions.sort_by!(&:time) revisions end
Private Instance Methods
add_projects_as_namespaces()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 64 def add_projects_as_namespaces projects.each do |row_project| namespace = { identifier: row_project['identifier'], name: row_project['name'] } namespaces << namespace end end
build_page(row_page)
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 43 def build_page(row_page) results_contents = database.query(single_page_query(row_page['id'])) wiki = wikis.find { |row| row['id'] == row_page['wiki_id'] } project_identifier = '' if wiki project = projects.find { |row| row['id'] == wiki['project_id'] } project_identifier = "#{project['identifier']}/" end title = project_identifier + row_page['title'] titles << title results_contents.each do |row_content| page = Page.new(build_properties(title, row_content)) revisions << page end end
build_properties(title, row_content)
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 104 def build_properties(title, row_content) author = authors.fetch(row_content['author_id'], nil) { id: row_content['id'], title:, body: row_content['data'], markup: :textile, latest: false, time: row_content['updated_on'], message: row_content['comments'], author: } end
pages()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 92 def pages @pages ||= database.query(pages_query) end
pages_query()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 84 def pages_query 'SELECT id, title, wiki_id FROM wiki_pages;' end
projects()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 96 def projects @projects ||= database.query(projects_query) end
projects_query()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 80 def projects_query 'SELECT id, identifier, name FROM projects;' end
single_page_query(page_id)
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 76 def single_page_query(page_id) "SELECT * FROM wiki_content_versions WHERE page_id='#{page_id}' ORDER BY updated_on;" end
wikis()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 100 def wikis @wikis ||= database.query(wikis_query) end
wikis_query()
click to toggle source
# File lib/caramelize/input_wiki/redmine_wiki.rb, line 88 def wikis_query 'SELECT id, project_id FROM wikis;' end