Sha256: 7186046428de97cd62605554d485e44d6288e672e8120840e32bf3f6c9e953e3
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module PuppetDebugger module Support module Scope # @param [Puppet::Pops::Scope] - Scope object or nil def set_scope(value) @scope = value end # @return [Puppet::Pops::Scope] - returns a puppet scope object def scope @scope ||= create_scope end # @return [Puppet::Pops::Scope] - returns a puppet scope object def create_scope do_initialize begin # 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 # 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 # @return [Hash] - returns a hash of variables that are currently in scope def scope_vars vars = scope.to_hash.delete_if { |key, _value| node.facts.values.key?(key.to_sym) } vars['facts'] = 'removed by the puppet-debugger' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppet-debugger-0.6.1 | lib/puppet-debugger/support/scope.rb |
puppet-debugger-0.6.0 | lib/puppet-debugger/support/scope.rb |