Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / pry.rb
1 #
2 # pry.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:pry, :type => :statement, :doc => <<-DOC
6     This function invokes a pry debugging session in the current scope object. This is useful for debugging manifest code at specific points during a compilation.
7
8     *Examples:*
9
10         pry()
11     DOC
12              ) do |arguments|
13     begin
14       require 'pry'
15     rescue LoadError
16       raise(Puppet::Error, "pry(): Requires the 'pry' rubygem to use, but it was not found")
17     end
18     #
19     ## Run `catalog` to see the contents currently compiling catalog
20     ## Run `cd catalog` and `ls` to see catalog methods and instance variables
21     ## Run `@resource_table` to see the current catalog resource table
22     #
23     if $stdout.isatty
24       binding.pry # rubocop:disable Lint/Debugger
25     else
26       Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized master'
27     end
28   end
29 end