[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:31:54 UTC 2010


The following commit has been merged in the upstream branch:
commit af9a92086df8fcfbb572eb3d2bc11eee383ef9e4
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Thu Jan 21 22:45:43 2010 -0800

    Adding an environment helper
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index 537a5dd..7041744 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -7,6 +7,20 @@ end
 # Model the environment that a node can operate in.  This class just
 # provides a simple wrapper for the functionality around environments.
 class Puppet::Node::Environment
+    module Helper
+        def environment
+            Puppet::Node::Environment.new(@environment)
+        end
+
+        def environment=(env)
+            if env.is_a?(String) or env.is_a?(Symbol)
+                @environment = env
+            else
+                @environment = env.name
+            end
+        end
+    end
+
     include Puppet::Util::Cacher
 
     @seen = {}
diff --git a/spec/unit/node/environment.rb b/spec/unit/node/environment.rb
index 8198197..8945f28 100755
--- a/spec/unit/node/environment.rb
+++ b/spec/unit/node/environment.rb
@@ -216,4 +216,28 @@ describe Puppet::Node::Environment do
             end
         end
     end
+
+    describe Puppet::Node::Environment::Helper do
+        before do
+            @helper = Object.new
+            @helper.extend(Puppet::Node::Environment::Helper)
+        end
+
+        it "should be able to set and retrieve the environment" do
+            @helper.environment = :foo
+            @helper.environment.name.should == :foo
+        end
+
+        it "should accept an environment directly" do
+            env = Puppet::Node::Environment.new :foo
+            @helper.environment = env
+            @helper.environment.name.should == :foo
+        end
+
+        it "should accept an environment as a string" do
+            env = Puppet::Node::Environment.new "foo"
+            @helper.environment = env
+            @helper.environment.name.should == :foo
+        end
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list