Module: PuppetRepl::Support::Scope

Included in:
PuppetRepl::Support
Defined in:
lib/puppet-repl/support/scope.rb

Instance Method Summary collapse

Instance Method Details

#create_scope(node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet-repl/support/scope.rb', line 4

def create_scope(node)
  @compiler = create_compiler(node) # creates a new compiler for each scope
  scope = Puppet::Parser::Scope.new(@compiler)
  scope.source = Puppet::Resource::Type.new(:node, node.name)
  scope.parent = @compiler.topscope
  load_lib_dirs
  # compiling will load all the facts into the scope
  # without this step facts will not get resolved
  scope.compiler.compile # this will load everything into the scope
  scope
end

#scope_varsObject

returns a hash of varaibles that are currently in scope



17
18
19
20
# File 'lib/puppet-repl/support/scope.rb', line 17

def scope_vars
  vars = scope.to_hash.delete_if {| key, value | node.facts.key?(key.to_sym) }
  vars['facts'] = 'removed by the puppet-repl'
end