[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:30:37 UTC 2010


The following commit has been merged in the upstream branch:
commit 329527f5173d17c9c2b788734033534009efcf04
Author: Luke Kanies <luke at madstop.com>
Date:   Sun Nov 1 13:16:39 2009 -0600

    Changing SimpleGraph.matching_edges to expect one event
    
    It previously worked with multiple, but the only caller
    actually only ever passed one event.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 5e8f5cd..9160394 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -145,21 +145,19 @@ class Puppet::SimpleGraph
 
     # Collect all of the edges that the passed events match.  Returns
     # an array of edges.
-    def matching_edges(events, base = nil)
-        events.collect do |event|
-            source = base || event.source
+    def matching_edges(event, base = nil)
+        source = base || event.resource
 
-            unless vertex?(source)
-                Puppet.warning "Got an event from invalid vertex %s" % source.ref
-                next
-            end
-            # Get all of the edges that this vertex should forward events
-            # to, which is the same thing as saying all edges directly below
-            # This vertex in the graph.
-            adjacent(source, :direction => :out, :type => :edges).find_all do |edge|
-                edge.match?(event.name)
-            end
-        end.compact.flatten
+        unless vertex?(source)
+            Puppet.warning "Got an event from invalid vertex #{source.ref}"
+            return []
+        end
+        # Get all of the edges that this vertex should forward events
+        # to, which is the same thing as saying all edges directly below
+        # This vertex in the graph.
+        adjacent(source, :direction => :out, :type => :edges).find_all do |edge|
+            edge.match?(event.name)
+        end
     end
 
     # Return a reversed version of this graph.
diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb
index 22d6ebe..f8596c7 100755
--- a/spec/unit/simple_graph.rb
+++ b/spec/unit/simple_graph.rb
@@ -34,7 +34,6 @@ describe Puppet::SimpleGraph do
     it "should always put its edges first when printing yaml" do
         @graph = Puppet::SimpleGraph.new
         @graph.add_edge(:one, :two)
-        p @graph.to_yaml_properties
         @graph.to_yaml_properties[0].should == "@edges"
     end
 
@@ -349,8 +348,8 @@ describe Puppet::SimpleGraph do
     describe "when matching edges" do
         before do
             @graph = Puppet::SimpleGraph.new
-            @event = Puppet::Transaction::Event.new(:yay, "a")
-            @none = Puppet::Transaction::Event.new(:NONE, "a")
+            @event = Puppet::Transaction::Event.new(:name => :yay, :resource => "a")
+            @none = Puppet::Transaction::Event.new(:name => :NONE, :resource => "a")
 
             @edges = {}
             @edges["a/b"] = Puppet::Relationship.new("a", "b", {:event => :yay, :callback => :refresh})
@@ -359,16 +358,16 @@ describe Puppet::SimpleGraph do
         end
 
         it "should match edges whose source matches the source of the event" do
-            @graph.matching_edges([@event]).should == [@edges["a/b"]]
+            @graph.matching_edges(@event).should == [@edges["a/b"]]
         end
 
         it "should match always match nothing when the event is :NONE" do
-            @graph.matching_edges([@none]).should be_empty
+            @graph.matching_edges(@none).should be_empty
         end
 
         it "should match multiple edges" do
             @graph.add_edge(@edges["a/c"])
-            edges = @graph.matching_edges([@event])
+            edges = @graph.matching_edges(@event)
             edges.should be_include(@edges["a/b"])
             edges.should be_include(@edges["a/c"])
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list