Class: ArchitectureJS::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/architecture-js/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Watcher

Returns a new instance of Watcher.



6
7
8
9
10
11
12
13
14
# File 'lib/architecture-js/watcher.rb', line 6

def initialize(project)
  @project = project
  @listener = Listen.to(@project.root) do |modified, added, removed|
    update_files(modified, "modified") if modified.length > 0
    update_files(added, "added") if added.length > 0
    update_files(removed, "deleted") if removed.length > 0
  end
  @listener.ignore(/#{@project.config[:build_dir]}/)
end

Instance Attribute Details

#listenerObject

Returns the value of attribute listener.



4
5
6
# File 'lib/architecture-js/watcher.rb', line 4

def listener
  @listener
end

#projectObject

Returns the value of attribute project.



4
5
6
# File 'lib/architecture-js/watcher.rb', line 4

def project
  @project
end

Instance Method Details

#stopObject



22
23
24
# File 'lib/architecture-js/watcher.rb', line 22

def stop
  @listener.stop
end

#watch(message = false) ⇒ Object



16
17
18
19
20
# File 'lib/architecture-js/watcher.rb', line 16

def watch(message = false)
  @listener.start
  puts ArchitectureJS::Notification.log message if message
  self
end