Class: RailsDevelopmentBoost::Async::Reactor::Base
- Inherits:
-
Object
- Object
- RailsDevelopmentBoost::Async::Reactor::Base
- Defined in:
- lib/rails_development_boost/async/reactor.rb
Class Method Summary collapse
Instance Method Summary collapse
- #alive_and_watching?(directories) ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #start! ⇒ Object
- #stop ⇒ Object
- #watch(directories, &block) ⇒ Object
Constructor Details
#initialize ⇒ Base
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
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
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 |
#stop ⇒ Object
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 |