Class: Giblish::GitRepoConverter

Inherits:
FileTreeConverter show all
Defined in:
lib/giblish/core.rb

Overview

Converts all adoc files within a git repo

Instance Attribute Summary

Attributes inherited from FileTreeConverter

#converter

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GitRepoConverter

Returns a new instance of GitRepoConverter.



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/giblish/core.rb', line 292

def initialize(options)
  super(options)
  # cache the top of the tree since we need to redefine the
  # paths per branch/tag later on.
  @master_paths = @paths.dup
  @master_deployment_info = @deploy_info.dup
  @git_repo_root = options[:gitRepoRoot]
  @git_repo = init_git_repo @git_repo_root, options[:localRepoOnly]
  @user_branches = select_user_branches(options[:gitBranchRegexp])
  @user_tags = select_user_tags(options[:gitTagRegexp])
end

Instance Method Details

#convertObject

Convert the docs from each branch/tag and add info to the summary page. return true if all conversions went ok, false if at least one failed



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/giblish/core.rb', line 308

def convert
  conv_error = false
  (@user_branches + @user_tags).each do |co|
    has_error = convert_one_checkout(co)
    if has_error == true
      conv_error = true
    end
  rescue
    conv_error = true
    next
  end

  # Render the summary page
  index_builder = GitSummaryIndexBuilder.new @git_repo,
                                             @user_branches,
                                             @user_tags

  conv_error ||= @converter.convert_str(
    index_builder.source,
    @master_paths.dst_root_abs,
    "index"
  )

  # clean up
  GC.start

  conv_error
end