Class: Entangler::Executor::Base
- Inherits:
-
Object
- Object
- Entangler::Executor::Base
- Defined in:
- lib/entangler/executor/base.rb
Constant Summary collapse
- GIT_IGNORE_REGEX =
%r{^\.git(?:/[^/]+)*$}.freeze
- ENTANGLER_IGNORE_REGEX =
/^\.entangler.*/.freeze
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
Instance Method Summary collapse
- #generate_abs_path(rel_path) ⇒ Object
-
#initialize(base_dir, opts = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #strip_base_path(path, base_dir = self.base_dir) ⇒ Object
Constructor Details
#initialize(base_dir, opts = {}) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/entangler/executor/base.rb', line 19 def initialize(base_dir, opts = {}) validate_base_dir(base_dir) @base_dir = File.realpath(File.(base_dir)) @recently_received_paths = [] @listener_pauses = [false, false] @opts = opts @opts[:ignore] = [GIT_IGNORE_REGEX] unless @opts.key?(:ignore) @opts[:ignore] << ENTANGLER_IGNORE_REGEX @opts[:force_polling] ||= false validate_opts Entangler::Logger.create_log_dir(base_dir) end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
17 18 19 |
# File 'lib/entangler/executor/base.rb', line 17 def base_dir @base_dir end |
Instance Method Details
#generate_abs_path(rel_path) ⇒ Object
33 34 35 |
# File 'lib/entangler/executor/base.rb', line 33 def generate_abs_path(rel_path) File.join(base_dir, rel_path) end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/entangler/executor/base.rb', line 41 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
37 38 39 |
# File 'lib/entangler/executor/base.rb', line 37 def strip_base_path(path, base_dir = self.base_dir) File.(path).sub(base_dir, '') end |