diff options
| author | Luke Kanies <luke@madstop.com> | 2007-10-22 19:28:22 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-10-22 19:28:22 -0500 |
| commit | 688fcdf11a685dfda297beff50de8d4c751494d9 (patch) | |
| tree | f2d737a2382de16a43e3d37f09dab2c76ad57d91 /lib/puppet/file_serving | |
| parent | 393a3e8743f503543ad34a874e9296d684b0d49b (diff) | |
| download | puppet-688fcdf11a685dfda297beff50de8d4c751494d9.tar.gz puppet-688fcdf11a685dfda297beff50de8d4c751494d9.tar.xz puppet-688fcdf11a685dfda297beff50de8d4c751494d9.zip | |
Adding searchability to the fileserving termini, using the
new Fileset class.
The tests aren't the cleanest, in that there is still
a good bit of duplication in them, but it's what we got.
Diffstat (limited to 'lib/puppet/file_serving')
| -rw-r--r-- | lib/puppet/file_serving/fileset.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/file_serving/terminus_helper.rb | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index 7f7b9fc2d..fe54350b1 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -11,11 +11,11 @@ class Puppet::FileServing::Fileset attr_reader :path, :ignore, :links attr_accessor :recurse - # Find our collection of files. This is different from the + # Return a list of all files in our fileset. This is different from the # normal definition of find in that we support specific levels # of recursion, which means we need to know when we're going another # level deep, which Find doesn't do. - def find + def files files = perform_recursion # Now strip off the leading path, so each file becomes relative, and remove diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb new file mode 100644 index 000000000..9542cbf84 --- /dev/null +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -0,0 +1,15 @@ +# +# Created by Luke Kanies on 2007-10-22. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving' +require 'puppet/file_serving/fileset' + +# Define some common methods for FileServing termini. +module Puppet::FileServing::TerminusHelper + # Create model instances for all files in a fileset. + def path2instances(path, options = {}) + args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = options[param] if options[param]; hash } + Puppet::FileServing::Fileset.new(path, args).files.collect { |file| model.new(file) } + end +end |
