Class: Bunto::Commands::Build
- Inherits:
-
Bunto::Command
- Object
- Bunto::Command
- Bunto::Commands::Build
- Defined in:
- lib/bunto/commands/build.rb
Class Method Summary collapse
-
.build(site, options) ⇒ Object
Build your Bunto site.
-
.init_with_program(prog) ⇒ Object
Create the Mercenary command for the Bunto CLI for this Command.
-
.process(options) ⇒ Object
Build your bunto site Continuously watch if ‘watch` is set to true in the config.
-
.watch(site, options) ⇒ Object
Private: Watch for file changes and rebuild the site.
Methods inherited from Bunto::Command
add_build_options, configuration_from_options, inherited, process_site, subclasses
Class Method Details
.build(site, options) ⇒ Object
Build your Bunto site.
site - the Bunto::Site instance to build options - A Hash of options passed to the command
Returns nothing.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/bunto/commands/build.rb', line 53 def build(site, ) t = Time.now source = ["source"] destination = ["destination"] incremental = ["incremental"] Bunto.logger.info "Source:", source Bunto.logger.info "Destination:", destination Bunto.logger.info "Incremental build:", (incremental ? "enabled" : "disabled. Enable with --incremental") Bunto.logger.info "Generating..." process_site(site) Bunto.logger.info "", "done in #{(Time.now - t).round(3)} seconds." end |
.init_with_program(prog) ⇒ Object
Create the Mercenary command for the Bunto CLI for this Command
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bunto/commands/build.rb', line 6 def init_with_program(prog) prog.command(:build) do |c| c.syntax "build [options]" c.description "Build your site" c.alias :b (c) c.action do |_, | ["serving"] = false Bunto::Commands::Build.process() end end end |
.process(options) ⇒ Object
Build your bunto site Continuously watch if ‘watch` is set to true in the config.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bunto/commands/build.rb', line 23 def process() # Adjust verbosity quickly Bunto.logger.adjust_verbosity() = () site = Bunto::Site.new() if .fetch("skip_initial_build", false) Bunto.logger.warn "Build Warning:", "Skipping the initial build." \ " This may result in an out-of-date site." else build(site, ) end if .fetch("detach", false) Bunto.logger.info "Auto-regeneration:", "disabled when running server detached." elsif .fetch("watch", false) watch(site, ) else Bunto.logger.info "Auto-regeneration:", "disabled. Use --watch to enable." end end |
.watch(site, options) ⇒ Object
Private: Watch for file changes and rebuild the site.
site - A Bunto::Site instance options - A Hash of options passed to the command
Returns nothing.
73 74 75 76 77 78 79 80 81 |
# File 'lib/bunto/commands/build.rb', line 73 def watch(site, ) External.require_with_graceful_fail "bunto-watch" watch_method = Bunto::Watcher.method(:watch) if watch_method.parameters.size == 1 watch_method.call() else watch_method.call(, site) end end |