summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-07-21 11:40:00 -0700
committerNick Lewis <nick@puppetlabs.com>2011-07-21 20:10:12 -0700
commitbdcb9be3b5d7cd54548cbeb7b13bee6fe4e730f7 (patch)
tree9a07db475ff12c99e74aeeded6aff92bdf30feed
parentfac867c7bdbfbd431b089eb1bfb6eb73230e912c (diff)
downloadpuppet-bdcb9be3b5d7cd54548cbeb7b13bee6fe4e730f7.tar.gz
puppet-bdcb9be3b5d7cd54548cbeb7b13bee6fe4e730f7.tar.xz
puppet-bdcb9be3b5d7cd54548cbeb7b13bee6fe4e730f7.zip
Remove Puppet::Util::Cacher usage from Puppet::Util::Settings
The path attribute was being unnecessarily cached. The value is a LoadedFile instance, which already knows how to check whether it needs to be reloaded. The act of reparsing was being triggered separately from the cacher mechanism. The comment indicated this value was only being cached so it could be easily cleared for tests, but it wasn't being cleared for tests. Thus, there is no reason for this attribute to be cached, so remove it. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
-rw-r--r--lib/puppet/util/settings.rb9
-rwxr-xr-xspec/unit/util/settings_spec.rb10
2 files changed, 3 insertions, 16 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 4559e9af3..caaf61b7b 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -2,13 +2,11 @@ require 'puppet'
require 'sync'
require 'getoptlong'
require 'puppet/external/event-loop'
-require 'puppet/util/cacher'
require 'puppet/util/loadedfile'
# The class for handling configuration files.
class Puppet::Util::Settings
include Enumerable
- include Puppet::Util::Cacher
require 'puppet/util/settings/setting'
require 'puppet/util/settings/file_setting'
@@ -401,11 +399,10 @@ class Puppet::Util::Settings
}
end
- # Cache this in an easily clearable way, since we were
- # having trouble cleaning it up after tests.
- cached_attr(:file) do
+ def file
+ return @file if @file
if path = self[:config] and FileTest.exist?(path)
- Puppet::Util::LoadedFile.new(path)
+ @file = Puppet::Util::LoadedFile.new(path)
end
end
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index f7cb19936..76f229c0f 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -606,16 +606,6 @@ describe Puppet::Util::Settings do
@settings.reparse
end
- it "should use a cached LoadedFile instance" do
- first = mock 'first'
- second = mock 'second'
- Puppet::Util::LoadedFile.expects(:new).times(2).with("/test/file").returns(first).then.returns(second)
-
- @settings.file.should equal(first)
- Puppet::Util::Cacher.expire
- @settings.file.should equal(second)
- end
-
it "should replace in-memory values with on-file values" do
# Init the value
text = "[main]\none = disk-init\n"