Class: TOTS::Watcher

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

Overview

File changes watcher

Class Method Summary collapse

Class Method Details

.checkObject



10
11
12
13
14
15
16
# File 'lib/tots/watcher.rb', line 10

def self.check
  return if ! @paths

  TOTS::Printer.watching(true)

  setup; @watching = true if !@watching
end

.setupObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tots/watcher.rb', line 18

def self.setup
  require 'rb-fsevent'

  fsevent = FSEvent.new
  fsevent.watch Dir.pwd do |directories|
    TOTS::Printer.watching(false)

    puts "Detected change inside: #{directories.inspect}\n"

    TOTS::Runner.start
  end

  fsevent.run
end

.watch(paths) ⇒ Object



6
7
8
# File 'lib/tots/watcher.rb', line 6

def self.watch(paths)
  @paths = paths
end