class Caramelize::OutputWiki::Gollum
Constants
- SUPPORTED_TARGET_MARKUP
Attributes
wiki_path[R]
Public Class Methods
new(new_wiki_path)
click to toggle source
Initialize a new gollum-wiki-repository at the given path.
# File lib/caramelize/output_wiki/gollum.rb, line 14 def initialize(new_wiki_path) # TODO: use sanitized name as wiki-repository-title @wiki_path = new_wiki_path initialize_repository unless File.exist?(wiki_path) end
Public Instance Methods
build_commit(page)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 54 def build_commit(page) { message: page.commit_message, name: page.author_name, email: page.author_email, time: page.time } end
commit_history(revisions, options = {}) { |page, index| ... }
click to toggle source
Commit all revisions of the given history into this gollum-wiki-repository.
# File lib/caramelize/output_wiki/gollum.rb, line 38 def commit_history(revisions, options = {}, &block) revisions.each_with_index do |page, index| # call debug output from outside yield(page, index) if block commit_revision(page, options.fetch(:markup, :markdown)) end end
commit_namespace_overview(namespaces)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 46 def commit_namespace_overview(namespaces) commit_revision(build_namespace_overview(namespaces), :markdown) end
commit_revision(page, markup)
click to toggle source
Commit the given page into the gollum-wiki-repository. Make sure the target markup is correct before calling this method.
# File lib/caramelize/output_wiki/gollum.rb, line 22 def commit_revision(page, markup) gollum_page = gollum.page(page.path) if gollum_page gollum.update_page(gollum_page, gollum_page.name, gollum_page.format, page.body, build_commit(page)) else gollum.write_page(page.path, markup, page.body, build_commit(page)) end end
rename_page(page_title, new_title)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 32 def rename_page(page_title, new_title) gollum_page = gollum.page(page_title) gollum.rename_page(gollum_page, new_title, { message: 'Rename home page' }) end
supported_markup()
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 50 def supported_markup SUPPORTED_TARGET_MARKUP end
Private Instance Methods
build_namespace_overview(namespaces)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 65 def build_namespace_overview(namespaces) ::Caramelize::Services::PageBuilder.build_namespace_overview(namespaces) end
gollum()
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 69 def gollum @gollum ||= ::Gollum::Wiki.new(wiki_path, { repo_is_bare: true, ref: 'main' }) end
initialize_repository()
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 73 def initialize_repository Dir.mkdir(wiki_path) # ::Gollum::Git::Repo.new(wiki_path, { is_bare: true }) ::Gollum::Git::Repo.init(wiki_path) end