Module: Jekyll::Watcher
Instance Method Summary collapse
- #listen_handler(site) ⇒ Object
-
#watch(options, site = nil) ⇒ Object
Returns nothing.
Instance Method Details
#listen_handler(site) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/patches/jekyll_watcher.rb', line 30 def listen_handler(site) proc do |modified, added, removed| t = Time.now c = modified + added + removed n = c.length Jekyll.logger.info("Regenerating:", "#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")} ") relative_paths = c.map { |p| site.in_source_dir(p) } relative_paths.each { |file| Jekyll.logger.info "", file.cyan } process site, t end end |
#watch(options, site = nil) ⇒ Object
Returns nothing.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/patches/jekyll_watcher.rb', line 8 def watch(, site = nil) ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if ["verbose"] site ||= Jekyll::Site.new() listener = build_listener(site, ) listener.start Jekyll.logger.info "Auto-regeneration:", "#{"enabled".green} for #{options["source"]}" unless ["serving"] trap("INT") do listener.stop puts " Halting auto-regeneration." exit 0 end sleep_forever end rescue ThreadError # You pressed Ctrl-C, oh my! end |