Sha256: 4a4a9514bb5ec02c32dee4bf815de32f1d3441e9707baf744e87a33a6db24682
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
module Monad module Commands class Build < Command def self.process(options) site = Monad::Site.new(options) self.build(site, options) self.watch(site, options) if options['watch'] end # Private: Build the site from source into destination. # # site - A Monad::Site instance # options - A Hash of options passed to the command # # Returns nothing. def self.build(site, options) source = options['source'] destination = options['destination'] Monad::Logger.info "Source:", source Monad::Logger.info "Destination:", destination print Monad::Logger.formatted_topic "Generating..." self.process_site(site) puts "done." end # Private: Watch for file changes and rebuild the site. # # site - A Monad::Site instance # options - A Hash of options passed to the command # # Returns nothing. def self.watch(site, options) require 'directory_watcher' source = options['source'] destination = options['destination'] Monad::Logger.info "Auto-regeneration:", "enabled" dw = DirectoryWatcher.new(source, :glob => self.globs(source, destination), :pre_load => true) dw.interval = 1 dw.add_observer do |*args| t = Time.now.strftime("%Y-%m-%d %H:%M:%S") print Monad::Logger.formatted_topic("Regenerating:") + "#{args.size} files at #{t} " self.process_site(site) puts "...done." end dw.start unless options['serving'] trap("INT") do puts " Halting auto-regeneration." exit 0 end loop { sleep 1000 } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
monad-0.0.2 | lib/monad/commands/build.rb |
monad-0.0.1 | lib/monad/commands/build.rb |