fix amend-line :listing (wrongly listed as -line). Fix gist -o and gist -i
Change redundant String#replace to String#clear

"foo".clear does the same as "foo".replace(""). But the former is more
concise.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Merge pull request #599 from kyrylo/change-replace-to-clear

Change redundant String#replace to String#clear
Revert "Change redundant String#replace..."

This reverts commit a4e37948a20e73ba1de3f5c8e723f05d9f0c7da3. String#clear is a
method that was introduced in Ruby 1.9, it's not available in 1.8.
Add unit tests for DEFAULT_CONTROL_D_HANDLER

DEFAULT_CONTROL_D_HANDLER handles a user's Control-D (^D) presses. Add
unit tests for ^D presses. Note that this commit doesn't include unit
tests for the situation when ^D is being pressed in an expression[1].

[1]:
Example of the untested situation:
  % pry
  [1] pry(main)> class Foo
  [1] pry(main)*   ^D
  [2] pry(main)>

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Enormously important fix
Escape user input before completing it.

User input should be escaped using Regexp.escape() before trying to figure out
what data to use for the Readline completion system. Not escaping this input
would cause Pry to fail for input such as `[10, 20].map(&:class)`.

This problem was caused due to lib/completion.rb converting the input (in this
case it would be ":class)") to a Regexp object. Because this, when converted to
a Regexp object, is invalid it would cause Pry to throw a RegexpError error and
bail out.

See #601 for more information.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Completion for instance and class variables.

Pry is now able to complete variable names for instance and class variables, as
well as being able to complete methods and the like on these variables.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Fixed the completion test for Ruby 1.8.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Completion fix for Jruby.

Jruby doesn't always provide the method `#instance_methods()` on objects. By
checking to see if this method exists before using it the completion system
won't totally barf itself when used on Jruby.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Manually merged branch "issue/601".

The commits in this branch would conflict with the current ones in the master
branch. I've modified the code of pry/completion.rb so that instead of escaping
*all* input it will only escape it when this hasn't already been done so.

This fixes #601.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
provide CLI 'pry my_file.rb' functionality to load file through REPL loop

This is an interesting trick as it processes your file as if it
was user input in an interactive session. As a result, all Pry
commands are available, and they are executed non-interactively. Furthermore
the session becomes interactive when the repl loop processes a
'make-interactive' command in the file. The session also becomes
interactive when an exception is encountered, enabling you to fix
the error before returning to non-interactive processing with the
'make-non-interactive' command.
remove unnecessary kruft i neglected to remove in last commit
Implement `cd -` command

The `cd -` command allows a user to toggle between last two scopes.

Example:

  [1] pry(main)> cd :foo
  [2] pry(:foo):1> cd :bar
  [3] pry(:bar):2> cd -
           ^ save :bar and toggle
  [4] pry(:foo):1> cd 44
           ^ we are back at foo
  [5] pry(44):2> cd ..
  [6] pry(:foo):1> cd ..
  [7] pry(main)> cd -
           ^ save main and toggle
  [8] pry(:foo):1>
           ^ we are back at foo

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
basic docs for Pry class so that show-doc Pry displays something
Expanded the documentation of "Pry" a bit.

Running `show-doc Pry` now shows a bit more useful information than just a
short description of what Pry is.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
unbreak pry executable

Options passed to pry executable, i.e '-h'  were not removed from ARGV
causing pry to attempt to open the "-h" file to load it through the REPL.

Fixed by removing flags from ARGV during option processing.
Update master
ensure pry doesn't load when invoked with -h option