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 13 def initialize(new_wiki_path) # TODO use sanitized name as wiki-repository-title @wiki_path = new_wiki_path initialize_repository end
Public Instance Methods
build_commit(page)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 53 def build_commit(page) { message: page.commit_message, name: page.author.name, email: page.author.email, time: page.time } end
commit_history(revisions, options = {}, &block)
click to toggle source
Commit all revisions of the given history into this gollum-wiki-repository.
# File lib/caramelize/output_wiki/gollum.rb, line 37 def commit_history(revisions, options = {}, &block) revisions.each_with_index do |page, index| # call debug output from outside block.call(page, index) if block_given? 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 45 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 21 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, rename)
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 31 def rename_page(page_title, rename) gollum_page = gollum.page(page_title) gollum.rename_page(gollum_page, rename, { message: 'Rename home page' }) end
supported_markup()
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 49 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 64 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 68 def gollum @gollum ||= ::Gollum::Wiki.new(wiki_path, {repo_is_bare: true}) end
initialize_repository()
click to toggle source
# File lib/caramelize/output_wiki/gollum.rb, line 72 def initialize_repository return if File.exists?(wiki_path) Dir.mkdir(wiki_path) #::Gollum::Git::Repo.new(wiki_path, { is_bare: true }) ::Gollum::Git::Repo.init(wiki_path) end