class Puppet::Environments::Directories

Reads environments from a directory on disk. Each environment is represented as a sub-directory. The environment’s manifest setting is the `manifest` directory of the environment directory. The environment’s modulepath setting is the global modulepath (from the `[master]` section for the master) prepended with the `modules` directory of the environment directory.

@api private

Public Instance Methods

get(name) click to toggle source

@!macro loader_get

# File lib/puppet/environments.rb, line 235
def get(name)
  if valid_directory?(File.join(@environment_dir, name.to_s))
    create_environment(name)
  end
end
get_conf(name) click to toggle source

@!macro loader_get_conf

# File lib/puppet/environments.rb, line 242
def get_conf(name)
  envdir = File.join(@environment_dir, name.to_s)
  if valid_directory?(envdir)
    return Puppet::Settings::EnvironmentConf.load_from(envdir, @global_module_path)
  end
  nil
end
list() click to toggle source

@!macro loader_list

# File lib/puppet/environments.rb, line 227
def list
  valid_directories.collect do |envdir|
    name = Puppet::FileSystem.basename_string(envdir).intern
    create_environment(name)
  end
end
search_paths() click to toggle source

@!macro loader_search_paths

# File lib/puppet/environments.rb, line 222
def search_paths
  ["file://#{@environment_dir}"]
end

Public Class Methods

from_path(path, global_module_path) click to toggle source

Generate an array of directory loaders from a path string. @param path [String] path to environment directories @param global_module_path [Array<String>] the global modulepath setting @return [Array<Puppet::Environments::Directories>] An array

of configured directory loaders.
# File lib/puppet/environments.rb, line 214
def self.from_path(path, global_module_path)
  environments = path.split(File::PATH_SEPARATOR)
  environments.map do |dir|
    Puppet::Environments::Directories.new(dir, global_module_path)
  end
end
new(environment_dir, global_module_path) click to toggle source
# File lib/puppet/environments.rb, line 204
def initialize(environment_dir, global_module_path)
  @environment_dir = environment_dir
  @global_module_path = global_module_path
end