Class: Entangler::Executor::Base

Inherits:
Object
  • Object
show all
Includes:
Entangler::Executor::Background::Base, Validation::Base
Defined in:
lib/entangler/executor/base.rb

Direct Known Subclasses

Master, Slave

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, opts = {}) ⇒ Base



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/entangler/executor/base.rb', line 16

def initialize(base_dir, opts = {})
  validate_base_dir(base_dir)
  @base_dir = File.realpath(File.expand_path(base_dir))
  @recently_received_paths = []
  @listener_pauses = [false, false]
  @opts = opts
  @opts[:ignore] = [%r{^\.git(?:/[^/]+)*$}] unless @opts.key?(:ignore)
  @opts[:ignore] << /^\.entangler.*/

  validate_opts
  Entangler::Logger.create_log_dir(base_dir)
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



14
15
16
# File 'lib/entangler/executor/base.rb', line 14

def base_dir
  @base_dir
end

Instance Method Details

#generate_abs_path(rel_path) ⇒ Object



29
30
31
# File 'lib/entangler/executor/base.rb', line 29

def generate_abs_path(rel_path)
  File.join(base_dir, rel_path)
end

#runObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/entangler/executor/base.rb', line 37

def run
  logger.info("Entangler v#{Entangler::VERSION}")
  start_listener
  start_remote_io
  Signal.trap('INT') { kill_off_threads }
  logger.info('Ready!')
  wait_for_threads
ensure
  stop_listener
  logger.info('Stopping Entangler')
end

#strip_base_path(path, base_dir = self.base_dir) ⇒ Object



33
34
35
# File 'lib/entangler/executor/base.rb', line 33

def strip_base_path(path, base_dir = self.base_dir)
  File.expand_path(path).sub(base_dir, '')
end