Class: GHPreview::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ghpreview/watcher.rb

Class Method Summary collapse

Class Method Details

.watch(filepath) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ghpreview/watcher.rb', line 5

def self.watch(filepath)
  yield

  filename = File.basename(filepath)
  dirname  = File.dirname(File.expand_path(filepath))

  Listen.to(dirname, filter: /#{filename}$/) do |modified|
    yield
  end
end