Update stdlib and concat to 6.1.0 both
[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     @summary
7       This function invokes a pry debugging session in the current scope object.
8     This is useful for debugging manifest code at specific points during a compilation.
9
10     @return
11       debugging information
12
13     @example **Usage**
14
15       `pry()`
16
17     DOC
18              ) do |arguments|
19     begin
20       require 'pry'
21     rescue LoadError
22       raise(Puppet::Error, "pry(): Requires the 'pry' rubygem to use, but it was not found")
23     end
24     #
25     ## Run `catalog` to see the contents currently compiling catalog
26     ## Run `cd catalog` and `ls` to see catalog methods and instance variables
27     ## Run `@resource_table` to see the current catalog resource table
28     #
29     if $stdout.isatty
30       binding.pry # rubocop:disable Lint/Debugger
31     else
32       Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized master'
33     end
34   end
35 end