The interesting moment is that `cd -` is still a bit dorky.
[1] pry(main)> _pry_.repl :a
[2] pry(:a):1> _pry_.repl :b
[3] pry(:b):2> cd -
[4] pry(:b):2> cd -
[5] pry(:b):2>
The problem is that `_pry_.repl` pushes a new binding onto
`binding_stack`, however, it knows nothing about `old_stack`.
Well, there is a workaround for this.
[1] pry(main)> _pry_.repl :a
[2] pry(:a):1> ^D
[3] pry(main)> cd -
[4] pry(:a):1> cd -
[5] pry(main)>
Fix "undefined method `old_stack=' for nil:NilClass" error in this
commit, when you press ^D in a nested REPL. Add a test case for this.
Rewrite some comments and old Control-D units tests (so they use newer
test API).
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
It's useful having Pry::WrappedModule and Pry::Method share as much interface as possible so that
methods can be indifferent to which one they get (a la show-source / edit)
* removed most historicla junk from lib/pry/test/helper.rb
* relocated recalcitrant junk to the local spec/helper.rb (this isn't exposed to 3rd parties)
`play 69` is a shortcut for `play --file #{_file_} --lines 69`. It plays
lines from the current file. Example (I omitted some useless
information):
pry(main)> show-source hello
def hello
binding.pry
true
puts "hi"
69
end
pry(main)> hello
1: def hello
=> 2: binding.pry
3: true
4: puts "hi"
5: 69
6: end
pry(main)> play 5
=> 69
pry(main)> play 3..4
hi
=> nil
pry(main)>
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
A few things were missing. I had to add a new method and slightly adjust
ClassCommand#slop method. Without these changes subcommands doesn't work
properly.
Add some unit tests for subcommands.
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Create `ClassCommand::Options` class, which ties up sub commands and
default options together.
Let's consider the command `food make --tea`. `food` is a command,
`make` is a sub command and `--tea` is an option of `make` sub command.
We can access `--tea` via `opts[:make][:tea].
Also, we can check the freshness of our food like so: `food --freshness`.
`--freshness` is a default option. We can access it like so:
`opts.freshness?` or `opts[:freshness]`.
Add unit tests for `ClassCommand::Option` and some other tests that
reflect the additions.
Finally, document everything and fix different typos in the existing
documentation.
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This is working around (another) brokenness in jruby 1.6.8s splat
handling in ruby 1.9 mode; but I figure that now jruby 1.7 is out,
we can not bother fixing it.