Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: pry/pry
head fork: pry/pry
Commits on Jan 01, 2013
Ryan Fitzgerald rf- Make the .gemspec canonical instead of generated fcad0a4
Ryan Fitzgerald rf- Merge pull request #790 from pry/live_gemspec
Make the .gemspec canonical instead of generated
John Mair banister pull more show-source/show-doc methods into their superclass c4dc8cf
John Mair banister refactor Pry::Command::ShowInfo to make codeclimate happier 3da2c4d
Commits on Jan 02, 2013
John Mair banister minor cleanup to whereami command dcdea09
John Mair banister bunch of random refactorings to different commands 4d38473
John Mair banister Pry::Editor, Pry::Command::Whereami: more refactorings e647957
John Mair banister MethodPatcher#with_method_transactions: alias --> alias_method ef8b71a
John Mair banister amend-line: refactor + overengineer the f*ck out of it, for the lulz ba1f761
Commits on Jan 03, 2013
John Mair banister Pry::Command::Edit: renamed some methods to improve grokkability 5302e3a
John Mair banister Pry::WrappedModule::Candidate: break up some large methods e41a9e1
John Mair banister Pry::WrappedModule: attempt to simplify a conditional f81dc1b
Kyrylo Silin kyrylo Extract absolute path finding into its own method
Indent some wrongly indented code, too.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Rename "fn" to "filename" in some places
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Fix indentation of the protected method
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Simplify method chain (use 'map.with_index')
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Simplify `Pry::Code#to_s`
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Ensure `max_width` is always an Integer
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Break up `Pry::Code#between`
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Refactor `Pry::Code#between`
Split some parts of it into small methods.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Add comments to protected methods of `Pry::Code`
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Revert "Simplify method chain (use 'map.with_index')"
This reverts commit a1f0a00.

It doesn't compatible with 1.8.7, ree, rbx-18mode, jruby-18mode.
John Mair banister Slightly refactor help command bcfa5eb
John Mair banister find-method command: break up large/complicated methods a1a6306
John Mair banister minor refactor to wtf command a42eec8
John Mair banister find-method refactor: 'pattern' becomes a method 1dda70c
Commits on Jan 04, 2013
Kyrylo Silin kyrylo Assign default value to `:listing` option
When you create a class command, there is a problem with `:listing`
option, which doesn't carry the correct default value. Consider the

  class MakeMeHappy < Pry::ClassCommand
    match 'woot'

`MakeMeHappy` command matches against 'woot' String, but its `:listing`
option is set to the "nil" String, which is incorrect. We can fix it by
setting `:listing` explicitly:

  command_options :listing => 'woot'

It's a repetitive task, so we can automate it. Holy smoke, this why we
all use computers, after all!

With help of this commit there is no need to set `:listing` manually.
Pry will handle it for you.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Rename "Fixnum" to "Integer" in YARD docs
Signed-off-by: Kyrylo Silin <>
Commits on Jan 05, 2013
Kyrylo Silin kyrylo Extract out some code from Code class
Create a new class called `LOC`, which represents a tuple of a line and
a line number (lineno). `LOC` contains methods that operate on a line.
For example, you can colorize it, or add a line number. The idea is to
make the code of `Pry::Code` more readable. It is clear to me that the
current code allows us to single out a new unit: a line of code.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Add some comments for `Pry::Code::LOC`
Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Rename `add_line_numbers` to `add_line_number`
Rename the instance method of `Pry::Code::LOC`.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Document `Pry::Code::LOC#add_marker`
I thought about some changes that I could make with this method, but
then I realised that it's already quite good.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Change @yield YARD tag for `Pry::Code#select`
It yields `LOC` now. Oh, and also prettify some default method

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Implement `Pry::Code::CodeRange`
Extract some protected methods from `Pry::Code` and add them into its
own class. Name it `CodeRange`, because it operates on numbers and
represents a range of lines of code.

This commit simplifies `Pry::Code`.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Move `LOC` and `CodeRange` to their own files
`Pry::Code` is not cluttered anymore.

Signed-off-by: Kyrylo Silin <>
John Mair banister renamed reload-method to reload-code and extended functionality
Should now be able to reload any valid code object, including: methods, modules, commands, procs, etc
John Mair banister reload-code: use obj_name (rather than code_object) in output strings 6254b8a
John Mair banister Allow 'edit self' and 'reload-code self'
This didn't work due to a quirk in Pry::CodeObject.lookup() which purposely ignores 'expressions'
as they can be methods, which are dangerous to lookup. We now make an exception when the expression is 'self'

This code needs to be refactored as we have ridiculosu method names like  `def variable_or_constant_or_self?`
and we have methods like this in a couple of places. Refactor pls.
John Mair banister Pry::CodeObject, Pry::WrappedModule: introduce safe_to_evaluate? method
Unsure where to put safe_to_evaluate? method, so it's currently duplicated in
both the mentioned modules. If we can simply switch to a defined?(str) != "method" test
then we could put the method on Pry::Method.looks_like_a_method?(str, binding) and call it from both locations, avoiding duplication.
Commits on Jan 06, 2013
John Mair banister set_file_and_dir(): now takes optional _pry_ and target args d77bfe2
John Mair banister refactor cat command
Put each output formatter (input expression, exception, file) into its own class.
Commits on Jan 07, 2013
Kyrylo Silin kyrylo Code: extract `#max_lineno_width` from `#to_s`
"Code" means `Pry::Code`.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Code::LOC: tuple should be "reader"
There is no need to expose the "writer" method.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Code::LOC: add #== and use it in Code#==
And fix a typo in comments.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Create Pry::Code::EXTENSIONS
There is no need to create the hash of supported languages all the time
as the method gets called.

As always, fix some stylistics und stuff :-)

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Code#to_s: standardise method chain
Make it as in `Code#raw` (they both do similar things).

And fix typos, typos, typos.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Use `block` instead of `blk` across-the-board
Everywhere else in the code it's the very `block`.

Rename `Code#get_abs_path` to `#abs_path`.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Code#to_s: don't loop thrice
One loop is enough to complete the task.

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Code: simplify `.from_file` class method
1. Use a temporary variable to hold code;
2. Instantiate `Pry::Code` only in one place;
3. Refactor reading from a file (a credit flies to John Mair).

Signed-off-by: Kyrylo Silin <>
Larry Gilbert L2G Fix calls to (GH issue #792)
Suffix of "*.rb" caused temp files to be named with "*.rb"
at the end, literally.  Not all file systems like that, and
it's almost certainly not what was intended.
Commits on Jan 08, 2013
Kyrylo Silin kyrylo Merge pull request #796 from L2G/gh-792
Fix calls to (GH issue #792)
Kyrylo Silin kyrylo Remove legacy methods from helpers
From BaseHelpers:

  * #stub_proc
  * #create_command_stub

From CommandHelpers:

  * #retrieve_code_object_from_string
  * #file_and_line_from_binding
  * #make_header

Signed-off-by: Kyrylo Silin <>
Kyrylo Silin kyrylo Extract out gem related code to Pry::Rubygem
And fix some typos, and prettify some lines.

Signed-off-by: Kyrylo Silin <>
☈king rking Intermediate merge step 4e89649
☈king rking Immediate output from Guard
(So you know it's not Guard lag, but test suite start)
☈king rking ls columns improvement
Now is like /bin/ls, sorting downward, shrink-wrapping columns, and
minimizing row usage as best as I know how.
☈king rking Downgrade each_with_object to manual accumulation 889ace4
☈king rking Fix my goofy indentation 0eccbbb
☈king rking More lenient assertion for whereami -n 982b4fa
Commits on Jan 09, 2013
Kyrylo Silin kyrylo Implement `Rubygem::install`
Use the code of `gem-install` command as a basis.

Signed-off-by: Kyrylo Silin <>
John Mair banister Pry::Command::Cat::FileFormatter: make format() private 8620676
John Mair banister Reimplemented play, save-file with Pry::Command::CodeCollector
Pry::Command::CodeCollector is a mixin that extracts out shared
functionality from play, save-file and gist. Gist is yet to be
John Mair banister Pry::CodeObject: binding_lookup --> empty_lookup 0608c0e
John Mair banister implement whereami -n (exclude line numbers) 32eb6ca
John Mair banister Pry::Command::CodeCollector: replace module inclusion with delegation
And implement play and save-file using the new delegator. 'gist' still needs
to be re-implemented using CodeCollector.

Couldn't write a test for `play --lines 4..5` with implied target.eval("__FILE__") parameter,
need to come up with a decent test.
Conrad Irwin ConradIrwin Add support for ENV["LINES"] which works
ENV["ROWS"] doesn't for me.
John Mair banister WrappedModule now ignores def_delegator methods, fixes #801
If a class had most of its methods defined by def_delegators, the module extraction code would break.
This was due to Pry::WrappedModule looking for the class definition in fowardable.rb. We now
just simply reject all methods that have source_location.first =~ /forwardable\.rb/
John Mair banister Try to simplify edit.rb
* Remove ContextLocator, inlining the class in edit.rb instead.
* Pass explicit parameters into MethodPatcher and ExceptionPatcher, rather than passing 'self'
  and using def_delegators

Hopefully this won't upset codeclimate too much!
John Mair banister oops, forgot to remove context_locator require 3669832
Kyrylo Silin kyrylo Prettify command descriptions, switches and stuff
Wrap command descriptions to 80 characters. Convert some string options
to symbols (where possible). Align options in code. Remove dots in the
end of switch descriptions.

Signed-off-by: Kyrylo Silin <>
John Mair banister Improve Pry::Command::Edit
* put all file and line location logic into FileAndLineLocator module
* pass explicit parameters to ExceptionPatcher and MethodPatcher (rather than just 'self')
☈king rking Extract Table to its own file 139a2a7
Commits on Jan 11, 2013
John Mair banister Pry::CodeObject: remove unnecessary 'target' parameter
Since we can access 'target' via _pry_.current_context

* We also update a few files (code_collector/show_info) that need to be updated for this change
John Mair banister edit command: add --method option
* --method doesn't accept any parameters, it only edits the 'current' method associated
with the binding. It's equivalent to 'edit-method' (with no args).
* This option is necessary as 'edit' by itself edits the last expression.
* Note that --method doesn't just edit the current method, if no method exists (i.e binding.pry was not put
inside a method context) then it edits the current OBJECT instead.

* explicitly restrict --method to *just* methods and not allow it to fall back to objects?
* allow --method to take a parameter that must be a method object? e.g --method Pry#repl works
but --method Pry would fail ?
☈king rking Update show-file docs 3b52fcb
Commits on Jan 12, 2013
Matt Carey swarley Fixed using a preprocessor just looking for --no-plugins in the ARGV …
…array using slop. Dirty and effective fix.

Took out the trash from the dev process
Kyrylo Silin kyrylo edit: Add example for `--ex --patch` combination
And make the two-column examples.
Conrad Irwin ConradIrwin Pass SyntaxErrors to error handler too. [Fixes #774] d3d29c4
John Mair banister add edit-method stub: deprecation warning, use edit f94eb5a
John Mair banister Improved Pry::CodeCollector so it accept multiple -i/o ranges
i.e play -i 1..3 -i 5..9 now works
John Mair banister added spec for save-file for multiple -i ranges 0ebc315
John Mair banister updated play_spec.rb to check for errors
Also added play spec for multi-ranged -i options but does not work
for some weird reason?!
John Mair banister added fix-indent command
Re-indents the eval_string, useful for amend_line and play, etc
John Mair banister show-source: prettier error messages a604fd6
John Mair banister play and amend-line: now use fix-indent to correct broken indentation 703f42b
Kyrylo Silin kyrylo Add headings for methods in the output of `ls`
You will see headings when a table has more than 35 methods.
Otherwise, there is no need in them.
Andrew Vos AndrewVos refactor #process 17d485b
Andrew Vos AndrewVos refactor the #process method
This has created a whole lot of additional methods. Perhaps these should
be moved into some sort of Presenter (puke) classes.
Andrew Vos AndrewVos stop passing so many parameters around
The write_out* methods all use to take multiple parameters which were
actually available without having to pass them around. Made these
parameters ivars and attr_reader'ed all of them.
Andrew Vos AndrewVos don't use unneccessary meta-programming 3e8c703
Andrew Vos AndrewVos readability in write_out methods
thanks to @locks for this one
Andrew Vos AndrewVos refactor raise_errors_if_arguments_are_weird as per @rking advice 2c4c784
Andrew Vos AndrewVos clean up redundant code 05487af
Andrew Vos AndrewVos extract method on redundant code cee34d9
Commits on Jan 14, 2013
Kyrylo Silin kyrylo Revert "Add headings for methods in the output of `ls`"
This reverts commit 1c33a73.

Looks unpleasant for most of Pry users.
Mon-Ouie Mon-Ouie Made sure completions proc do not return nil
The completion proc returning nil causes errors in input systems that only
expect strings (e.g. Coolline).
Kyrylo Silin kyrylo gist_spec: remove some repetitive code 5871054
Kyrylo Silin kyrylo Edit: handle blanks in filenames correctly
Also, move path escaping to `Editor` class. The test is currently
failing (looks like a bug in `Editor`).
Conrad Irwin ConradIrwin Only shellword escape filenames in system calls on linux 15caf5f
Conrad Irwin ConradIrwin Remove needless old_editor restoration
Unfortunately nested assignments to @old_editor meant that the
original @old_editor was permanently lost. This caused sporadic
failures of spec/editor_spec.rb which was relying on Pry.config.editor
containing a string.
Conrad Irwin ConradIrwin Fix indentation (HARDER) d29f6b5
Kyrylo Silin kyrylo Use proper temp directories for each OS
Also, there was a failing test on Windows ("should shell-escape files").
You will see it if you're running tests on Windows. Make it conditional.
Kyrylo Silin kyrylo Fix errors in tests on Windows
Some tests are still failing, though. This commit fixes wrong usage of
temporary paths on Windows. Please, note: the `edit` command is working
well; the issue is in poor tests.

Prettify some ugly code in `spec/editor_spec.rb`.
Kyrylo Silin kyrylo Remove redundant call to Shellwords.escape
The "edit" command already intelligently escapes arguments, if need.
This commit also fixes four failing tests on Windows.
Kyrylo Silin kyrylo Fix errors on Rubinius and JRuby
These implementations have slightly different APIs for getting your
temp directory path.
John Mair banister play specs: rewrite -i spec to use redirect_pry_io
This is because pry_tester doesn't work when the eval_string is mutated by a command
John Mair banister Pry.config.collision_warning = true by default
Let's try this, if it annoys people, we'll just revert it in a patch level
Kyrylo Silin kyrylo Fix errors in "edit_spec.rb" and "editor_spec.rb"
Basically, the condition was a bit wrong. Let's hope this commit fixes
Conrad Irwin ConradIrwin Remove output.write
Many plugins only define a puts method on the output object. This change
removse the ability to customize the formatter used when outputting
variables in `ls`. We should reconsider the best way to do this.
Kyrylo Silin kyrylo Fix indentations for the gist command description 5ceab36
Kyrylo Silin kyrylo [GEM] Depend on Slop "~> 3.4"
Slop v3.4.0 includes new syntax for subcommands. And we're going to
utilise it.
Kyrylo Silin kyrylo Remove old subcommands cruft
  * use a plain old Slop instance instead of `Options`;
  * remove `ClassCommand::Options` and its tests;
  * add clearer subcommand example (for `Command#subcommand` method);
  * refactor `ClassCommand#slop`;
  * refactor `ClassCommand#complete`.

Slop v3.4.0 has introduced full-featured subcommands. There is no need
in Pry specific code anymore.
Kyrylo Silin kyrylo Update relevant tests in "command_spec.rb"
Make them use the new Slop syntax.
Kyrylo Silin kyrylo Update examples for ClassCommand#subcommands 61326c0
Kyrylo Silin kyrylo Update hist command to the new Slop API
It was creating a new Slop instance for its own needs, thus and so
remove the previous abstraction for Slop commands. The
`ClassCommand::Options` class should be removed because we don't need it
John Mair banister save-file passes on windows :D e63a833
Commits on Jan 15, 2013
John Mair banister Pry::Command::CodeCollector: add #file attribute
This allows callers to know that CC is working on a file rather than ruby code.
John Mair banister edit: ensure 'edit --ex' always edits the exception
There was a bug where if 'edit --ex' was invoked in a patched method context
it would instead to the equivalent of 'edit --method' (patching the current method
rather than the exception)
John Mair banister gist: Use Pry::CodeCollector (like play/save-file)
This enables a simplified UI, i.e: gist my_file.rb instead of gist -f my_file.rb
and `gist my_method` instead of `gist -m my_method`. Unfortunately, we had to kill our
tests in the process of doing this (gist_spec.rb is just commented out) - however since play
and save-file have tests and they use the same Pry::CodeCollector object 'gist' is indirectly
tested. Nonetheless, we should re-add tests at some point
John Mair banister Add deprecated_commands API
And rewrite edit-method / show-command to use this API.
John Mair banister Thread.current -> Pry.current 5e3a3f0
John Mair banister turn Pry.config.collision_warnings back off
This was a horrible mistake, it's stupidly annoying

* in the case of 'rake pry' it warngs every time we do 'cd' (since 'cd' is a top-levle method
  defined by rake)

That's all i can think of right now, but that's still annoying enough.
Kyrylo Silin kyrylo Remove "notes.yml" f172177
Commits on Jan 16, 2013
Kyrylo Silin kyrylo Prepare CHANGELOG for the new release 2fd0e1b
John Mair banister Edit::MethodPatcher: remove unnecessary assignment e53af39
John Mair banister Version 0.9.11 release
Final adjustments made to CHANGELOG and CONTRIBUTORS
John Mair banister v0.9.11.1 bugfix
* forgot to remove 'no_arg' from Pry::Command::CodeCollector, this method no longer exists
and so 'gist' (when not given any params) would break. Replaced no_arg with empty string ""
so that 'gist' gists current object/method by default.
John Mair banister updated CHANGELOG for 6fdb393
John Mair banister gist: window's fix for broken clipboard 19aa778
John Mair banister bugfix for windows
minor bug fix for gist on windows, rescuing Jist::ClipboardError
rather than letting the scary error spill out to users and potentially
have them think the gist didnt post.