Class: Bashly::Watch
- Inherits:
-
Object
- Object
- Bashly::Watch
- Defined in:
- lib/bashly/watch.rb
Overview
File system watcher - an ergonomic wrapper around the Listen gem
Constant Summary collapse
- DEFAULT_OPTIONS =
{ force_polling: true, latency: 1.0, }.freeze
Instance Attribute Summary collapse
-
#dirs ⇒ Object
readonly
Returns the value of attribute dirs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(*dirs, **options) ⇒ Watch
constructor
A new instance of Watch.
- #on_change ⇒ Object
Constructor Details
#initialize(*dirs, **options) ⇒ Watch
Returns a new instance of Watch.
13 14 15 16 |
# File 'lib/bashly/watch.rb', line 13 def initialize(*dirs, **) @options = DEFAULT_OPTIONS.merge().freeze @dirs = dirs.empty? ? ['.'] : dirs end |
Instance Attribute Details
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
6 7 8 |
# File 'lib/bashly/watch.rb', line 6 def dirs @dirs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/bashly/watch.rb', line 6 def @options end |
Instance Method Details
#on_change ⇒ Object
18 19 20 21 22 23 |
# File 'lib/bashly/watch.rb', line 18 def on_change(&) start(&) wait ensure stop end |