module PuppetRepl::Support::Scope
Public Instance Methods
create_scope()
click to toggle source
# File lib/puppet-repl/support/scope.rb, line 16 def create_scope do_initialize begin @compiler = create_compiler(node) # creates a new compiler for each scope scope = Puppet::Parser::Scope.new(@compiler) # creates a node class 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 rescue StandardError => e err = parse_error(e) raise err end scope end
scope()
click to toggle source
@return [Scope] puppet scope object
# File lib/puppet-repl/support/scope.rb, line 9 def scope unless @scope @scope ||= create_scope end @scope end
scope_vars()
click to toggle source
returns a hash of varaibles that are currently in scope
# File lib/puppet-repl/support/scope.rb, line 36 def scope_vars vars = scope.to_hash.delete_if {| key, value | node.facts.values.key?(key.to_sym) } vars['facts'] = 'removed by the puppet-repl' end
set_scope(value)
click to toggle source
# File lib/puppet-repl/support/scope.rb, line 4 def set_scope(value) @scope = value end