Class: Filewatcher::CLI::SpecHelper::ShellWatchRun
- Inherits:
-
Object
- Object
- Filewatcher::CLI::SpecHelper::ShellWatchRun
- Includes:
- Filewatcher::CLI::SpecHelper, SpecHelper::WatchRun
- Defined in:
- lib/filewatcher/cli/spec_helper/shell_watch_run.rb
Overview
Watch runner for calls from shell
Constant Summary collapse
- EXECUTABLE =
"#{'ruby ' if Gem.win_platform?}#{executable_path}"
- DUMP_FILE =
File.join(TMP_DIR, 'dump')
Constants included from Filewatcher::CLI::SpecHelper
ENVIRONMENT_SPECS_COEFFICIENTS
Instance Method Summary collapse
-
#initialize(watch_path, options:, dumper:, dumper_args:, **rest_args) ⇒ ShellWatchRun
constructor
A new instance of ShellWatchRun.
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Filewatcher::CLI::SpecHelper
#environment_specs_coefficients
Constructor Details
#initialize(watch_path, options:, dumper:, dumper_args:, **rest_args) ⇒ ShellWatchRun
Returns a new instance of ShellWatchRun.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/filewatcher/cli/spec_helper/shell_watch_run.rb', line 19 def initialize(watch_path, options:, dumper:, dumper_args:, **rest_args) super(**rest_args) @watch_path = watch_path @options = @options[:interval] ||= 0.2 debug "options = #{}" @dumper = dumper debug "dumper = #{@dumper}" @dumper_args = dumper_args.join(' ') end |
Instance Method Details
#start ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/filewatcher/cli/spec_helper/shell_watch_run.rb', line 31 def start super spawn_filewatcher wait wait seconds: 3 do debug "pid state = #{pid_state.inspect}" dump_file_exists = File.exist?(DUMP_FILE) debug "#{__method__}: File.exist?(DUMP_FILE) = #{dump_file_exists}" pid_ready? && (!@options[:immediate] || dump_file_exists) end ## Dump file can exists with `--immediate` option, but Filewatcher can not have time ## to initialize `@last_snapshot` in main cycle. wait end |
#stop ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/filewatcher/cli/spec_helper/shell_watch_run.rb', line 50 def stop kill_filewatcher wait do pid_state.nil? end super end |