summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving/content.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-22 22:33:06 -0500
committerLuke Kanies <luke@madstop.com>2007-10-22 22:33:06 -0500
commit7fa99b08f9aa3777fba82f24eb5bb391f3758f48 (patch)
treea9dc23c0cdf3ecbc4a177086a5c699ad4f3b00f2 /lib/puppet/file_serving/content.rb
parent688fcdf11a685dfda297beff50de8d4c751494d9 (diff)
downloadpuppet-7fa99b08f9aa3777fba82f24eb5bb391f3758f48.tar.gz
puppet-7fa99b08f9aa3777fba82f24eb5bb391f3758f48.tar.xz
puppet-7fa99b08f9aa3777fba82f24eb5bb391f3758f48.zip
Link handling is now in the file serving classes.
This was done by putting all of the functionality in the Content and Metadata class (actually, in a new base class for them). There are still some issues, and there need to be integration tests between the :local (soon to be renamed :file) termini for these classes.
Diffstat (limited to 'lib/puppet/file_serving/content.rb')
-rw-r--r--lib/puppet/file_serving/content.rb18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb
index 38ca80fb0..3cb428e63 100644
--- a/lib/puppet/file_serving/content.rb
+++ b/lib/puppet/file_serving/content.rb
@@ -4,30 +4,28 @@
require 'puppet/indirector'
require 'puppet/file_serving'
+require 'puppet/file_serving/file_base'
require 'puppet/file_serving/terminus_selector'
# A class that handles retrieving file contents.
# It only reads the file when its content is specifically
# asked for.
-class Puppet::FileServing::Content
+class Puppet::FileServing::Content < Puppet::FileServing::FileBase
extend Puppet::Indirector
indirects :file_content, :extend => Puppet::FileServing::TerminusSelector
attr_reader :path
- def content
- ::File.read(@path)
- end
-
- def initialize(path)
- raise ArgumentError.new("Files must be fully qualified") unless path =~ /^#{::File::SEPARATOR}/
- raise ArgumentError.new("Files must exist") unless FileTest.exists?(path)
+ # Read the content of our file in.
+ def content(base = nil)
+ # This stat can raise an exception, too.
+ raise(ArgumentError, "Cannot read the contents of links unless following links") if stat(base).ftype == "symlink"
- @path = path
+ ::File.read(full_path(base))
end
# Just return the file contents as the yaml. This allows us to
- # avoid escaping or any such thing. LAK:FIXME Not really sure how
+ # avoid escaping or any such thing. LAK:NOTE Not really sure how
# this will behave if the file contains yaml... I think the far
# side needs to understand that it's a plain string.
def to_yaml