Class: Puppet::Pal::ScriptCompiler

Inherits:
Compiler show all
Defined in:
lib/puppet/pal/script_compiler.rb

Instance Method Summary collapse

Methods inherited from Compiler

#call_function, #create, #evaluate, #evaluate_file, #evaluate_literal, #evaluate_string, #function_signature, #has_catalog?, #initialize, #list_functions, #parse_file, #parse_string, #type

Constructor Details

This class inherits a constructor from Puppet::Pal::Compiler

Instance Method Details

#list_plans(filter_regex = nil, error_collector = nil) ⇒ Array<Puppet::Pops::Loader::TypedName>

Returns an array of TypedName objects for all plans, optionally filtered by a regular expression. The returned array has more information than just the leaf name - the typical thing is to just get the name as showing the following example.

Errors that occur during plan discovery will either be logged as warnings or collected by the optional `error_collector` array. When provided, it will receive DataTypes::Error instances describing each error in detail and no warnings will be logged.

Examples:

getting the names of all plans

compiler.list_plans.map {|tn| tn.name }

34
35
36
# File 'lib/puppet/pal/script_compiler.rb', line 34

def list_plans(filter_regex = nil, error_collector = nil)
  list_loadable_kind(:plan, filter_regex, error_collector)
end

#list_tasks(filter_regex = nil, error_collector = nil) ⇒ Array<Puppet::Pops::Loader::TypedName>

Returns an array of TypedName objects for all tasks, optionally filtered by a regular expression. The returned array has more information than just the leaf name - the typical thing is to just get the name as showing the following example.

Errors that occur during task discovery will either be logged as warnings or collected by the optional `error_collector` array. When provided, it will receive DataTypes::Error instances describing each error in detail and no warnings will be logged.

Examples:

getting the names of all tasks

compiler.list_tasks.map {|tn| tn.name }

67
68
69
# File 'lib/puppet/pal/script_compiler.rb', line 67

def list_tasks(filter_regex = nil, error_collector = nil)
  list_loadable_kind(:task, filter_regex, error_collector)
end

#plan_signature(plan_name) ⇒ Puppet::Pal::PlanSignature?

Returns the signature of the given plan name


9
10
11
12
13
14
15
16
17
# File 'lib/puppet/pal/script_compiler.rb', line 9

def plan_signature(plan_name)
  loader = internal_compiler.loaders.private_environment_loader
  func = loader.load(:plan, plan_name)
  if func
    return PlanSignature.new(func)
  end
  # Could not find plan
  nil
end

#task_signature(task_name) ⇒ Puppet::Pal::TaskSignature?

Returns the signature callable of the given task (the arguments it accepts, and the data type it returns)


42
43
44
45
46
47
48
49
50
# File 'lib/puppet/pal/script_compiler.rb', line 42

def task_signature(task_name)
  loader = internal_compiler.loaders.private_environment_loader
  task = loader.load(:task, task_name)
  if task
    return TaskSignature.new(task)
  end
  # Could not find task
  nil
end