Fixes#1843 (Rework the Pry config)
There are a few breaking changes. They are mostly minor, so I decided not to
indroduce deprecations because it will considerable slow things down.
Key changes:
* `Pry.lazy` was replaced with `Pry::Configuration::LazyValue`
The config accepts three values now `LazyValue`, `MemoizedValue` and simply
`Value`. The main difference is that:
- `Value` is any value, including procs (so that an option returns a raw
proc)
- `LazyValue` is a proc that is call on every invocation of an option
- `MemoizedValue` is a value that is called only once (and then the option
always returns the return value of the )
* `Pry.config.history` was a meta-option that held suboptions. However, the new
config doesn't permit that (unless you know what you do)
Instead, we introduce a few options. For example:
- `Pry.config.history.histignore` becomes `Pry.config.history_ignorelist`
- `Pry.config.history.file` becomes `Pry.config.history_file`
- and so on
This was done so we can simplify configuration merging. Inlining option makes
configuration implementation simpler, without losing much. The rule is that
you want to keep your options under your prefix (if you are a
plugin). Therefore, say, `Pry.config.pry_rescue.*` should be
`Pry.config.pry_rescue_*` if you need merging.
The rest should behave in a similar fashion (and I rely heavily on our test
suite to claim so).
Just discovered this nice feature of RSpec where it can load all files for
us. Works with `bundle exec rake` and `bundle exec rspec spec/file_spec.rb`,
which covers all use cases.
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.
Fixes offences of the following cops:
* Layout/SpaceAroundEqualsInParameterDefault
* Layout/SpaceAroundOperators
* Layout/SpaceBeforeBlockBraces
* Layout/SpaceInsideBlockBraces
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)>
```
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.