Class: Filewatcher::SpecHelper::RubyWatchRun

Inherits:
Object
  • Object
show all
Includes:
WatchRun
Defined in:
lib/filewatcher/spec_helper/ruby_watch_run.rb

Overview

Ruby API watcher for specs

Constant Summary

Constants included from WatchRun

WatchRun::TMP_DIR, WatchRun::TMP_FILES_DIR

Constants included from Filewatcher::SpecHelper

ENVIRONMENT_SPECS_COEFFICIENTS

Instance Attribute Summary collapse

Attributes included from WatchRun

#initial_files

Instance Method Summary collapse

Methods included from WatchRun

#run

Methods included from Filewatcher::SpecHelper

#debug, #environment_specs_coefficients, #logger, #system_stat, #system_stat_windows, #wait_with_block, #wait_without_block

Constructor Details

#initialize(filewatcher:, **args) ⇒ RubyWatchRun

Returns a new instance of RubyWatchRun.



13
14
15
16
17
18
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 13

def initialize(filewatcher:, **args)
  super(**args)
  @filewatcher = filewatcher

  @mutex = Mutex.new
end

Instance Attribute Details

#filewatcherObject (readonly)

Returns the value of attribute filewatcher.



11
12
13
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 11

def filewatcher
  @filewatcher
end

#processedObject (readonly)

Returns the value of attribute processed.



11
12
13
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 11

def processed
  @processed
end

#threadObject (readonly)

Returns the value of attribute thread.



11
12
13
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 11

def thread
  @thread
end

#watchedObject (readonly)

Returns the value of attribute watched.



11
12
13
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 11

def watched
  @watched
end

Instance Method Details

#startObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 20

def start
  super
  @thread = thread_initialize
  # thread needs a chance to start
  wait seconds: 1
  wait do
    keep_watching = filewatcher.keep_watching
    debug "keep_watching = #{keep_watching}"
    keep_watching
  end
end

#stopObject



32
33
34
35
36
37
38
39
40
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 32

def stop
  thread.exit

  wait do
    thread.stop?
  end

  super
end

#wait(seconds: 1) ⇒ Object



42
43
44
# File 'lib/filewatcher/spec_helper/ruby_watch_run.rb', line 42

def wait(seconds: 1)
  super seconds: seconds, interval: filewatcher.interval
end