PP subclass for streaming inspect output in color.
| 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" |
| reset_defaults | -> | orig_reset_defaults |
| 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] |
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.
@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.
Load HOME_RC_FILE and LOCAL_RC_FILE if appropriate This method can also be used to reload the files if they have changed.
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.
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
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`.
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
Pass a line of input to Pry.
This is the equivalent of `Binding#eval` but with extra Pry!
In particular:
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.
@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.
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
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.
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.)
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")
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.