Class: Docbook::Output::LibraryBuilder
- Inherits:
-
Object
- Object
- Docbook::Output::LibraryBuilder
- Defined in:
- lib/docbook/output/library_builder.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(input_path:, output_path:, format: :inline, **options) ⇒ LibraryBuilder
constructor
A new instance of LibraryBuilder.
Constructor Details
#initialize(input_path:, output_path:, format: :inline, **options) ⇒ LibraryBuilder
Returns a new instance of LibraryBuilder.
8 9 10 11 12 13 |
# File 'lib/docbook/output/library_builder.rb', line 8 def initialize(input_path:, output_path:, format: :inline, **) @input_path = input_path @output_path = output_path @format = format @options = end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
6 7 8 |
# File 'lib/docbook/output/library_builder.rb', line 6 def format @format end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
6 7 8 |
# File 'lib/docbook/output/library_builder.rb', line 6 def input_path @input_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/docbook/output/library_builder.rb', line 6 def @options end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
6 7 8 |
# File 'lib/docbook/output/library_builder.rb', line 6 def output_path @output_path end |
Instance Method Details
#build ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/docbook/output/library_builder.rb', line 15 def build manifest_resolver = Services::CollectionManifestResolver.new(@input_path) manifest = manifest_resolver.resolve if manifest.books.empty? raise ArgumentError, "No DocBook XML files found in #{@input_path}" end guides = manifest.books.map do |book| Pipeline.new( xml_path: book.source, image_strategy: @options[:image_strategy] || :data_url, image_search_dirs: @options[:image_search_dirs], sort_glossary: @options[:sort_glossary] || false, title: book.title || File.basename(book.source, ".*"), ).process end format_class = Formats::FORMAT_MAP[@format] raise ArgumentError, "Unknown format: #{@format}" unless format_class formatter = format_class.new(dist_dir: @options[:dist_dir]) formatter.write_library(@output_path, guides, manifest: manifest, title: @options[:title]) @output_path end |