Class: Tripwire::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/tripwire/runner.rb

Constant Summary collapse

GEM_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/tripwire/runner.rb', line 7

def command
  @command
end

#delayObject

Returns the value of attribute delay.



8
9
10
# File 'lib/tripwire/runner.rb', line 8

def delay
  @delay
end

#interruptedObject

Returns the value of attribute interrupted.



10
11
12
# File 'lib/tripwire/runner.rb', line 10

def interrupted
  @interrupted
end

#scannerObject

Returns the value of attribute scanner.



6
7
8
# File 'lib/tripwire/runner.rb', line 6

def scanner
  @scanner
end

Instance Method Details

#run!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tripwire/runner.rb', line 12

def run!
  raise "No command specified.  Please specify a command to run." if !command
  raise "No files/folders specified.  Please specify files/patterns to scan." if scanner.scan_patterns.empty?
  original_quiet = scanner.quiet
  scanner.quiet = true
  scanner.scan # do this because we don't care about the initial updates collection
  scanner.quiet = original_quiet

  add_sigint_handler

  loop do
    begin
      `cd '#{Dir.pwd}'; #{File.join(GEM_PATH, 'bin', 'fsevent_sleep')} . 2>&1`
    rescue
      sleep delay
    end
    system(command) unless scanner.scan.empty?
  end  
end