Class: Fontcustom::Watcher
- Inherits:
-
Object
- Object
- Fontcustom::Watcher
- Defined in:
- lib/fontcustom/watcher.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ Watcher
constructor
A new instance of Watcher.
- #stop ⇒ Object
- #watch ⇒ Object
Constructor Details
#initialize(opts) ⇒ Watcher
Returns a new instance of Watcher.
6 7 8 9 10 11 |
# File 'lib/fontcustom/watcher.rb', line 6 def initialize(opts) @opts = opts @listener = Listen.to(@opts[:input]).relative_paths(true).filter(/\.(eps|svg)$/).change(&callback) @opts[:blocking] = @opts[:blocking] == false ? false : true @listener = @listener.(false) unless @opts[:blocking] end |
Instance Method Details
#stop ⇒ Object
32 33 34 35 36 |
# File 'lib/fontcustom/watcher.rb', line 32 def stop # Adding a newline so message is not prepended with ^C on SIGTERM puts "\nFont Custom is signing off. Good night and good luck." @listener.stop end |
#watch ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fontcustom/watcher.rb', line 13 def watch puts "Font Custom is watching your icons at #{@opts[:input]}. Press Ctrl + C to stop." compile unless @opts[:skip_first] if @opts[:blocking] @listener.start! else @listener.start end rescue Fontcustom::Error => e show_error e # Catches Ctrl + C # TODO Does the listen gem have a better way of handling this? rescue SignalException stop end |