Class: Giblish::GitRepoConvert

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/application.rb

Overview

Converts a number of branches/tags in a gitrepo according to the given options.

Each branch/tag is converted into a subdir of the given root dir and a summary page with links to the converted docs for each branch/tag is generated within the root dir.

Instance Method Summary collapse

Constructor Details

#initialize(user_opts) ⇒ GitRepoConvert

Returns a new instance of GitRepoConvert.

Raises:

  • (ArgumentError)


90
91
92
93
94
95
96
97
98
99
# File 'lib/giblish/application.rb', line 90

def initialize(user_opts)
  raise ArgumentError, "No selection for git branches or tags were found!" unless user_opts.branch_regex || user_opts.tag_regex

  @user_opts = user_opts.dup

  # cache the root dir
  @dst_topdir = @user_opts.dstdir

  @gm = GitCheckoutManager.new(@user_opts)
end

Instance Method Details

#make_summaryObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/giblish/application.rb', line 118

def make_summary
  # reset the dst dir to the user-given-top
  @user_opts.dstdir = @dst_topdir

  # Make sure the summary page is just 'bare-bone'
  @user_opts.make_searchable = nil
  @user_opts.copy_asset_folders = nil
  @user_opts.no_index = true
  @user_opts.resolve_docid = false
  @user_opts.doc_attributes["table-caption"] = nil

  # assign/setup the doc_attr and layout using the same user options as
  # for the adoc source files on each checkout
  conf = Configurator.new(@user_opts)
  s = @gm.summary_provider
  s.index_basename = conf.config_opts.index_basename
  data_provider = NodeDataProvider.new(
    conf.doc_attr,
    SrcFromString.new(s.source)
  )
  srctree = Gran::PathTree.new("/" + conf.config_opts.index_basename + ".adoc", data_provider)
  TreeConverter.new(srctree, @dst_topdir, conf.build_options).run
end

#runObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/giblish/application.rb', line 101

def run
  # convert all docs found in the branches/tags that the user asked to parse
  @gm.each_checkout do |name|
    # tweak the destination dir to a subdir per branch/tag
    @user_opts.dstdir = @dst_topdir / Giblish.to_fs_str(name)

    Giblog.logger.debug { "cmdline: #{@user_opts.inspect}" }
    configurator = GitRepoConfigurator.new(@user_opts, @gm.repo_root)
    DirTreeConvert.new(@user_opts).run(configurator)
  rescue => e
    Giblog.logger.error { "Conversion of #{name} failed!" }
    raise e if @user_opts.abort_on_error
    Giblog.logger.error { e.message }
  end
  make_summary
end