Class Pry
In: lib/pry.rb
lib/pry/module_candidate.rb
lib/pry/cli.rb
lib/pry/editor.rb
lib/pry/helpers/text.rb
lib/pry/helpers/command_helpers.rb
lib/pry/helpers/documentation_helpers.rb
lib/pry/helpers/options_helpers.rb
lib/pry/helpers/table.rb
lib/pry/helpers/base_helpers.rb
lib/pry/plugins.rb
lib/pry/code_object.rb
lib/pry/command_set.rb
lib/pry/hooks.rb
lib/pry/pry_class.rb
lib/pry/pry_instance.rb
lib/pry/exceptions.rb
lib/pry/repl_file_loader.rb
lib/pry/code/loc.rb
lib/pry/code/code_file.rb
lib/pry/code/code_range.rb
lib/pry/rbx_path.rb
lib/pry/output.rb
lib/pry/method/weird_method_locator.rb
lib/pry/method/disowned.rb
lib/pry/method/patcher.rb
lib/pry/rubygem.rb
lib/pry/code.rb
lib/pry/command.rb
lib/pry/core_extensions.rb
lib/pry/object_path.rb
lib/pry/method.rb
lib/pry/history.rb
lib/pry/indent.rb
lib/pry/repl.rb
lib/pry/history_array.rb
lib/pry/color_printer.rb
lib/pry/input_lock.rb
lib/pry/commands/watch_expression.rb
lib/pry/commands/toggle_color.rb
lib/pry/commands/easter_eggs.rb
lib/pry/commands/help.rb
lib/pry/commands/whereami.rb
lib/pry/commands/exit.rb
lib/pry/commands/import_set.rb
lib/pry/commands/disable_pry.rb
lib/pry/commands/ri.rb
lib/pry/commands/gem_cd.rb
lib/pry/commands/edit.rb
lib/pry/commands/hist.rb
lib/pry/commands/play.rb
lib/pry/commands/save_file.rb
lib/pry/commands/cat.rb
lib/pry/commands/cd.rb
lib/pry/commands/show_info.rb
lib/pry/commands/reload_code.rb
lib/pry/commands/exit_program.rb
lib/pry/commands/gist.rb
lib/pry/commands/fix_indent.rb
lib/pry/commands/shell_command.rb
lib/pry/commands/cat/input_expression_formatter.rb
lib/pry/commands/cat/file_formatter.rb
lib/pry/commands/cat/abstract_formatter.rb
lib/pry/commands/cat/exception_formatter.rb
lib/pry/commands/watch_expression/expression.rb
lib/pry/commands/show_input.rb
lib/pry/commands/show_source.rb
lib/pry/commands/switch_to.rb
lib/pry/commands/nesting.rb
lib/pry/commands/raise_up.rb
lib/pry/commands/exit_all.rb
lib/pry/commands/jump_to.rb
lib/pry/commands/simple_prompt.rb
lib/pry/commands/gem_list.rb
lib/pry/commands/shell_mode.rb
lib/pry/commands/install_command.rb
lib/pry/commands/ls.rb
lib/pry/commands/pry_backtrace.rb
lib/pry/commands/code_collector.rb
lib/pry/commands/stat.rb
lib/pry/commands/ls/grep.rb
lib/pry/commands/ls/self_methods.rb
lib/pry/commands/ls/formatter.rb
lib/pry/commands/ls/methods.rb
lib/pry/commands/ls/local_vars.rb
lib/pry/commands/ls/instance_vars.rb
lib/pry/commands/ls/constants.rb
lib/pry/commands/ls/local_names.rb
lib/pry/commands/ls/globals.rb
lib/pry/commands/ls/ls_entity.rb
lib/pry/commands/amend_line.rb
lib/pry/commands/gem_open.rb
lib/pry/commands/bang_pry.rb
lib/pry/commands/pry_version.rb
lib/pry/commands/gem_install.rb
lib/pry/commands/edit/exception_patcher.rb
lib/pry/commands/edit/file_and_line_locator.rb
lib/pry/commands/reset.rb
lib/pry/commands/wtf.rb
lib/pry/commands/find_method.rb
lib/pry/commands/bang.rb
lib/pry/commands/show_doc.rb
lib/pry/wrapped_module.rb
lib/pry/version.rb
Parent: Object

PP subclass for streaming inspect output in color.

Methods

Classes and Modules

Module Pry::ExtendCommandBundle
Module Pry::FrozenObjectException
Module Pry::Helpers
Module Pry::RbxPath
Module Pry::RescuableException
Module Pry::Rubygem
Module Pry::TooSafeException
Module Pry::UserError
Class Pry::BlockCommand
Class Pry::CLI
Class Pry::ClassCommand
Class Pry::Code
Class Pry::CodeFile
Class Pry::CodeObject
Class Pry::ColorPrinter
Class Pry::Command
Class Pry::CommandError
Class Pry::CommandSet
Class Pry::Config
Class Pry::Editor
Class Pry::History
Class Pry::HistoryArray
Class Pry::Hooks
Class Pry::Indent
Class Pry::InputCompleter
Class Pry::InputLock
Class Pry::Inspector
Class Pry::LastException
Class Pry::Method
Class Pry::MethodNotFound
Class Pry::NoCommandError
Class Pry::ObjectPath
Class Pry::ObsoleteError
Class Pry::Output
Class Pry::Pager
Class Pry::PluginManager
Class Pry::Prompt
Class Pry::REPL
Class Pry::REPLFileLoader
Class Pry::Result
Class Pry::Terminal
Class Pry::WrappedModule

Constants

DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_| next if _pry_.quiet?   The default hooks - display messages when beginning and ending Pry sessions.
HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
LOCAL_RC_FILE = "./.pryrc"
EMPTY_COMPLETIONS = [].freeze
DEFAULT_EXCEPTION_WHITELIST = [SystemExit, SignalException, Pry::TooSafeException]   Don‘t catch these exceptions
BINDING_METHOD_IMPL = [<<-METHOD, __FILE__, __LINE__ + 1] # Get a binding with 'self' set to self, and no locals. # # The default definee is determined by the context in which the # definition is eval'd. # # Please don't call this method directly, see {__binding__}. # # @return [Binding] def __pry__ binding end METHOD , __FILE__, __LINE__ + 1]   @return [Array] Code of the method used when implementing Pry‘s
  __binding__, along with line indication to be used with instance_eval (and
  friends).

@see Object#binding

VERSION = "0.10.1"

External Aliases

reset_defaults -> orig_reset_defaults

Attributes

backtrace  [RW] 
binding_stack  [RW] 
cli  [RW] 
command_state  [R] 
config  [R] 
config  [RW] 
current_line  [RW] 
custom_completions  [RW] 
custom_completions  [RW] 
eval_path  [RW] 
eval_string  [RW] 
exit_value  [R] 
history  [W] 
input_array  [R] 
last_dir  [RW] 
last_exception  [R] 
last_file  [RW] 
last_internal_error  [RW] 
last_result  [RW] 
line_buffer  [RW] 
output_array  [R] 
quiet  [RW] 
suppress_output  [RW] 

Public Class methods

Convert the given object into an instance of `Pry::Code`, if it isn‘t already one.

@param [Code, Method, UnboundMethod, Proc, Pry::Method, String, Array,

  IO] obj

If the given object is a `Pry::Method`, return it unaltered. If it‘s anything else, return it wrapped in a `Pry::Method` instance.

If the given object is a `Pry::WrappedModule`, return it unaltered. If it‘s anything else, return it wrapped in a `Pry::WrappedModule` instance.

Return a `Binding` object for `target` or return `target` if it is already a `Binding`. In the case where `target` is top-level then return `TOPLEVEL_BINDING` @param [Object] target The object to get a `Binding` object for. @return [Binding] The `Binding` object.

@return [Pry::Config]

 Returns a value store for an instance of Pry running on the current thread.

Basic initialization.

@return [Boolean] Whether this is the first time a Pry session has

  been started since loading the Pry class.

Do basic setup for initial session. Including: loading .pryrc, loading plugins, loading requires, and loading history.

Load the given file in the context of `Pry.toplevel_binding` @param [String] file The unexpanded file path.

Execute the file through the REPL loop, non-interactively. @param [String] file_name File name to load through the REPL.

Load Readline history if required.

Load HOME_RC_FILE and LOCAL_RC_FILE if appropriate This method can also be used to reload the files if they have changed.

Load any Ruby files specified with the -r flag on the command line.

Trap interrupts on jruby, and make them behave like MRI so we can catch them.

@return [main]

  returns the special instance of Object, "main".

Create a new {Pry} instance. @param [Hash] options @option options [readline] :input

  The object to use for input.

@option options [puts] :output

  The object to use for output.

@option options [Pry::CommandBase] :commands

  The object to use for commands.

@option options [Hash] :hooks

  The defined hook Procs.

@option options [Array<Proc>] :prompt

  The array of Procs to use for prompts.

@option options [Proc] :print

  The Proc to use for printing return values.

@option options [Boolean] :quiet

  Omit the `whereami` banner when starting.

@option options [Array<String>] :backtrace

  The backtrace of the session's `binding.pry` line, if applicable.

@option options [Object] :target

  The initial context for this session.

Load the local RC file (./.pryrc)

Expand a file to its canonical name (following symlinks as appropriate)

Set all the configurable options back to their default values

Run a Pry command from outside a session. The commands available are those referenced by `Pry.config.commands` (the default command set). @param [String] command_string The Pry command (including arguments,

  if any).

@param [Hash] options Optional named parameters. @return [Object] The return value of the Pry command. @option options [Object, Binding] :target The object to run the

  command under. Defaults to `TOPLEVEL_BINDING` (main).

@option options [Boolean] :show_output Whether to show command

  output. Defaults to true.

@example Run at top-level with no output.

  Pry.run_command "ls"

@example Run under Pry class, returning only public methods.

  Pry.run_command "ls -m", :target => Pry

@example Display command output.

  Pry.run_command "ls -av", :show_output => true

Start a Pry REPL. This method also loads `~/.pryrc` and `./.pryrc` as necessary the first time it is invoked. @param [Object, Binding] target The receiver of the Pry session @param [Hash] options @option options (see Pry#initialize) @example

  Pry.start(Object.new, :input => MyInput.new)

An inspector that clips the output to `max_length` chars. In case of > `max_length` chars the `#<Object…> notation is used.

@param [Object] obj

  The object to view.

@param [Hash] options @option options [Integer] :max_length (60)

  The maximum number of chars before clipping occurs.

@option options [Boolean] :id (false)

  Boolean to indicate whether or not a hex reprsentation of the object ID
  is attached to the return value when the length of inspect is greater than
  value of `:max_length`.

@return [String]

  The string representation of `obj`.

Public Instance methods

Add a sticky local to this Pry instance. A sticky local is a local that persists between all bindings in a session. @param [Symbol] name The name of the sticky local. @yield The block that defines the content of the local. The local

  will be refreshed at each tick of the repl loop.

Generate completions.

@param [String] input

  What the user has typed so far

@return [Array<String>]

  Possible completions

The currently active `Binding`. @return [Binding] The currently active `Binding` for the session.

current_context()

Alias for current_binding

Pass a line of input to Pry.

This is the equivalent of `Binding#eval` but with extra Pry!

In particular:

  1. Pry commands will be executed immediately if the line matches.
  2. Partial lines of input will be queued up until a complete expression has been accepted.
  3. Output is written to `output` in pretty colours, not returned.

Once this method has raised an exception or returned false, this instance is no longer usable. {exit_value} will return the session‘s breakout value if applicable.

@param [String?] line The line of input; `nil` if the user types `<Ctrl-D>` @option options [Boolean] :generated Whether this line was generated automatically.

  Generated lines are not stored in history.

@return [Boolean] Is Pry ready to accept more input? @raise [Exception] If the user uses the `raise-up` command, this method

  will raise that exception.

Execute the specified hook. @param [Symbol] name The hook name to execute @param [*Object] args The arguments to pass to the hook @return [Object, Exception] The return value of the hook or the exception raised

If executing a hook raises an exception, we log that and then continue sucessfully. To debug such errors, use the global variable $pry_hook_error, which is set as a result.

Injects a local variable into the provided binding.

@param [String] name

  The name of the local to inject.

@param [Object] value

  The value to set the local to.

@param [Binding] b

  The binding to set the local on.

@return [Object]

  The value the local was set to.

Inject all the sticky locals into the current binding.

Set the last exception for a session.

@param [Exception] e

  the last exception.

@return [Boolean] True if the last result is an exception that was raised,

  as opposed to simply an instance of Exception (like the result of
  Exception.new)

@return [Integer] The maximum amount of objects remembered by the inp and

  out arrays. Defaults to 100.

Returns an output device @example

  _pry_.output.puts "ohai!"

Returns the currently configured pager @example

  _pry_.pager.page text

Pops the current prompt off of the prompt stack. If the prompt you are popping is the last prompt, it will not be popped. Use this to restore the previous prompt. @return [Array<Proc>] Prompt being popped. @example

   prompt1 = [ proc { '>' }, proc { '>>' } ]
   prompt2 = [ proc { '$' }, proc { '>' } ]
   pry = Pry.new :prompt => prompt1
   pry.push_prompt(prompt2)
   pry.pop_prompt # => prompt2
   pry.pop_prompt # => prompt1
   pry.pop_prompt # => prompt1

If the given line is a valid command, process it in the context of the current `eval_string` and binding. @param [String] val The line to process. @return [Boolean] `true` if `val` is a command, `false` otherwise

Same as process_command, but outputs exceptions to `output` instead of raising. @param [String] val The line to process. @return [Boolean] `true` if `val` is a command, `false` otherwise

The current prompt. This is the prompt at the top of the prompt stack.

@example

   self.prompt = Pry::SIMPLE_PROMPT
   self.prompt # => Pry::SIMPLE_PROMPT

@return [Array<Proc>] Current prompt.

Push a binding for the given object onto the stack. If this instance is currently stopped, mark it as usable again.

Initialize this instance by pushing its initial context into the binding stack. If no target is given, start at the top level.

Pushes the current prompt onto a stack that it can be restored from later. Use this if you wish to temporarily change the prompt. @param [Array<Proc>] new_prompt @return [Array<Proc>] new_prompt @example

   new_prompt = [ proc { '>' }, proc { '>>' } ]
   push_prompt(new_prompt) # => new_prompt

Convenience accessor for the `quiet` config key. @return [Boolean]

Raise an exception out of Pry.

See Kernel#raise for documentation of parameters. See rb_make_exception for the inbuilt implementation.

This is necessary so that the raise-up command can tell the difference between an exception the user has decided to raise, and a mistake in specifying that exception.

(i.e. raise-up RunThymeError.new should not be the same as

 raise-up NameError, "unititialized constant RunThymeError")

Potentially deprecated — Use `Pry::REPL.new(pry, :target => target).start` (If nested sessions are going to exist, this method is fine, but a goal is to come up with an alternative to nested sessions altogether.)

Reset the current eval string. If the user has entered part of a multiline expression, this discards that input.

Run the specified command. @param [String] val The command (and its params) to execute. @return [Pry::Command::VOID_VALUE] @example

  pry_instance.run_command("ls -m")

Returns the appropriate prompt to use. @return [String] The prompt.

Set the last result of an eval. This method should not need to be invoked directly. @param [Object] result The result. @param [String] code The code that was run.

Whether the print proc should be invoked. Currently only invoked if the output is not suppressed. @return [Boolean] Whether the print proc should be invoked.

Output the result or pass to an exception handler (if result is an exception).

Update Pry‘s internal state after evalling code. This method should not need to be invoked directly. @param [String] code The code we just eval‘d

[Validate]