The pry-rails prompt uses `pry.config.prompt_name` but assumes it
will always be a string and never tries to `.call` the object, which means
we can end up with a prompt like this:
[2] [vagrant][development] #<Pry::Config::Lazy:0x000000000fde07b0>(main)>
This commit solves the problem for pry-rails and other prompts who make
the same mistake by calling `.call` for them, automatically, upon read from
a config object.
The commit also removes the issue where every prompt has to deal with `prompt_name`
being a string / Proc-like object then acting accordingly.
Before this change when you set a prompt, you have to do the following:
```rb
Pry.config.prompt = Pry::Prompt[:simple][:value]
```
The `[:value]` part was leaking implementation details and it proved to be an
unnecessary step.
With this change we can do the following:
```rb
Pry.config.prompt = Pry::Prompt[:simple]
```
`[:value]` is omitted.
I have also refactored some tests and removed irrelevant ones.
The Array API for prompt is deprecated:
`Pry.config.prompt = [proc {}, proc {}]` emits a warning now.
currently upon calling Pry::Prompt[:foo] a new Hash is created, and on all
subsequent calls a new Hash is also created. it's wasteful and careless,
so let's fix it.
Fixes#1738 (Possible to make prompt_name dynamic?)
The user-facing API is the following:
```rb
Pry.config.prompt_name = Pry.lazy { rand(100) }
[1] 80(main)>
[2] 87(main)>
[3] 30(main)>
```
Since we always need to define two procs that look almost the same, duplication
was unavoidable. With help of method wrappers around procs we can reduce it.
As a bonus, the class has some YARD annotations now.
It makes a lot more sense to keep these procs under the `Pry::Prompt` namespace
than `Pry`, which is already heavily populated by other various things.
the list-prompts command shows a list of available prompts as well
as the active prompt in the list. prompts are drawn with a name as
well as a short description.
change-prompt can be used to change the prompt by the name found in
the list-prompts command.