Sha256: 88678e547d9e3f4fa3a5dcb6b7f176681c553df48008041ea4a1e42c2b6bd049
Contents?: true
Size: 553 Bytes
Versions: 5
Compression:
Stored size: 553 Bytes
Contents
require "listen" require "pathname" require "forwardable" module Blogdoor class Watcher extend Forwardable attr_accessor :builder delegate build: :builder def initialize(args = {}) @root_path = Pathname.new(args[:root_path] || ".") end def start listener = Listen.to(@root_path.to_s, only: /\.md$/) do |modified, added| [modified, added].flatten.each do |file_path| build(Pathname.new(file_path)) end end trap(:INT) { listener.stop } listener.start end end end
Version data entries
5 entries across 5 versions & 1 rubygems