view modules/stdlib/lib/puppet/parser/functions/pry.rb @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents c42fb28cff86
children 4a2ee7e3b110
line wrap: on
line source

#
# pry.rb
#
module Puppet::Parser::Functions
  newfunction(:pry, :type => :statement, :doc => <<-DOC
    @summary
      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.

    @return
      debugging information

    @example **Usage**

      `pry()`

    DOC
             ) do |arguments|
    begin
      require 'pry'
    rescue LoadError
      raise(Puppet::Error, "pry(): Requires the 'pry' rubygem to use, but it was not found")
    end
    #
    ## Run `catalog` to see the contents currently compiling catalog
    ## Run `cd catalog` and `ls` to see catalog methods and instance variables
    ## Run `@resource_table` to see the current catalog resource table
    #
    if $stdout.isatty
      binding.pry # rubocop:disable Lint/Debugger
    else
      Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized master'
    end
  end
end