Class: Bookbinder::Commands::Bind
- Inherits:
-
Object
- Object
- Bookbinder::Commands::Bind
- Defined in:
- lib/bookbinder/commands/bind.rb
Instance Method Summary collapse
-
#initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, link_checker: nil, preprocessor: nil, cloner_factory: nil, section_repository: nil, directory_preparer: nil) ⇒ Bind
constructor
A new instance of Bind.
- #run(bind_type, verbose = false, dita_flags = nil, require_valid_subnav_links = false, proof = false) ⇒ Object
Constructor Details
#initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, link_checker: nil, preprocessor: nil, cloner_factory: nil, section_repository: nil, directory_preparer: nil) ⇒ Bind
Returns a new instance of Bind.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bookbinder/commands/bind.rb', line 8 def initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, link_checker: nil, preprocessor: nil, cloner_factory: nil, section_repository: nil, directory_preparer: nil) @base_streams = base_streams @output_locations = output_locations @config_fetcher = config_fetcher @config_decorator = config_decorator @file_system_accessor = file_system_accessor @middleman_runner = middleman_runner @link_checker = link_checker @preprocessor = preprocessor @cloner_factory = cloner_factory @section_repository = section_repository @directory_preparer = directory_preparer end |
Instance Method Details
#run(bind_type, verbose = false, dita_flags = nil, require_valid_subnav_links = false, proof = false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bookbinder/commands/bind.rb', line 33 def run(bind_type, verbose = false, dita_flags = nil, = false, proof = false) = Components::CommandOptions.new([bind_type], base_streams, verbose) bind_config = config_fetcher.fetch_config cloner = cloner_factory.produce(.local_repo_dir) = true unless bind_type == 'local' directory_preparer.prepare_directories( bind_config, File.('../../../../', __FILE__), output_locations, cloner, ref_override: .ref_override ) sections = section_repository.fetch( configured_sections: bind_config.sections, destination_dir: output_locations.cloned_preprocessing_dir, ref_override: .ref_override, cloner: cloner, streams: base_streams ) preprocessor.preprocess( sections, output_locations, options: { dita_flags: dita_flags, require_valid_subnav_links: }, output_streams: .streams, config: bind_config ) if file_system_accessor.file_exist?('redirects.rb') file_system_accessor.copy('redirects.rb', output_locations.final_app_dir) end generation_result = middleman_runner.run( 'build --verbose', streams: .streams, output_locations: output_locations, config: config_decorator.generate(bind_config, sections), local_repo_dir: .local_repo_dir, subnavs: (sections), product_info: product_infos(sections), proof: proof ) if generation_result.success? file_system_accessor.copy(output_locations.build_dir, output_locations.public_dir) link_checker.check!(bind_config.broken_link_exclusions) .streams[:success].puts "Bookbinder bound your book into #{output_locations.final_app_dir}" link_checker.has_errors? ? 1 : 0 else .streams[:err].puts "Your bind failed. Rerun with --verbose to troubleshoot." 1 end end |