[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:17 UTC 2009


The following commit has been merged in the master branch:
commit 0b1e60f69a03e6525e1a9eefd748c59b4fc5261c
Author: Luke Kanies <luke at madstop.com>
Date:   Mon Oct 6 19:06:21 2008 -0500

    Adding an array indexer method to Puppet::Util::Metric as requested in #1633.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb
index 722277e..e6d7678 100644
--- a/lib/puppet/util/metric.rb
+++ b/lib/puppet/util/metric.rb
@@ -14,6 +14,15 @@ class Puppet::Util::Metric
 
     attr_writer :basedir
 
+    # Return a specific value
+    def [](name)
+        if value = @values.find { |v| v[0] == name }
+            return value[2]
+        else
+            return nil
+        end
+    end
+
     def basedir
         if defined? @basedir
             @basedir
diff --git a/spec/unit/util/metric.rb b/spec/unit/util/metric.rb
index 7aa0448..3501aac 100755
--- a/spec/unit/util/metric.rb
+++ b/spec/unit/util/metric.rb
@@ -75,6 +75,15 @@ describe Puppet::Util::Metric do
         @metric.values.should == [[:bar, "a", 10], [:foo, "b", 10]]
     end
 
+    it "should use an array indexer method to retrieve individual values" do
+        @metric.newvalue(:foo, 10)
+        @metric[:foo].should == 10
+    end
+
+    it "should return nil if the named value cannot be found" do
+        @metric[:foo].should be_nil
+    end
+
     # LAK: I'm not taking the time to develop these tests right now.
     # I expect they should actually be extracted into a separate class
     # anyway.

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list