Class: Bookbinder::Commands::Watch
- Inherits:
-
Object
- Object
- Bookbinder::Commands::Watch
- Includes:
- Naming
- Defined in:
- lib/bookbinder/commands/watch.rb
Instance Method Summary collapse
-
#initialize(streams, middleman_runner: nil, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, preprocessor: nil, cloner: nil, section_repository: nil, directory_preparer: nil) ⇒ Watch
constructor
A new instance of Watch.
- #run(_) ⇒ Object
- #usage ⇒ Object
Methods included from Naming
#command_for?, #command_type, #flag?
Constructor Details
#initialize(streams, middleman_runner: nil, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, preprocessor: nil, cloner: nil, section_repository: nil, directory_preparer: nil) ⇒ Watch
Returns a new instance of Watch.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bookbinder/commands/watch.rb', line 8 def initialize(streams, middleman_runner: nil, output_locations: nil, config_fetcher: nil, config_decorator: nil, file_system_accessor: nil, preprocessor: nil, cloner: nil, section_repository: nil, directory_preparer: nil) @streams = streams @middleman_runner = middleman_runner @output_locations = output_locations @config_fetcher = config_fetcher @config_decorator = config_decorator @file_system_accessor = file_system_accessor @preprocessor = preprocessor @cloner = cloner @section_repository = section_repository @directory_preparer = directory_preparer end |
Instance Method Details
#run(_) ⇒ Object
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 |
# File 'lib/bookbinder/commands/watch.rb', line 35 def run(_) watch_config = config_fetcher.fetch_config directory_preparer.prepare_directories( watch_config, File.('../../../../', __FILE__), output_locations, cloner ) sections = section_repository.fetch( configured_sections: watch_config.sections, destination_dir: output_locations.cloned_preprocessing_dir, cloner: cloner, streams: streams ) preprocessor.preprocess( sections, output_locations, output_streams: streams, config: watch_config ) if file_system_accessor.file_exist?('redirects.rb') file_system_accessor.copy('redirects.rb', output_locations.final_app_dir) end middleman_runner.run("server --force-polling --latency=5.0", output_locations: output_locations, config: config_decorator.generate(watch_config, sections), local_repo_dir: File.('..'), streams: streams, subnavs: (sections) ).exitstatus end |
#usage ⇒ Object
30 31 32 33 |
# File 'lib/bookbinder/commands/watch.rb', line 30 def usage ["watch", "Bind and serve a local book, watching for changes"] end |