summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving/terminus_helper.rb
blob: c88bacc4af44338729735b914d8e9d09fd3e9ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
#  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, *paths)
        filesets = paths.collect do |path|
            # 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|
            inst = model.new(base_path, :relative_path => file)
            inst.links = request.options[:links] if request.options[:links]
            inst.collect
            inst
        end
    end
end