lib/caramelize/input_wiki/redmine_wiki.rb in caramelize-1.1.1 vs lib/caramelize/input_wiki/redmine_wiki.rb in caramelize-1.2.0
- old
+ new
@@ -1,5 +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
@@ -21,37 +23,37 @@
pages.each do |row_page|
build_page(row_page)
end
titles.uniq!
- revisions.sort! { |a,b| a.time <=> b.time }
+ revisions.sort! { |a, b| a.time <=> b.time }
revisions
end
def read_authors
results = database.query(authors_query)
results.each do |row|
- authors[row["id"]] = OpenStruct.new(id: row["id"],
- name: row["login"],
- email: row["mail"])
+ authors[row['id']] = { id: row['id'],
+ name: row['login'],
+ email: row['mail'] }
end
authors
end
private
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.select { |row| row['id'] == row_page['wiki_id'] }.first
project_identifier = ''
if wiki
- project = projects.select{ |row| row['id'] == wiki['project_id'] }.first
- project_identifier = project['identifier'] + '/'
+ project = projects.select { |row| row['id'] == wiki['project_id'] }.first
+ project_identifier = "#{project['identifier']}/"
end
title = project_identifier + row_page['title']
titles << title
@@ -61,12 +63,12 @@
end
end
def add_projects_as_namespaces
projects.each do |row_project|
- namespace = OpenStruct.new(identifier: row_project['identifier'],
- name: row_project['name'])
+ namespace = { identifier: row_project['identifier'],
+ name: row_project['name'] }
namespaces << namespace
end
end
def authors_query
@@ -100,20 +102,19 @@
def wikis
@wikis ||= database.query(wikis_query)
end
def build_properties(title, row_content)
- author = authors.fetch(row_content["author_id"], nil)
+ author = authors.fetch(row_content['author_id'], nil)
{
id: row_content['id'],
- title: title,
+ title:,
body: row_content['data'],
markup: :textile,
latest: false,
time: row_content['updated_on'],
message: row_content['comments'],
- author: author,
- author_name: author.name
+ author:
}
end
end
end
end