Class: Puppet::Plugins::DataProviders::FileBasedDataProviderFactory Abstract

Inherits:
PathBasedDataProviderFactory show all
Defined in:
lib/puppet/plugins/data_providers/data_provider.rb

Overview

This class is abstract.

Factory for creating file based data providers. This is an extension of the path based factory where it is required that each resolved path appoints an existing file in the local file system.

Since:

  • Puppet 4.0.0

Instance Method Summary collapse

Methods inherited from PathBasedDataProviderFactory

#create

Instance Method Details

#resolve_paths(datadir, declared_paths, paths, lookup_invocation) ⇒ Array<ResolvedPath>

Returns Array of resolved paths.

Parameters:

  • datadir (Pathname)

    The base when creating absolute paths

  • declared_paths (Array<String>)

    paths as found in declaration. May contain interpolation expressions

  • paths (Array<String>)

    paths that have been preprocessed (interpolations resolved)

  • lookup_invocation (Puppet::Pops::Lookup::Invocation)

    The current lookup invocation

Returns:

Since:

  • Puppet 4.0.0



266
267
268
269
270
271
272
273
274
275
276
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 266

def resolve_paths(datadir, declared_paths, paths, lookup_invocation)
  resolved_paths = []
  unless paths.nil? || datadir.nil?
    ext = path_extension
    paths.each_with_index do |path, idx|
      path = path + ext unless path.end_with?(ext)
      resolved_paths << ResolvedPath.new(declared_paths[idx], datadir + path)
    end
  end
  resolved_paths
end