This is for file, line, version, and tags, with the
parameter name added to the tags.

This is mostly so logs generated by the parameters
work better.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/parameter.rb |   19 +++++++++++++++++++
 lib/puppet/property.rb  |   13 -------------
 spec/unit/parameter.rb  |   16 +++++++++++++++-
 spec/unit/property.rb   |    5 -----
 4 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index c594ed5..f408667 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -359,6 +359,12 @@ class Puppet::Parameter
     # LAK 2007-05-09: Keep the @parent around for backward compatibility.
     attr_accessor :parent
 
+    [:line, :file, :version].each do |param|
+        define_method(param) do
+            resource.send(param)
+        end
+    end
+
     def devfail(msg)
         self.fail(Puppet::DevError, msg)
     end
@@ -513,6 +519,19 @@ class Puppet::Parameter
         @resource.provider
     end
 
+    # The properties need to return tags so that logs correctly collect them.
+    def tags
+        unless defined? @tags
+            @tags = []
+            # This might not be true in testing
+            if @resource.respond_to? :tags
+                @tags = @resource.tags
+            end
+            @tags << self.name.to_s
+        end
+        @tags
+    end
+
     def to_s
         s = "Parameter(%s)" % self.name
     end
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 487028e..1ed323f 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -370,19 +370,6 @@ class Puppet::Property < Puppet::Parameter
         end
     end
 
-    # The properties need to return tags so that logs correctly collect them.
-    def tags
-        unless defined? @tags
-            @tags = []
-            # This might not be true in testing
-            if @resource.respond_to? :tags
-                @tags = @resource.tags
-            end
-            @tags << self.name.to_s
-        end
-        @tags
-    end
-
     def to_s
         return "%s(%s)" % [[email protected],self.name]
     end
diff --git a/spec/unit/parameter.rb b/spec/unit/parameter.rb
index 42d3103..0548346 100755
--- a/spec/unit/parameter.rb
+++ b/spec/unit/parameter.rb
@@ -6,7 +6,9 @@ require 'puppet/parameter'
 
 describe Puppet::Parameter do
     before do
-        @class = Class.new(Puppet::Parameter)
+        @class = Class.new(Puppet::Parameter) do
+            @name = :foo
+        end
         @class.initvars
         @resource = mock 'resource'
         @resource.stub_everything
@@ -30,6 +32,18 @@ describe Puppet::Parameter do
         @parameter.expirer.should equal(catalog)
     end
 
+    [:line, :file, :version].each do |data|
+        it "should return its resource's #{data} as its #{data}" do
+            @resource.expects(data).returns "foo"
+            @parameter.send(data).should == "foo"
+        end
+    end
+
+    it "should return the resource's tags plus its name as its tags" do
+        @resource.expects(:tags).returns %w{one two}
+        @parameter.tags.should == %w{one two foo}
+    end
+
     describe "when returning the value" do
         it "should return nil if no value is set" do
             @parameter.value.should be_nil
diff --git a/spec/unit/property.rb b/spec/unit/property.rb
index f09549d..07ab9c3 100755
--- a/spec/unit/property.rb
+++ b/spec/unit/property.rb
@@ -30,11 +30,6 @@ describe Puppet::Property do
         @class.value_option(:foo, :event).should == :whatever
     end
 
-    it "should return the resource's tags plus its name as its tags" do
-        @resource.expects(:tags).returns %w{one two}
-        @property.tags.should == %w{one two foo}
-    end
-
     it "should be able to specify required features" do
         @class.should respond_to(:required_features=)
     end
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to