class Blogdoor::Watcher

Attributes

builder[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/blogdoor/watcher.rb, line 12
def initialize(args = {})
  @root_path = Pathname.new(args[:root_path] || ".")
end

Public Instance Methods

start() click to toggle source
# File lib/blogdoor/watcher.rb, line 16
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