pry/pry — pull request #615 by kyrylo (2012-06-27 12:10:23+00:00)
Title: Change behavior of `cd -` command

Since banister begged me to do that... completely rewrite `cd -`
command (implemetation is much simpler now).

This commit brings such changes:

* completely rewrite behavior of `cd -` command;

* implement ScratchPad aka Pad for unit testing purposes (by
banister);

* use Pad riches in the unit tests for `cd -` command;

* remove verbose and clunky unit tests;

This commit brings new meaning to the `cd -` command. The main
difference is that the new command saves entire binding stack, not just
the last binding. Let me show you an example of the variance between
these two implemetations:

* Old `cd -` implementation saves *only* last binding. With our next
`cd -` invocation our interjacent results are lost:
[1] pry(main)> cd 1/2/3/../4
[2] pry(4):3> cd -
[3] pry(main)> cd -
[4] pry(4):1> nesting
Nesting status:
--
0. main (Pry top level)
1. 4

Also, there are a few bugs in old `cd -` command:

* you type `cd :foo`, `cd 1/2/3` and `cd -`. The last command
relocates you to the scope of `3` (leaves you where you was),
when `:foo` is expected;

* you type `cd :foo`, `cd 1/2/3/../4`, `cd -`. The last command
relocates you to the scope of `3`, when `:foo` is expected.

* New and shiny `cd -` is devoid of those shortcomings:
[1] pry(main)> cd 1/2/3/../4
[2] pry(4):3> cd -
[3] pry(main)> cd -
[4] pry(4):3> nesting
Nesting status:
--
0. main (Pry top level)
1. 1
2. 2
3. 4

As I said before, this solution is *much* simpler and less error-prone.

Signed-off-by: Kyrylo Silin