Class: VivlioStarter::CLI::TocCommands::TocCommandExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio_starter/cli/toc.rb

Overview

toc コマンドのエントリ処理を統括する 中間 HTML と _toc.md/_toc.html はワークスペースの html/ に置く(P4 §3.4-1)

Constant Summary collapse

BASE_DIR =
Pathname.new(Common::BUILD_HTML_DIR).expand_path

Instance Method Summary collapse

Constructor Details

#initialize(options, htmls) ⇒ TocCommandExecutor

Returns a new instance of TocCommandExecutor.



36
37
38
39
# File 'lib/vivlio_starter/cli/toc.rb', line 36

def initialize(options, htmls)
  @options = options || {}
  @resolver = HtmlTargetResolver.new(htmls, base_dir: BASE_DIR)
end

Instance Method Details

#callObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/vivlio_starter/cli/toc.rb', line 41

def call
  apply_verbose
  targets = resolver.resolve
  return warn_no_targets if targets.empty?

  log_targets(targets)
  entry_map = build_entry_map(targets)
  document = TocDocumentBuilder.new(entry_map, base_dir: BASE_DIR).build
  TocOutputWriter.new(document, base_dir: BASE_DIR).write
end