summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-08-26 12:53:44 -0500
committerLuke Kanies <luke@madstop.com>2007-08-26 12:53:44 -0500
commit4e9c63181f4c3912e48ddd97782f07b89826d9fd (patch)
tree2d50bc8dd123505aee24e48eca55d49dfc9a4d1c /lib
parenta8f2a33c7e9c0efb12093338179f004298dbcbde (diff)
downloadpuppet-4e9c63181f4c3912e48ddd97782f07b89826d9fd.tar.gz
puppet-4e9c63181f4c3912e48ddd97782f07b89826d9fd.tar.xz
puppet-4e9c63181f4c3912e48ddd97782f07b89826d9fd.zip
Moving the node tests to rspec, and cleaning up the spec of the node, especially WRT the environment.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/node.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index 3bbbe5979..e23472ebf 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -1,7 +1,24 @@
# A simplistic class for managing the node information itself.
class Puppet::Node
- attr_accessor :name, :classes, :parameters, :environment, :source, :ipaddress, :names
+ attr_accessor :name, :classes, :parameters, :source, :ipaddress, :names
attr_reader :time
+ attr_writer :environment
+
+ # Do not return environments tha are empty string, and use
+ # explicitly set environments, then facts, then a central env
+ # value.
+ def environment
+ unless @environment and @environment != ""
+ if env = parameters["environment"] and env != ""
+ @environment = env
+ elsif env = Puppet[:environment] and env != ""
+ @environment = env
+ else
+ @environment = nil
+ end
+ end
+ @environment
+ end
def initialize(name, options = {})
@name = name
@@ -21,11 +38,7 @@ class Puppet::Node
@parameters = options[:parameters] || {}
- unless @environment = options[:environment]
- if env = Puppet[:environment] and env != ""
- @environment = env
- end
- end
+ @environment = options[:environment]
@time = Time.now
end