Class: Guard::Internals::Queue
- Inherits:
-
Object
- Object
- Guard::Internals::Queue
- Defined in:
- lib/guard/internals/queue.rb
Instance Method Summary collapse
- #<<(changes) ⇒ Object
-
#initialize(commander) ⇒ Queue
constructor
A new instance of Queue.
- #pending? ⇒ Boolean
-
#process ⇒ Object
Process the change queue, running tasks within the main Guard thread.
Constructor Details
#initialize(commander) ⇒ Queue
Returns a new instance of Queue.
4 5 6 7 |
# File 'lib/guard/internals/queue.rb', line 4 def initialize(commander) @commander = commander @queue = ::Queue.new end |
Instance Method Details
#<<(changes) ⇒ Object
31 32 33 |
# File 'lib/guard/internals/queue.rb', line 31 def <<(changes) @queue << changes end |
#pending? ⇒ Boolean
27 28 29 |
# File 'lib/guard/internals/queue.rb', line 27 def pending? !@queue.empty? end |
#process ⇒ Object
Process the change queue, running tasks within the main Guard thread
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/guard/internals/queue.rb', line 10 def process actions = [] changes = { modified: [], added: [], removed: [] } while pending? if (item = @queue.pop).first.is_a?(Symbol) actions << item else item.each { |key, value| changes[key] += value } end end _run_actions(actions) return if changes.values.all?(&:empty?) Runner.new.run_on_changes(*changes.values) end |