summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving/terminus_helper.rb
blob: e5da0e29f3ba25ad706560c97e0e21ef81c82948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#
#  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(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.links = request.options[:links] if request.options[:links]
            inst
        end
    end
end