Class: Bookbinder::Commands::Bind
- Inherits:
-
Object
- Object
- Bookbinder::Commands::Bind
- Includes:
- Naming
- Defined in:
- lib/bookbinder/commands/bind.rb
Instance Method Summary collapse
- #command_for?(test_command_name) ⇒ Boolean
- #deprecated_command_for?(command_name) ⇒ Boolean
-
#initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, sitemap_writer: nil, preprocessor: nil, cloner_factory: nil, section_repository: nil, directory_preparer: nil) ⇒ Bind
constructor
A new instance of Bind.
- #run(cli_arguments) ⇒ Object
- #usage ⇒ Object
Methods included from Naming
Constructor Details
#initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, sitemap_writer: nil, preprocessor: nil, cloner_factory: nil, section_repository: nil, directory_preparer: nil) ⇒ Bind
Returns a new instance of Bind.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bookbinder/commands/bind.rb', line 11 def initialize(base_streams, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, middleman_runner: nil, sitemap_writer: 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 @sitemap_writer = sitemap_writer @preprocessor = preprocessor @cloner_factory = cloner_factory @section_repository = section_repository @directory_preparer = directory_preparer end |
Instance Method Details
#command_for?(test_command_name) ⇒ Boolean
41 42 43 |
# File 'lib/bookbinder/commands/bind.rb', line 41 def command_for?(test_command_name) %w(bind publish).include?(test_command_name) end |
#deprecated_command_for?(command_name) ⇒ Boolean
45 46 47 |
# File 'lib/bookbinder/commands/bind.rb', line 45 def deprecated_command_for?(command_name) %w(publish).include?(command_name) end |
#run(cli_arguments) ⇒ Object
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 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/bookbinder/commands/bind.rb', line 49 def run(cli_arguments) = Components::CommandOptions.new(cli_arguments, base_streams).tap(&:validate!) bind_config = config_fetcher.fetch_config cloner = cloner_factory.produce(.local_repo_dir) 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: ., 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", .verbosity].compact.join(" "), streams: .streams, output_locations: output_locations, config: config_decorator.generate(bind_config, sections), local_repo_dir: .local_repo_dir, subnavs: (sections) ) if generation_result.success? file_system_accessor.copy(output_locations.build_dir, output_locations.public_dir) result = sitemap_writer.write( bind_config.public_host, .streams, bind_config.broken_link_exclusions ) .streams[:success].puts "Bookbinder bound your book into #{output_locations.final_app_dir}" result.has_broken_links? ? 1 : 0 else .streams[:err].puts "Your bind failed. Rerun with --verbose to troubleshoot." 1 end end |
#usage ⇒ Object
36 37 38 39 |
# File 'lib/bookbinder/commands/bind.rb', line 36 def usage ["bind <local|remote> [--verbose] [--dita-flags=\\\"<dita-option>=<value>\\\"]", "Bind the sections specified in config.yml from <local> or <remote> into the final_app directory"] end |