Class: Peridot::Watcher

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Watcher

Returns a new instance of Watcher.



5
6
7
# File 'lib/peridot/watcher.rb', line 5

def initialize(*args)
  @args = args
end

Instance Method Details

#install!Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/peridot/watcher.rb', line 9

def install!
  puts 'Peridot is watching for changes'
  @listener = ::Listen.to(Dir.pwd.to_s)
  @listener.change do
    @listener.pause
    run_command!
    @listener.unpause
  end
  @listener.start!
end

#run_command!Object



20
21
22
23
24
# File 'lib/peridot/watcher.rb', line 20

def run_command!
  command = @args.unshift('rake').join(' ')
  puts(command)
  system(command)
end