summaryrefslogtreecommitdiffstats
path: root/lib/puppet/storage.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-17 07:11:50 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-17 07:11:50 +0000
commit3700b37e2386e7dbaabd90b7ba13c3dce06203d2 (patch)
tree28a691598edd5e56332c0d8e254263fb4fe8a9f4 /lib/puppet/storage.rb
parent92a780a3106f863e442c12897184abbe39fe3310 (diff)
downloadpuppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.tar.gz
puppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.tar.xz
puppet-3700b37e2386e7dbaabd90b7ba13c3dce06203d2.zip
Adding an "ensure" state where appropriate, and significantly reworking the builtin docs.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@832 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/storage.rb')
-rw-r--r--lib/puppet/storage.rb40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
index af59efa19..b174e0183 100644
--- a/lib/puppet/storage.rb
+++ b/lib/puppet/storage.rb
@@ -2,34 +2,32 @@ require 'yaml'
module Puppet
# a class for storing state
- class Storage
- include Singleton
-
- def initialize
- self.class.load
- end
+ class Storage
+ include Singleton
+
+ def initialize
+ self.class.load
+ end
def self.clear
- @@state = nil
+ @@state.clear
Storage.init
end
def self.init
Puppet.debug "Initializing Storage"
- @@state = Hash.new { |hash,key|
- hash[key] = Hash.new(nil)
- }
+ @@state = {}
@@splitchar = "\t"
end
self.init
- def self.load
+ def self.load
if Puppet[:checksumfile].nil?
raise Puppet::DevError, "Somehow the statefile is nil"
end
- unless File.exists?(Puppet[:checksumfile])
+ unless File.exists?(Puppet[:checksumfile])
Puppet.info "Statefile %s does not exist" % Puppet[:checksumfile]
unless defined? @@state and ! @@state.nil?
self.init
@@ -56,16 +54,22 @@ module Puppet
}
#Puppet.debug "Loaded state is %s" % @@state.inspect
- end
+ end
+
+ def self.stateinspect
+ @@state.inspect
+ end
- def self.state(myclass)
+ def self.state(myclass)
unless myclass.is_a? Class
myclass = myclass.class
end
+
+ @@state[myclass.to_s] ||= {}
return @@state[myclass.to_s]
- end
+ end
- def self.store
+ def self.store
unless FileTest.directory?(File.dirname(Puppet[:checksumfile]))
begin
Puppet.recmkdir(File.dirname(Puppet[:checksumfile]))
@@ -95,8 +99,8 @@ module Puppet
# }
#}
}
- end
- end
+ end
+ end
end
# $Id$