summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-18 15:27:32 -0600
committerLuke Kanies <luke@madstop.com>2009-02-19 16:22:50 -0600
commit00726bac02211be3c269c23a564bdcc8fdd28c2b (patch)
treee7f9692caebdc12c8661233a17cca2d3a0370e1b /lib/puppet
parent058266feebb3be90f6af29d0ff70b22ceeb9b3e7 (diff)
downloadpuppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.tar.gz
puppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.tar.xz
puppet-00726bac02211be3c269c23a564bdcc8fdd28c2b.zip
Moving Request and Fileset integration into Fileset.
It was previously in a helper module, TerminusHelper. I hope to actually remove that module entirely. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/file_serving/fileset.rb36
-rw-r--r--lib/puppet/file_serving/terminus_helper.rb13
2 files changed, 31 insertions, 18 deletions
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index 74a3c27fe..61ca897e1 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -68,13 +68,10 @@ class Puppet::FileServing::Fileset
@links = :manage
@recurse = false
- options.each do |option, value|
- method = option.to_s + "="
- begin
- send(method, value)
- rescue NoMethodError
- raise ArgumentError, "Invalid option '%s'" % option
- end
+ if options.is_a?(Puppet::Indirector::Request)
+ initialize_from_request(options)
+ else
+ initialize_from_hash(options)
end
raise ArgumentError.new("Fileset paths must exist") unless stat = stat(path)
@@ -102,6 +99,31 @@ class Puppet::FileServing::Fileset
# Else, return false.
return false
end
+
+ def initialize_from_hash(options)
+ options.each do |option, value|
+ method = option.to_s + "="
+ begin
+ send(method, value)
+ rescue NoMethodError
+ raise ArgumentError, "Invalid option '%s'" % option
+ end
+ end
+ end
+
+ def initialize_from_request(request)
+ [:links, :ignore, :recurse].each do |param|
+ if request.options.include?(param) # use 'include?' so the values can be false
+ value = request.options[param]
+ elsif request.options.include?(param.to_s)
+ value = request.options[param.to_s]
+ end
+ next if value.nil?
+ value = true if value == "true"
+ value = false if value == "false"
+ send(param.to_s + "=", value)
+ end
+ end
private
diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb
index 5b993c9e0..c88bacc4a 100644
--- a/lib/puppet/file_serving/terminus_helper.rb
+++ b/lib/puppet/file_serving/terminus_helper.rb
@@ -9,18 +9,9 @@ require 'puppet/file_serving/fileset'
module Puppet::FileServing::TerminusHelper
# Create model instances for all files in a fileset.
def path2instances(request, *paths)
- args = [:links, :ignore, :recurse].inject({}) do |hash, param|
- if request.options.include?(param) # use 'include?' so the values can be false
- hash[param] = request.options[param]
- elsif request.options.include?(param.to_s)
- hash[param] = request.options[param.to_s]
- end
- hash[param] = true if hash[param] == "true"
- hash[param] = false if hash[param] == "false"
- hash
- end
filesets = paths.collect do |path|
- Puppet::FileServing::Fileset.new(path, args)
+ # Filesets support indirector requests as an options collection
+ Puppet::FileServing::Fileset.new(path, request)
end
Puppet::FileServing::Fileset.merge(*filesets).collect do |file, base_path|