This is the initial implementation for Puppet::Events::Subscription::Queue,
passing the initial tests.
---
lib/puppet/events/subscription/queue.rb | 14 +++++++++++++-
spec/unit/events/subscription/queue.rb | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
mode change 100644 => 100755 spec/unit/events/subscription/queue.rb
diff --git a/lib/puppet/events/subscription/queue.rb
b/lib/puppet/events/subscription/queue.rb
index af4b534..79356a3 100644
--- a/lib/puppet/events/subscription/queue.rb
+++ b/lib/puppet/events/subscription/queue.rb
@@ -5,13 +5,25 @@ class Puppet::Events::Subscription::Queue <
Puppet::Events::Subscription
@events ||= []
end
+ def callback
+ @callback
+ end
+
+ def callback=(val)
+ @callback = val
+ end
+
def has_events?
events.size > 0
end
def handle_event(event)
+ events << event
end
- def process_events
+ def process_events(&block)
+ while (e = events.shift)
+ block ? block.call(e) : self.callback.call(e)
+ end
end
end
diff --git a/spec/unit/events/subscription/queue.rb
b/spec/unit/events/subscription/queue.rb
old mode 100644
new mode 100755
index 8d2a2b5..688a6ce
--- a/spec/unit/events/subscription/queue.rb
+++ b/spec/unit/events/subscription/queue.rb
@@ -56,7 +56,7 @@ describe Puppet::Events::Subscription::Queue do
it 'should pop the events off the stack along the way' do
@sizes = []
- @subscription.callback = Proc.new {|event| @size <<
@subscription.events.size}
+ @subscription.callback = Proc.new {|event| @sizes <<
@subscription.events.size}
@subscription.process_events
@sizes.should == ([email protected]).to_a.reverse
end
--
1.6.3.3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---