Class: Pith::Watcher

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

Constant Summary collapse

DEFAULT_INTERVAL =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, options = {}) ⇒ Watcher

Returns a new instance of Watcher.



7
8
9
10
11
12
13
# File 'lib/pith/watcher.rb', line 7

def initialize(project, options = {})
  @project = project
  @interval = DEFAULT_INTERVAL
  options.each do |k,v|
    send("#{k}=", v)
  end
end

Instance Attribute Details

#intervalObject

Returns the value of attribute interval.



16
17
18
# File 'lib/pith/watcher.rb', line 16

def interval
  @interval
end

#projectObject

Returns the value of attribute project.



15
16
17
# File 'lib/pith/watcher.rb', line 15

def project
  @project
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/pith/watcher.rb', line 18

def call
  loop do
    begin
      project.build
      sleep(interval)
    rescue Interrupt
      break
    end
  end
end