From: Brice Figureau <[email protected]>

we already offer read access for the yaml, this changeset adds
the destroy handler which only removes the yaml file for
a request. This can be used to remove cached entries.

Signed-off-by: Brice Figureau <[email protected]>
Signed-off-by: Peter Meier <[email protected]>
---
 lib/puppet/indirector/yaml.rb     |    4 ++++
 spec/unit/indirector/yaml_spec.rb |   14 ++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 23997e9..46fdc24 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -47,6 +47,10 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
     File.join(base, self.class.indirection_name.to_s, name.to_s + ext)
   end
 
+  def destroy(request)
+    File.unlink(path(request.key))
+  end
+
   def search(request)
     Dir.glob(path(request.key,'')).collect do |file|
       YAML.load_file(file)
diff --git a/spec/unit/indirector/yaml_spec.rb 
b/spec/unit/indirector/yaml_spec.rb
index 86c13c5..605385e 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -154,5 +154,19 @@ describe Puppet::Indirector::Yaml, " when choosing file 
location" do
       Dir.expects(:glob).with(:glob).returns []
       @store.search(@request).should == []
     end
+
+
+    describe Puppet::Indirector::Yaml, " when destroying" do
+      it "should unlink the right yaml file" do
+        @request = stub 'request', :key => "one*", :instance => @subject
+        @one = mock 'one'
+        @store.stubs(:base).returns "/my/yaml/dir"
+
+        File.expects(:unlink).with(File.join("/my/yaml/dir", 
@store.class.indirection_name.to_s, @request.key + ".yaml"))
+
+        @store.destroy(@request)
+      end
+    end
+
   end
 end
-- 
1.7.2.3

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