Class: Litbuild::Driver
- Inherits:
-
Object
- Object
- Litbuild::Driver
- Defined in:
- lib/litbuild/driver.rb
Overview
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).
Constant Summary collapse
- REQUIRED_PARAMS =
%w[DOCUMENT_DIR LOGFILE_DIR PATCH_DIR SCRIPT_DIR TARFILE_DIR WORK_SITE].freeze
Instance Method Summary collapse
- #download_urls_for(target:) ⇒ Object
-
#initialize(logfile_namer_class: Litbuild::LogfileNamer) ⇒ Driver
constructor
A new instance of Driver.
- #library ⇒ Object
- #params ⇒ Object
- #source_files_for(target:) ⇒ Object
- #write_document_for(target:) ⇒ Object
- #write_scripts_for(target:) ⇒ Object
Constructor Details
#initialize(logfile_namer_class: Litbuild::LogfileNamer) ⇒ Driver
Returns a new instance of Driver.
22 23 24 |
# File 'lib/litbuild/driver.rb', line 22 def initialize(logfile_namer_class: Litbuild::LogfileNamer) @bplib = BlueprintLibrary.new(logfile_namer_class: logfile_namer_class) end |
Instance Method Details
#download_urls_for(target:) ⇒ Object
34 35 36 37 38 |
# File 'lib/litbuild/driver.rb', line 34 def download_urls_for(target:) uv = UrlVisitor.new dispatch(visitor: uv, target: target) uv.urls end |
#library ⇒ Object
26 27 28 |
# File 'lib/litbuild/driver.rb', line 26 def library @bplib end |
#params ⇒ Object
30 31 32 |
# File 'lib/litbuild/driver.rb', line 30 def params @bplib.parameters end |
#source_files_for(target:) ⇒ Object
40 41 42 43 44 |
# 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:) ⇒ Object
53 54 55 56 57 58 |
# 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:) ⇒ Object
46 47 48 49 50 51 |
# 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 |