* Shows a deprecation warning when used with a link to the new `Pry::Hooks` documentation.
* When hash-based hooks are used they create anonymous hooks for the associated event.
i.e Pry.hooks = { :before_session => proc { puts 'hi' } }, the 'name' of that hook is `nil`.
* Anonymous hooks (nil-named) are different to ordinary hooks in that they dont raise an exception when user attempts to define another of the same name, they just silently overwrite previous one. This is to
mimic the old hash-based behaviour.
* Pry::Hooks[] and Pry::Hooks[]= are defined too, and they get and set the anonymous hook for the given event, i.e hooks[:before_session] = proc { "hi" } is equivalent to: hook.add_hook(:before_session, nil,
proc { "hi" })
* Proc::Hook#[] and Pry::Hooks#[]= also display deprecation warnings.
We no longer wish to support the (undocumented!!) hash-based hooks API. When a user attempts to use this API
Pry will raise a `Pry::ObsoleteError` exception with a message telling them to use `Pry::Hooks` instead.
Code is indented using the class Pry::Indent. This class uses an internal stack
that contains the indentation levels for each line of code. Certain keywords
such as "class" or "def" will add data to this stack so that the next line is
indented, other keywords such as "end" or "}" will remove data from the stack,
causing the next line to be un-indented.
Pry::Indent is hooked into Pry#retrieve_line as well as Pry#readline. This means
that both input strings as well as the ones displayed by "show-method" are
indented. Sadly due to the way Readline works input strings are indented similar
to IRB. This means that instead of the following:
> class User
> def initialize
> end
> end
You'll get the following:
> class User
> def initialize
> end
> end
While annoying there doesn't seem to be a way to work around this issue. Luckily
the "show-method" command indents your code properly.
By default indentation is turned on. This can be turned off (or back on) using
the configuration item Pry.config.indent. However, if you turn this option off
after a method is defined "show-method" will still show it with indentation as
indentation happens on input rather than only when code is displayed.
For more information see Pry::Indent#indent in lib/pry/indent.rb.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
input_stack allows Pry instances to seemlessly continue reading input from other input objects on the stack when the current object generates EOF
Useful when you need to temporarily divert reading to another object and then switch back to another object