├── .gitignore ├── Gemfile ├── examples └── foo.rb ├── lib └── ruby-debug │ └── pry.rb ├── README.md ├── ruby-debug-pry.gemspec ├── LICENSE └── Gemfile.lock /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | gem "pry", ">= 0.8.3" 4 | 5 | platform :mri_18 do 6 | gem "ruby-debug", "~> 0.10.4" 7 | end 8 | 9 | platform :mri_19 do 10 | gem "ruby-debug19", "~> 0.11.6", :require => "ruby-debug" 11 | end 12 | -------------------------------------------------------------------------------- /examples/foo.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | Bundler.require 4 | $:.unshift(File.dirname(__FILE__) + "/../lib") 5 | require "ruby-debug/pry" 6 | 7 | class Foo 8 | attr_accessor :bar 9 | 10 | def initialize(bar) 11 | @bar = bar 12 | end 13 | end 14 | 15 | foo = Foo.new(5) 16 | debugger 17 | foo.bar += 10 -------------------------------------------------------------------------------- /lib/ruby-debug/pry.rb: -------------------------------------------------------------------------------- 1 | require 'pry' 2 | require 'ruby-debug' 3 | 4 | module Debugger 5 | class PryCommand < Command 6 | def regexp 7 | /^\s* pry 8 | (?:\s+(-d))? 9 | \s*$/x 10 | end 11 | 12 | def execute 13 | unless @state.interface.kind_of?(LocalInterface) 14 | print "Command is available only in local mode.\n" 15 | throw :debug_error 16 | end 17 | 18 | get_binding.pry 19 | end 20 | 21 | class << self 22 | def help_command 23 | 'pry' 24 | end 25 | 26 | def help(cmd) 27 | %{ 28 | pry\tstarts an Pry session. 29 | } 30 | end 31 | end 32 | 33 | end 34 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This gem adds a "pry" command to ruby-debug. 2 | 3 | To see it in action, run `ruby examples/foo.rb` and type "pry" at the debug prompt. 4 | 5 | To use it in a project, add this to your Gemfile: 6 | 7 | gem "ruby-debug-pry", :require => "ruby-debug/pry" 8 | 9 | For more information on pry, read [this article](http://banisterfiend.wordpress.com/2011/01/27/turning-irb-on-its-head-with-pry/). 10 | 11 | This has been tested on Ruby 1.8.7 p334 and Ruby 1.9.2 p136 and seems to work. 12 | 13 | # Future Steps # 14 | 15 | Right now I don't have any of the additional features that ruby-debug's IRB command has. I don't really use them, but it would be nice to have them. 16 | 17 | * `next`, `step`, and `cont` support 18 | * add `autopry` configuration variable 19 | * make debugger state accessible as a global variable -------------------------------------------------------------------------------- /ruby-debug-pry.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib/', __FILE__) 3 | $:.unshift lib unless $:.include?(lib) 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "ruby-debug-pry" 7 | s.version = "0.0.3" 8 | s.platform = Gem::Platform::RUBY 9 | s.authors = ["Andrew O'Brien"] 10 | s.email = ["obrien.andrew@gmail.com"] 11 | s.homepage = "http://github.com/AndrewO/ruby-debug-pry" 12 | s.summary = "Adds a 'pry' command to ruby-debug" 13 | s.description = "Pry is a featureful REPL that looks like it can work nicely with ruby-debug. This gem adds a 'pry' command to invoke Pry in the current context." 14 | 15 | s.required_rubygems_version = ">= 1.3.6" 16 | 17 | 18 | s.add_dependency("pry", ">= 0.8.3") 19 | 20 | # s.add_dependency("ruby-debug", "~> 0.10.4") if RUBY_VERSION < "1.9" 21 | # s.add_dependency("ruby-debug19", "~> 0.11.6") if RUBY_VERSION >= "1.9" 22 | 23 | s.files = Dir.glob("{lib}/**/*") + %w(LICENSE README.md) 24 | s.require_path = 'lib' 25 | end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | License 2 | ------- 3 | 4 | (The MIT License) 5 | 6 | Copyright (c) 2011 Andrew O'Brien 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | 'Software'), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | archive-tar-minitar (0.5.2) 5 | coderay (0.9.7) 6 | columnize (0.3.2) 7 | linecache (0.43) 8 | linecache19 (0.5.12) 9 | ruby_core_source (>= 0.1.4) 10 | method_source (0.4.1) 11 | ruby_parser (>= 2.0.5) 12 | pry (0.8.3) 13 | coderay (>= 0.9.7) 14 | method_source (>= 0.4.0) 15 | ruby_parser (>= 2.0.5) 16 | slop (>= 1.5.3) 17 | ruby-debug (0.10.4) 18 | columnize (>= 0.1) 19 | ruby-debug-base (~> 0.10.4.0) 20 | ruby-debug-base (0.10.4) 21 | linecache (>= 0.3) 22 | ruby-debug-base19 (0.11.25) 23 | columnize (>= 0.3.1) 24 | linecache19 (>= 0.5.11) 25 | ruby_core_source (>= 0.1.4) 26 | ruby-debug19 (0.11.6) 27 | columnize (>= 0.3.1) 28 | linecache19 (>= 0.5.11) 29 | ruby-debug-base19 (>= 0.11.19) 30 | ruby_core_source (0.1.5) 31 | archive-tar-minitar (>= 0.5.2) 32 | ruby_parser (2.0.6) 33 | sexp_processor (~> 3.0) 34 | sexp_processor (3.0.5) 35 | slop (1.5.3) 36 | 37 | PLATFORMS 38 | ruby 39 | 40 | DEPENDENCIES 41 | pry (>= 0.8.3) 42 | ruby-debug (~> 0.10.4) 43 | ruby-debug19 (~> 0.11.6) 44 | --------------------------------------------------------------------------------