class Litbuild::Driver

This is what the command-line program `lb` uses to do all the work, aside from parsing the command line. It initializes a blueprint library and provides methods for exercising all the functionality of litbuild: writing bash scripts, writing documents, querying package details, etc.

All the actual work is done by Visitors that are handed to the top-level blueprint target (typically specified on the command line).

Constants

REQUIRED_PARAMS

Public Class Methods

new(logfile_namer_class: Litbuild::LogfileNamer) click to toggle source
# File lib/litbuild/driver.rb, line 22
def initialize(logfile_namer_class: Litbuild::LogfileNamer)
  @bplib = BlueprintLibrary.new(logfile_namer_class: logfile_namer_class)
end

Public Instance Methods

download_urls_for(target:) click to toggle source
# File lib/litbuild/driver.rb, line 34
def download_urls_for(target:)
  uv = UrlVisitor.new
  dispatch(visitor: uv, target: target)
  uv.urls
end
library() click to toggle source
# File lib/litbuild/driver.rb, line 26
def library
  @bplib
end
params() click to toggle source
# File lib/litbuild/driver.rb, line 30
def params
  @bplib.parameters
end
source_files_for(target:) click to toggle source
# File lib/litbuild/driver.rb, line 40
def source_files_for(target:)
  sfv = SourceFilesVisitor.new
  dispatch(visitor: sfv, target: target)
  sfv.files
end
write_document_for(target:) click to toggle source
# File lib/litbuild/driver.rb, line 53
def write_document_for(target:)
  adv = AsciiDocVisitor.new(parameters: params)
  bp = library.blueprint_for(target: target)
  bp.accept(visitor: adv)
  adv.write_toplevel_doc(blueprint: bp)
end
write_scripts_for(target:) click to toggle source
# File lib/litbuild/driver.rb, line 46
def write_scripts_for(target:)
  bsv = BashScriptVisitor.new(parameters: params)
  dispatch(visitor: bsv, target: target)
  bsv.write_sudoers
  bsv.write_toplevel_script(target: target)
end

Private Instance Methods

dispatch(visitor:, target:) click to toggle source
# File lib/litbuild/driver.rb, line 62
def dispatch(visitor:, target:)
  library.blueprint_for(target: target).accept(visitor: visitor)
end