-
Notifications
You must be signed in to change notification settings - Fork 0
Available plugins
- pry-byebug / code
- pry-coolline / code
- pry-remote / code
- pry-remote-em / code
- pry-stack_explorer / code
- pry-exception_explorer / code
- pry-vterm_aliases / code
- pry-syntax-hacks / code
- pry-em / code
- pry-theme / code
- pry-toys / code
- pry-macro / code
- pry-debugger / code
- pry-state / code
- pry-inline / code
- pry-loudmouth / code
Adds next
,step
, finish
and continue
commands to Pry for stepping
through your program's code and up
, down
and frame
commands for callstack
navigation.
[1] (pry) main: 0> step
From: ./y.rb @ line 4 in Object#hello:
1: require 'pry-byebug'
2:
3: def hello
=> 4: puts 'Hello'
5: end
6:
7: binding.pry
8: hello
For Ruby 1.9 alternatives, checkout pry-debugger and pry-stack_explorer
Author: Mon_Ouie Ruby versions: 1.9.2+ MRIPry-coolline is a nifty little Readline replacement that takes advantage of the new stdlib io-console library to provide live syntax highlighting for user input. It's unfortunately limited to Ruby versions 1.9.2+ and MRI, but generally works well.
Author: Mon_OuiePry-remote (along with its cousin pry-remote-em) enables you to start instances of Pry in a running program and connect to those instances over a network or the Internet. Once connected you can interact with the internal state of the program. This plugin comes into its own when used with tools such as Pow, enabling you to get a Pry session in places not normally possible. pry-remote is also notable for having pry-nav support.
We set up the server as follows:
require 'pry-remote'
class Foo
def initialize(x, y)
binding.remote_pry
end
end
Foo.new 10, 20
Pry-remote-em is a sophisticated EventMachine-based alternative to pry-remote. It adds user
authentication and SSL support along with tab-completion and paging. It also allows multiple clients to connect to the same server, and multiple servers
to run on the same computer and even within the same process. pry-remote-em
is one of the most exciting projects in the Pry ecosystem, as it opens up
possibilities for multi-user remote-debugging/exploration, as well as educational applications. It is also just fun to interact with other programmers in
a live environment. One limitation of pry-remote-em
at the moment is the lack of pry-nav support, but this will be added in the future.
Starting the pry-remote-em server:
require 'pry-remote-em/server'
class Foo
def initialize(x, y)
binding.remote_pry_em
end
end
EM.run { Foo.new 10, 20 }
Pry-stack_explorer is a powerful plugin that enables navigation of your program's call-stack. From
the point a Pry session is started, you can move up the stack through parent frames, examine state, and even evaluate code. Unlike some other debuggers,
pry-stack_explorer incurs no runtime cost and enables navigation right up the call-stack to the birth of the program. Together with the
pry-nav plugin, it should provide the user with a fairly complete and fast debugging experience in
Ruby 1.9.2+ MRI. Pry-stack_explorer provides the show-stack
comand as well as up
and down
[1] (pry) main: 0> show-stack
Showing all accessible frames in stack (5 in total):
--
=> #0 [method] gamma <Object#gamma()>
#1 [method] beta <Object#beta()>
#2 [method] alpha <Object#alpha()>
#3 [eval] <main>
#4 [top] <main>
Pry-exception_explorer is an interactive error console for MRI Ruby 1.9.2+ inspired by the Hammertime gem, which was in turn inspired by consoles found in the Lisp and Smalltalk environments. Unlike the Hammertime gem, we are dropped into the actual context of the exception (with full access to local state) and can even walk the stack (using pry-stack_explorer, discussed above) to isolate the cause of the exception. Rudimentary support for some C-level exceptions is also provided and activated with a command line switch. Another feature of pry-exception_explorer is the ability to define exactly when it kicks-in. This can be as simple as specifying an exception type, or as sophisticated as an assertion over the entire state of the stack. The Plymouth gem works by defining a number of stack assertions for each of the testing libraries it supports. In the example below, we configure a stack assertion so that exception explorer starts when an ArgumentError is raised, but only if the exception context is an instance of MyClass and the parent's context is an instance of MyCallingClass:
EE.intercept do |frame, ex|
ex.is_a?(ArgumentError) && frame.klass.is_a?(MyClass)) &&
frame.prev.klass.is_a?(MyCallingClass)
end
However, this plugin has been deprecated in favor of pre-rescue.
Author: EnvyGeeks Ruby versions: 1.8.7+, 1.9+Pry-VTerm_Aliases brings your bash and zsh aliases into Pry as known shell commands.
Author: Conrad Irwin Ruby versions: allPry-syntax-hacks adds some syntactic sugar to Pry. Most usefully it allows you to look at instance variables of objects: user.@password
, call private/protected methods on objects: user.!hash_password('test')
. It also lets you access methods: passwords.map user.&hash_password
, and access variables in previously active pry bindings (a.la. cd
): puts ../a
.
Pry-em adds an em:
command which allows you to run code in an EventMachine context. It also waits for asynchronous operations to complete, and binds to the callback
and errback
of deferrables.
Ruby versions: all
Pry Theme plugin helps you to customize your Pry colors via prytheme
files. It adds pry-theme
command, which allows you to test themes on the fly and and install new ones.
Put your Pry theme in ~/.pry/themes
directory and set it up in your config:
# ~/.pryrc
Pry.config.theme = "theme-name"
Ruby versions: all
Pry Toys adds easy ways to create complex throwaway Ruby object in pry. Now you can quickly create Array of Floats:
Array.toy(3, Float) # => [1.0, 2.0, 3.0]
or Hash with 300 keys:
Hash.toy(300) # => { a: 1, b: 2, ..., kn: 300 }
or String with 2 words:
String.toy(2) # => "ttttttt oooo"
After gem is installed, these toy / throwaway Ruby objects are going to be available for creation when pry is started. To learn more about other arguments you can use to customize toy objects, click here
Author: Brandon WeaverRuby versions: all
Pry Macro allows you to record a workflow, define a command, and save macros to your .pryrc. This works with both plain ruby and pry commands.
[1] pry(main)> record
[2] pry(main)> 1
=> 1
[4] pry(main)> ls
self.methods: inspect to_s
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
[5] pry(main)> stop -n testing -d 'A test command!'
Run it like any other command:
[6] pry(main)> testing
=> 1
self.methods: inspect to_s
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
Like it? You can save it and have it automatically append to your PryRC:
[10] pry(main)> save-macro testing
This is the old debugging plugin for Ruby 1.9. Still useful to aid upgrading or for legacy code.
Author: Sudhagar Ruby versions: 2.0+ MRIPry State lets you can see the values of the instance and local variables in a pry session.
[1] pry(#<UsersFetcherService>)> n
From: /Users/sudhagars/Projects/authentication-service/app/services/users_fetcher_service.rb @ line 17 UsersFetcherService#fetch:
11: def fetch
12: a = 'dummy string'
13: b = ['dummy', 'array']
14: binding.pry
15: apply_access_type_filter
16: apply_third_party_filter
=> 17: reject_protected_auth
18: sort_auths
19: auths
20: end
@user #<User:0x007fd7da194790>
@access_type_filter "owner"
@third_party_filter len:0 []
@auths len:3 [#<Auth:0x007fd7d6fb55a8 @new_record=false, @attrib...
a "dummy string"
b len:2 ["dummy", "array"]
Pry Inline enables the inline variables view like RubyMine.
From: /Users/seikichi/src/book/ror-tutorial/sample_app/app/controllers/users_controller.rb @ line 54 UsersController#following:
49: def following
50: @title = "Following" # @title: "Following"
51: @user = User.find(params[:id]) # @user: #<User id: 1751, name: "Person 68", email: "[email protected]", created_at: "2015-09-20 05:58:40", updat
52: @users = @user.followed_users.paginate(page: params[:page]) # @users: #<ActiveRecord::AssociationRelation [#<User id: 1752, name: "Person 69", email
53: binding.pry
=> 54: render 'show_follow'
55: end
[1] pry(#<UsersController>)>
Author: sagotsky Ruby versions: 2.0+ MRI
Pry Loudmouth makes pry sessions more visible. It changes the process title and emits an alarm character whenever the session begins.