Class: RailsDevelopmentBoost::Async::Reactor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_development_boost/async/reactor.rb

Direct Known Subclasses

Darwin, Linux, Windows

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



42
43
44
45
# File 'lib/rails_development_boost/async/reactor.rb', line 42

def initialize
  @watcher     = create_watcher
  @directories = Set.new
end

Class Method Details

.usable?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/rails_development_boost/async/reactor.rb', line 79

def usable?
  gem_check! if platform_match?
end

Instance Method Details

#alive_and_watching?(directories) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/rails_development_boost/async/reactor.rb', line 61

def alive_and_watching?(directories)
  @thread.alive? && directories.all? {|directory| @directories.include?(directory)}
end

#start!Object



52
53
54
# File 'lib/rails_development_boost/async/reactor.rb', line 52

def start!
  @thread = Thread.new { start_watcher! }
end

#stopObject



56
57
58
59
# File 'lib/rails_development_boost/async/reactor.rb', line 56

def stop
  @watcher.stop
  stop_thread
end

#watch(directories, &block) ⇒ Object



47
48
49
50
# File 'lib/rails_development_boost/async/reactor.rb', line 47

def watch(directories, &block)
  @directories.merge(directories)
  watch_internal(directories, &block)
end