Sha256: a5bed6c7c6086dc42b108b0ec80c3e78defc5e4460d47a7c81f66212224b0fb4

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

module PuppetRepl
  module Support
    module Scope
      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

      # returns a hash of varaibles that are currently in scope
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-repl-0.0.8 lib/puppet-repl/support/scope.rb