Class: Bashly::Watch

Inherits:
Object
  • Object
show all
Defined in:
lib/bashly/watch.rb

Overview

File system watcher - an ergonomic wrapper around the Listen gem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*dirs, **options) ⇒ Watch

Returns a new instance of Watch.



8
9
10
11
# File 'lib/bashly/watch.rb', line 8

def initialize(*dirs, **options)
  @options = default_options.merge(options).freeze
  @dirs = dirs.empty? ? ['.'] : dirs
end

Instance Attribute Details

#dirsObject (readonly)

Returns the value of attribute dirs.



6
7
8
# File 'lib/bashly/watch.rb', line 6

def dirs
  @dirs
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/bashly/watch.rb', line 6

def options
  @options
end

Instance Method Details

#on_changeObject



13
14
15
16
17
18
# File 'lib/bashly/watch.rb', line 13

def on_change(&)
  start(&)
  wait
ensure
  stop
end