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