lib/caramelize/input_wiki/redmine_wiki.rb in caramelize-1.2.1 vs lib/caramelize/input_wiki/redmine_wiki.rb in caramelize-1.3.0

- old
+ new

@@ -1,8 +1,7 @@ # frozen_string_literal: true -require 'caramelize/input_wiki/wiki' require 'caramelize/filters/swap_wiki_links' require 'caramelize/filters/remove_table_tab_line_endings' module Caramelize module InputWiki @@ -10,12 +9,12 @@ include DatabaseConnector def initialize(options = {}) super(options) @options[:markup] = :textile - @options[:filters] << Caramelize::SwapWikiLinks - @options[:filters] << Caramelize::RemoveTableTabLineEndings + @options[:filters] << ::Caramelize::SwapWikiLinks + @options[:filters] << ::Caramelize::RemoveTableTabLineEndings @options[:create_namespace_overview] = true end # after calling this action, I expect the titles and revisions to be filled def read_pages @@ -23,37 +22,35 @@ pages.each do |row_page| build_page(row_page) end titles.uniq! - revisions.sort! { |a, b| a.time <=> b.time } + revisions.sort_by!(&:time) revisions end def read_authors - results = database.query(authors_query) - results.each do |row| + database.query(authors_query).each do |row| authors[row['id']] = { id: row['id'], name: row['login'], email: row['mail'] } end authors end private - # rubocop:todo Metrics/MethodLength - def build_page(row_page) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength + def build_page(row_page) results_contents = database.query(single_page_query(row_page['id'])) - wiki = wikis.select { |row| row['id'] == row_page['wiki_id'] }.first + wiki = wikis.find { |row| row['id'] == row_page['wiki_id'] } project_identifier = '' if wiki - project = projects.select { |row| row['id'] == wiki['project_id'] }.first + project = projects.find { |row| row['id'] == wiki['project_id'] } project_identifier = "#{project['identifier']}/" end title = project_identifier + row_page['title'] titles << title @@ -61,11 +58,10 @@ results_contents.each do |row_content| page = Page.new(build_properties(title, row_content)) revisions << page end end - # rubocop:enable Metrics/MethodLength def add_projects_as_namespaces projects.each do |row_project| namespace = { identifier: row_project['identifier'], name: row_project['name'] } @@ -103,10 +99,10 @@ def wikis @wikis ||= database.query(wikis_query) end - def build_properties(title, row_content) # rubocop:todo Metrics/MethodLength + def build_properties(title, row_content) author = authors.fetch(row_content['author_id'], nil) { id: row_content['id'], title:, body: row_content['data'],