diff options
author | Luke Kanies <luke@madstop.com> | 2008-08-24 14:42:48 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-08-26 22:40:41 -0700 |
commit | 8ea25efd90b4d2281db12076cbaab3f766cac8b4 (patch) | |
tree | 3dcd4eedbb8c3a7118927fa2581375975cfdbc22 /lib/puppet/file_serving | |
parent | 550e3d6ad5aadfe99fc1e10efa77cc193d3a9df3 (diff) | |
download | puppet-8ea25efd90b4d2281db12076cbaab3f766cac8b4.tar.gz puppet-8ea25efd90b4d2281db12076cbaab3f766cac8b4.tar.xz puppet-8ea25efd90b4d2281db12076cbaab3f766cac8b4.zip |
Refactoring how files in FileServing are named.
Previously, they retained some concept of the URI used to
find them, and this uri was the primary key
for the FileServing instances. This key was unfortunately
completely useless, as evidenced by the fact that it was never
used except to test that it worked.
I've modified the FileServing instances (through modifying
the Base class) to use their local path as their key, and they
no longer care about the URI at all.
This commit is mostly about fixing the code that interacts with
the instances to use this new API.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/file_serving')
-rw-r--r-- | lib/puppet/file_serving/base.rb | 8 | ||||
-rw-r--r-- | lib/puppet/file_serving/content.rb | 1 | ||||
-rw-r--r-- | lib/puppet/file_serving/terminus_helper.rb | 2 |
3 files changed, 3 insertions, 8 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 1cfd0bc4c..94e337b99 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -7,8 +7,6 @@ require 'puppet/file_serving' # The base class for Content and Metadata; provides common # functionality like the behaviour around links. class Puppet::FileServing::Base - attr_accessor :key - # Does our file exist? def exist? begin @@ -21,8 +19,6 @@ class Puppet::FileServing::Base # Return the full path to our file. Fails if there's no path set. def full_path - raise(ArgumentError, "You must set a path to get a file's path") unless self.path - if relative_path.nil? or relative_path == "" path else @@ -30,8 +26,8 @@ class Puppet::FileServing::Base end end - def initialize(key, options = {}) - @key = key + def initialize(path, options = {}) + self.path = path @links = :manage options.each do |param, value| diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 64f000eaa..f13fcaa72 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -25,7 +25,6 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base # This stat can raise an exception, too. raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink" - p full_path @content = ::File.read(full_path()) end @content diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index e5da0e29f..bde0bd389 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -11,7 +11,7 @@ module Puppet::FileServing::TerminusHelper def path2instances(request, path) args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = request.options[param] if request.options[param]; hash } Puppet::FileServing::Fileset.new(path, args).files.collect do |file| - inst = model.new(File.join(request.key, file), :path => path, :relative_path => file) + inst = model.new(path, :relative_path => file) inst.links = request.options[:links] if request.options[:links] inst end |