pry-byebug 1.3.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +8 -3
- data/README.md +30 -38
- data/lib/pry-byebug/base.rb +4 -4
- data/lib/pry-byebug/breakpoints.rb +44 -30
- data/lib/pry-byebug/cli.rb +1 -1
- data/lib/pry-byebug/commands.rb +115 -87
- data/lib/pry-byebug/processor.rb +64 -86
- data/lib/pry-byebug/pry_remote_ext.rb +11 -12
- data/lib/pry-byebug/version.rb +1 -1
- data/pry-byebug.gemspec +3 -3
- data/test/base_test.rb +5 -3
- data/test/breakpoints_test.rb +102 -3
- data/test/commands_test.rb +35 -136
- data/test/examples/break1.rb +9 -6
- data/test/examples/break2.rb +7 -4
- data/test/examples/stepping.rb +12 -8
- data/test/processor_test.rb +22 -2
- data/test/pry_ext_test.rb +0 -2
- data/test/pry_remote_ext_test.rb +0 -2
- data/test/test_helper.rb +12 -11
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8123f22dc42ff24f284f47d77bdf74679b8025c2
|
4
|
+
data.tar.gz: 1803eaf3cc4e019e64ce84835bb0a288cef8cebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eecedab14af1c1eddfc82d5828a4418a239691b6ef27f67e4340458054e0646edd049ded5cde2dc1ef10efe72bf2abb70b4c759a1145710c2e25b9e59b3faeec
|
7
|
+
data.tar.gz: 33135d020dc22bf50e1a8f57b39a5dce8f5e8c1373cd8f380500a210b8199bf05a5c90084f286c2d003b2379703e025fe63d80465b2007dfa3d10b68849a0495
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 2.0.0 (2014-01-09)
|
2
|
+
|
3
|
+
- Improvements:
|
4
|
+
* Compatibility with byebug 3
|
5
|
+
* Now pry starts at the first line after binding.pry, not at binding.pry
|
6
|
+
- Bugfixes:
|
7
|
+
* 'continue' doesn't finish pry instance (issue #13)
|
8
|
+
|
9
|
+
|
1
10
|
## 1.3.3 (2014-25-06)
|
2
11
|
|
3
12
|
* Relaxes pry dependency to support pry 0.10 series and further minor version
|
data/Gemfile
CHANGED
@@ -2,8 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'rake', '~> 10.
|
5
|
+
gem 'rake', '~> 10.3'
|
6
6
|
|
7
|
-
group :development
|
8
|
-
gem '
|
7
|
+
group :development do
|
8
|
+
gem 'rubocop', '~> 0.25'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'mocha', '~> 1.1'
|
13
|
+
gem 'minitest', '~> 5.4'
|
9
14
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
pry-byebug
|
2
|
-
|
1
|
+
# pry-byebug
|
2
|
+
[![Version][VersionBadge]][VersionURL]
|
3
|
+
[![Build][TravisBadge]][TravisURL]
|
4
|
+
[![Gittip][GittipBadge]][GittipURL]
|
3
5
|
|
4
6
|
_Fast execution control in Pry_
|
5
7
|
|
@@ -15,9 +17,6 @@ def some_method
|
|
15
17
|
end
|
16
18
|
```
|
17
19
|
|
18
|
-
For a complete debugging environment, add
|
19
|
-
[pry-stack_explorer][pry-stack_explorer] for call-stack frame navigation.
|
20
|
-
|
21
20
|
|
22
21
|
## Installation
|
23
22
|
|
@@ -59,25 +58,24 @@ conditional breakpoint. Edit existing breakpoints via various flags.
|
|
59
58
|
|
60
59
|
Examples:
|
61
60
|
|
62
|
-
```
|
63
|
-
break SomeClass#run Break at the start of `SomeClass#run`.
|
64
|
-
break Foo#bar if baz? Break at `Foo#bar` only if `baz?`.
|
65
|
-
break app/models/user.rb:15 Break at line 15 in user.rb.
|
66
|
-
break 14 Break at line 14 in the current file.
|
61
|
+
```ruby
|
62
|
+
break SomeClass#run # Break at the start of `SomeClass#run`.
|
63
|
+
break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`.
|
64
|
+
break app/models/user.rb:15 # Break at line 15 in user.rb.
|
65
|
+
break 14 # Break at line 14 in the current file.
|
67
66
|
|
68
|
-
break --condition 4 x > 2 Change condition on breakpoint #4 to 'x > 2'.
|
69
|
-
break --condition 3 Remove the condition on breakpoint #3.
|
67
|
+
break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'.
|
68
|
+
break --condition 3 # Remove the condition on breakpoint #3.
|
70
69
|
|
71
|
-
break --delete 5 Delete breakpoint #5.
|
72
|
-
break --disable-all Disable all breakpoints.
|
70
|
+
break --delete 5 # Delete breakpoint #5.
|
71
|
+
break --disable-all # Disable all breakpoints.
|
73
72
|
|
74
|
-
break List all breakpoints. (Same as `breakpoints`)
|
75
|
-
break --show 2 Show details about breakpoint #2.
|
73
|
+
break # List all breakpoints. (Same as `breakpoints`)
|
74
|
+
break --show 2 # Show details about breakpoint #2.
|
76
75
|
```
|
77
76
|
|
78
77
|
Type `break --help` from a Pry session to see all available options.
|
79
78
|
|
80
|
-
|
81
79
|
**breakpoints**: List all defined breakpoints. Pass `-v` or `--verbose` to see
|
82
80
|
the source code around each breakpoint.
|
83
81
|
|
@@ -88,28 +86,22 @@ Only supports MRI 2.0.0 or newer. For MRI 1.9.3 or older, use
|
|
88
86
|
[pry-debugger][pry-debugger]
|
89
87
|
|
90
88
|
|
91
|
-
##
|
89
|
+
## Credits
|
92
90
|
|
93
|
-
*
|
94
|
-
|
95
|
-
|
96
|
-
*
|
97
|
-
* Benjamin R. Haskell (@benizi)
|
98
|
-
* Joshua Hou (@jshou)
|
99
|
-
* ...and others who helped with [pry-nav][pry-nav]
|
91
|
+
* Gopal Patel (@nixme), creator of [pry-debugger][pry-debugger], and everybody
|
92
|
+
who contributed to it. pry-byebug is a fork of pry-debugger so it wouldn't
|
93
|
+
exist as it is without those contributions.
|
94
|
+
* John Mair (@banister), creator of [pry][pry].
|
100
95
|
|
101
|
-
Patches and bug reports are welcome.
|
102
|
-
file an [issue][issues]. [Project changelog][changelog].
|
96
|
+
Patches and bug reports are welcome.
|
103
97
|
|
104
|
-
[pry]:
|
105
|
-
[byebug]:
|
106
|
-
[pry-debugger]:
|
98
|
+
[pry]: http://pry.github.com
|
99
|
+
[byebug]: https://github.com/deivid-rodriguez/byebug
|
100
|
+
[pry-debugger]: https://github.com/nixme/pry-debugger
|
107
101
|
[pry-stack_explorer]: https://github.com/pry/pry-stack_explorer
|
108
|
-
[
|
109
|
-
[
|
110
|
-
[
|
111
|
-
[
|
112
|
-
[
|
113
|
-
[
|
114
|
-
[3]: https://secure.travis-ci.org/deivid-rodriguez/pry-byebug.png
|
115
|
-
[4]: http://travis-ci.org/deivid-rodriguez/pry-byebug
|
102
|
+
[VersionBadge]: https://badge.fury.io/rb/pry-byebug.png
|
103
|
+
[VersionURL]: http://badge.fury.io/rb/pry-byebug
|
104
|
+
[TravisBadge]: https://secure.travis-ci.org/deivid-rodriguez/pry-byebug.png
|
105
|
+
[TravisURL]: http://travis-ci.org/deivid-rodriguez/pry-byebug
|
106
|
+
[GittipBadge]: http://img.shields.io/gittip/deivid-rodriguez.svg
|
107
|
+
[GittipURL]: https://www.gittip.com/deivid-rodriguez
|
data/lib/pry-byebug/base.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module PryByebug
|
2
|
-
|
3
|
-
|
2
|
+
#
|
4
3
|
# Checks that a binding is in a local file context. Extracted from
|
5
|
-
#
|
4
|
+
#
|
6
5
|
def check_file_context(target)
|
7
6
|
file = target.eval('__FILE__')
|
8
|
-
file == Pry.eval_path || (file
|
7
|
+
file == Pry.eval_path || !Pry::Helpers::BaseHelpers.not_a_real_file?(file)
|
9
8
|
end
|
9
|
+
module_function :check_file_context
|
10
10
|
|
11
11
|
# Reference to currently running pry-remote server. Used by the processor.
|
12
12
|
attr_accessor :current_remote_server
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module PryByebug
|
2
|
-
|
2
|
+
#
|
3
3
|
# Wrapper for Byebug.breakpoints that respects our Processor and has better
|
4
4
|
# failure behavior. Acts as an Enumerable.
|
5
5
|
#
|
@@ -7,6 +7,9 @@ module PryByebug
|
|
7
7
|
extend Enumerable
|
8
8
|
extend self
|
9
9
|
|
10
|
+
#
|
11
|
+
# Breakpoint in a file:line location
|
12
|
+
#
|
10
13
|
class FileBreakpoint < SimpleDelegator
|
11
14
|
def source_code
|
12
15
|
Pry::Code.from_file(source).around(pos, 3).with_marker(pos)
|
@@ -17,6 +20,9 @@ module PryByebug
|
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
23
|
+
#
|
24
|
+
# Breakpoint in a Class#method location
|
25
|
+
#
|
20
26
|
class MethodBreakpoint < SimpleDelegator
|
21
27
|
def initialize(byebug_bp, method)
|
22
28
|
__setobj__ byebug_bp
|
@@ -36,32 +42,35 @@ module PryByebug
|
|
36
42
|
@breakpoints ||= []
|
37
43
|
end
|
38
44
|
|
39
|
-
#
|
45
|
+
#
|
46
|
+
# Adds a method breakpoint.
|
47
|
+
#
|
40
48
|
def add_method(method, expression = nil)
|
41
49
|
validate_expression expression
|
42
|
-
Pry.processor.debugging = true
|
43
50
|
owner, name = method.split(/[\.#]/)
|
44
|
-
byebug_bp = Byebug.
|
51
|
+
byebug_bp = Byebug::Breakpoint.add(owner, name.to_sym, expression)
|
45
52
|
bp = MethodBreakpoint.new byebug_bp, method
|
46
53
|
breakpoints << bp
|
47
54
|
bp
|
48
55
|
end
|
49
56
|
|
50
|
-
#
|
57
|
+
#
|
58
|
+
# Adds a file breakpoint.
|
59
|
+
#
|
51
60
|
def add_file(file, line, expression = nil)
|
52
61
|
real_file = (file != Pry.eval_path)
|
53
|
-
|
62
|
+
fail(ArgumentError, 'Invalid file!') if real_file && !File.exist?(file)
|
54
63
|
validate_expression expression
|
55
64
|
|
56
|
-
Pry.processor.debugging = true
|
57
|
-
|
58
65
|
path = (real_file ? File.expand_path(file) : file)
|
59
|
-
bp = FileBreakpoint.new Byebug.
|
66
|
+
bp = FileBreakpoint.new Byebug::Breakpoint.add(path, line, expression)
|
60
67
|
breakpoints << bp
|
61
68
|
bp
|
62
69
|
end
|
63
70
|
|
64
|
-
#
|
71
|
+
#
|
72
|
+
# Changes the conditional expression for a breakpoint.
|
73
|
+
#
|
65
74
|
def change(id, expression = nil)
|
66
75
|
validate_expression expression
|
67
76
|
|
@@ -70,33 +79,40 @@ module PryByebug
|
|
70
79
|
breakpoint
|
71
80
|
end
|
72
81
|
|
73
|
-
#
|
82
|
+
#
|
83
|
+
# Deletes an existing breakpoint with the given ID.
|
84
|
+
#
|
74
85
|
def delete(id)
|
75
|
-
deleted = Byebug.started? &&
|
76
|
-
Byebug.
|
77
|
-
|
78
|
-
raise ArgumentError, "No breakpoint ##{id}" if not deleted
|
79
|
-
Pry.processor.debugging = false if to_a.empty?
|
86
|
+
deleted = Byebug.started? &&
|
87
|
+
Byebug::Breakpoint.remove(id) && breakpoints.delete(find_by_id(id))
|
88
|
+
fail(ArgumentError, "No breakpoint ##{id}") unless deleted
|
80
89
|
end
|
81
90
|
|
82
|
-
#
|
83
|
-
|
91
|
+
#
|
92
|
+
# Deletes all breakpoints.
|
93
|
+
#
|
94
|
+
def delete_all
|
84
95
|
@breakpoints = []
|
85
96
|
Byebug.breakpoints.clear if Byebug.started?
|
86
|
-
Pry.processor.debugging = false
|
87
97
|
end
|
88
98
|
|
89
|
-
#
|
99
|
+
#
|
100
|
+
# Enables a disabled breakpoint with the given ID.
|
101
|
+
#
|
90
102
|
def enable(id)
|
91
103
|
change_status id, true
|
92
104
|
end
|
93
105
|
|
94
|
-
#
|
106
|
+
#
|
107
|
+
# Disables a breakpoint with the given ID.
|
108
|
+
#
|
95
109
|
def disable(id)
|
96
110
|
change_status id, false
|
97
111
|
end
|
98
112
|
|
99
|
-
#
|
113
|
+
#
|
114
|
+
# Disables all breakpoints.
|
115
|
+
#
|
100
116
|
def disable_all
|
101
117
|
each do |breakpoint|
|
102
118
|
breakpoint.enabled = false
|
@@ -117,12 +133,11 @@ module PryByebug
|
|
117
133
|
|
118
134
|
def find_by_id(id)
|
119
135
|
breakpoint = find { |b| b.id == id }
|
120
|
-
|
136
|
+
fail(ArgumentError, "No breakpoint ##{id}!") unless breakpoint
|
121
137
|
breakpoint
|
122
138
|
end
|
123
139
|
|
124
|
-
|
125
|
-
private
|
140
|
+
private
|
126
141
|
|
127
142
|
def change_status(id, enabled = true)
|
128
143
|
breakpoint = find_by_id(id)
|
@@ -130,11 +145,10 @@ module PryByebug
|
|
130
145
|
breakpoint
|
131
146
|
end
|
132
147
|
|
133
|
-
def validate_expression(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
148
|
+
def validate_expression(exp)
|
149
|
+
return unless exp && (exp.empty? || !Pry::Code.complete_expression?(exp))
|
150
|
+
|
151
|
+
fail("Invalid breakpoint conditional: #{expression}")
|
138
152
|
end
|
139
153
|
end
|
140
154
|
end
|
data/lib/pry-byebug/cli.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'pry-byebug'
|
1
|
+
require 'pry-byebug'
|
data/lib/pry-byebug/commands.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'pry'
|
2
2
|
require 'pry-byebug/breakpoints'
|
3
3
|
|
4
|
+
#
|
5
|
+
# Container for all of pry-byebug's functionality
|
6
|
+
#
|
4
7
|
module PryByebug
|
5
8
|
Commands = Pry::CommandSet.new do
|
6
9
|
create_command 'step' do
|
@@ -73,7 +76,7 @@ module PryByebug
|
|
73
76
|
|
74
77
|
def process
|
75
78
|
check_file_context
|
76
|
-
|
79
|
+
breakout_navigation :continue
|
77
80
|
end
|
78
81
|
end
|
79
82
|
alias_command 'c', 'continue'
|
@@ -95,91 +98,100 @@ module PryByebug
|
|
95
98
|
|
96
99
|
Examples:
|
97
100
|
|
98
|
-
break SomeClass#run
|
99
|
-
break Foo#bar if baz?
|
100
|
-
break app/models/user.rb:15
|
101
|
-
break 14
|
101
|
+
break SomeClass#run Break at the start of `SomeClass#run`.
|
102
|
+
break Foo#bar if baz? Break at `Foo#bar` only if `baz?`.
|
103
|
+
break app/models/user.rb:15 Break at line 15 in user.rb.
|
104
|
+
break 14 Break at line 14 in the current file.
|
102
105
|
|
103
|
-
break --condition 4 x > 2
|
104
|
-
break --condition 3
|
106
|
+
break --condition 4 x > 2 Add/change condition on breakpoint #4.
|
107
|
+
break --condition 3 Remove the condition on breakpoint #3.
|
105
108
|
|
106
|
-
break --delete 5
|
107
|
-
break --disable-all
|
109
|
+
break --delete 5 Delete breakpoint #5.
|
110
|
+
break --disable-all Disable all breakpoints.
|
108
111
|
|
109
|
-
break
|
110
|
-
break --show 2
|
112
|
+
break List all breakpoints.
|
113
|
+
break --show 2 Show details about breakpoint #2.
|
111
114
|
BANNER
|
112
115
|
|
113
116
|
def options(opt)
|
114
|
-
|
115
|
-
|
116
|
-
opt.on :
|
117
|
-
opt.on :
|
118
|
-
opt.on :
|
119
|
-
opt.on
|
120
|
-
opt.on
|
121
|
-
|
117
|
+
defaults = { argument: true, as: Integer }
|
118
|
+
|
119
|
+
opt.on :c, :condition, 'Change condition of a breakpoint.', defaults
|
120
|
+
opt.on :s, :show, 'Show breakpoint details and source.', defaults
|
121
|
+
opt.on :D, :delete, 'Delete a breakpoint.', defaults
|
122
|
+
opt.on :d, :disable, 'Disable a breakpoint.', defaults
|
123
|
+
opt.on :e, :enable, 'Enable a disabled breakpoint.', defaults
|
124
|
+
opt.on :'disable-all', 'Disable all breakpoints.'
|
125
|
+
opt.on :'delete-all', 'Delete all breakpoints.'
|
122
126
|
end
|
123
127
|
|
124
128
|
def process
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
:'delete-all' => :clear
|
132
|
-
}.each do |action, method|
|
133
|
-
if opts.present?(action)
|
134
|
-
Breakpoints.__send__ method, *(method == action ? [opts[action]] : [])
|
135
|
-
return run 'breakpoints'
|
136
|
-
end
|
129
|
+
all = %w(condition show delete disable enable disable-all delete-all)
|
130
|
+
all.each do |option|
|
131
|
+
next unless opts.present?(option)
|
132
|
+
|
133
|
+
method_name = "process_#{option.gsub('-', '_')}"
|
134
|
+
return send(method_name)
|
137
135
|
end
|
138
136
|
|
139
|
-
|
140
|
-
|
137
|
+
new_breakpoint unless args.empty?
|
138
|
+
end
|
139
|
+
|
140
|
+
%w(delete disable enable).each do |command|
|
141
|
+
define_method(:"process_#{command}") do
|
142
|
+
Breakpoints.send(command, opts[command])
|
141
143
|
run 'breakpoints'
|
142
|
-
|
143
|
-
|
144
|
-
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
%w(disable-all delete-all).each do |command|
|
148
|
+
method_name = command.gsub('-', '_')
|
149
|
+
define_method(:"process_#{method_name}") do
|
150
|
+
Breakpoints.send(method_name)
|
145
151
|
run 'breakpoints'
|
146
|
-
else
|
147
|
-
new_breakpoint
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
155
|
+
def process_show
|
156
|
+
print_full_breakpoint(Breakpoints.find_by_id(opts[:show]))
|
157
|
+
end
|
158
|
+
|
159
|
+
def process_condition
|
160
|
+
expr = args.empty? ? nil : args.join(' ')
|
161
|
+
Breakpoints.change(opts[:condition], expr)
|
162
|
+
end
|
163
|
+
|
151
164
|
def new_breakpoint
|
152
165
|
place = args.shift
|
153
166
|
condition = args.join(' ') if 'if' == args.shift
|
154
167
|
|
155
168
|
bp =
|
156
169
|
case place
|
157
|
-
when /^(\d+)$/
|
158
|
-
line =
|
159
|
-
|
160
|
-
|
161
|
-
|
170
|
+
when /^(\d+)$/
|
171
|
+
line = Regexp.last_match[1]
|
172
|
+
errmsg = 'Line number declaration valid only in a file context.'
|
173
|
+
check_file_context(errmsg)
|
174
|
+
|
162
175
|
Breakpoints.add_file(target.eval('__FILE__'), line.to_i, condition)
|
163
|
-
when /^(.+):(\d+)$/
|
164
|
-
|
176
|
+
when /^(.+):(\d+)$/
|
177
|
+
file, lineno = Regexp.last_match[1], Regexp.last_match[2].to_i
|
178
|
+
Breakpoints.add_file(file, lineno, condition)
|
165
179
|
when /^(.*)[.#].+$/ # Method or class name
|
166
|
-
if
|
167
|
-
|
168
|
-
|
169
|
-
end
|
180
|
+
if Regexp.last_match[1].strip.empty?
|
181
|
+
errmsg = 'Method name declaration valid only in a file context.'
|
182
|
+
check_file_context(errmsg)
|
170
183
|
place = target.eval('self.class.to_s') + place
|
171
184
|
end
|
172
|
-
Breakpoints.add_method(place,condition)
|
185
|
+
Breakpoints.add_method(place, condition)
|
173
186
|
else
|
174
|
-
|
187
|
+
fail(ArgumentError, 'Cannot identify arguments as breakpoint')
|
175
188
|
end
|
176
189
|
|
177
|
-
print_full_breakpoint
|
190
|
+
print_full_breakpoint(bp)
|
178
191
|
end
|
179
192
|
end
|
180
193
|
alias_command 'breakpoint', 'break'
|
181
194
|
|
182
|
-
|
183
195
|
create_command 'breakpoints' do
|
184
196
|
description 'List defined breakpoints.'
|
185
197
|
|
@@ -195,27 +207,16 @@ module PryByebug
|
|
195
207
|
end
|
196
208
|
|
197
209
|
def process
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
header = "#{' ' * (max_width - 1)}# Enabled At "
|
204
|
-
|
205
|
-
output.puts
|
206
|
-
output.puts text.bold(header)
|
207
|
-
output.puts text.bold('-' * header.size)
|
208
|
-
Breakpoints.each do |breakpoint|
|
209
|
-
output.printf "%#{max_width}d ", breakpoint.id
|
210
|
-
output.print breakpoint.enabled? ? 'Yes ' : 'No '
|
211
|
-
output.print breakpoint.to_s
|
212
|
-
output.print " (if #{breakpoint.expr})" if breakpoint.expr
|
213
|
-
output.puts
|
214
|
-
end
|
215
|
-
output.puts
|
216
|
-
end
|
210
|
+
errmsg = 'No breakpoints defined.'
|
211
|
+
return output.puts text.bold(errmsg) unless Breakpoints.count > 0
|
212
|
+
|
213
|
+
if opts.verbose?
|
214
|
+
Breakpoints.each { |b| print_full_breakpoint(b) }
|
217
215
|
else
|
218
|
-
output.puts
|
216
|
+
output.puts
|
217
|
+
print_breakpoints_header
|
218
|
+
Breakpoints.each { |b| print_short_breakpoint(b) }
|
219
|
+
output.puts
|
219
220
|
end
|
220
221
|
end
|
221
222
|
end
|
@@ -224,28 +225,27 @@ module PryByebug
|
|
224
225
|
helpers do
|
225
226
|
def breakout_navigation(action, times = nil)
|
226
227
|
_pry_.binding_stack.clear # Clear the binding stack.
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
:pry => _pry_
|
231
|
-
}
|
228
|
+
|
229
|
+
# Break out of the REPL loop and signal tracer
|
230
|
+
throw :breakout_nav, action: action, times: times, pry: _pry_
|
232
231
|
end
|
233
232
|
|
234
233
|
# Ensures that a command is executed in a local file context.
|
235
|
-
def check_file_context
|
236
|
-
|
237
|
-
|
238
|
-
end
|
234
|
+
def check_file_context(e = nil)
|
235
|
+
e ||= 'Cannot find local context. Did you use `binding.pry`?'
|
236
|
+
fail(Pry::CommandError, e) unless PryByebug.check_file_context(target)
|
239
237
|
end
|
240
238
|
|
241
|
-
#
|
242
|
-
#
|
239
|
+
#
|
240
|
+
# Print out full information about a breakpoint.
|
241
|
+
#
|
242
|
+
# Includes surrounding code at that point.
|
243
|
+
#
|
243
244
|
def print_full_breakpoint(breakpoint)
|
244
|
-
line = breakpoint.pos
|
245
245
|
output.print text.bold("Breakpoint #{breakpoint.id}: ")
|
246
|
-
output.print "#{breakpoint
|
246
|
+
output.print "#{breakpoint} "
|
247
247
|
output.print breakpoint.enabled? ? '(Enabled)' : '(Disabled)'
|
248
|
-
output.puts
|
248
|
+
output.puts ' :'
|
249
249
|
if (expr = breakpoint.expr)
|
250
250
|
output.puts "#{text.bold('Condition:')} #{expr}"
|
251
251
|
end
|
@@ -253,6 +253,34 @@ module PryByebug
|
|
253
253
|
output.puts breakpoint.source_code.with_line_numbers.to_s
|
254
254
|
output.puts
|
255
255
|
end
|
256
|
+
|
257
|
+
#
|
258
|
+
# Print out concise information about a breakpoint.
|
259
|
+
#
|
260
|
+
def print_short_breakpoint(breakpoint)
|
261
|
+
output.printf "%#{max_width}d ", breakpoint.id
|
262
|
+
output.print breakpoint.enabled? ? 'Yes ' : 'No '
|
263
|
+
output.print breakpoint.to_s
|
264
|
+
output.print " (if #{breakpoint.expr})" if breakpoint.expr
|
265
|
+
output.puts
|
266
|
+
end
|
267
|
+
|
268
|
+
#
|
269
|
+
# Prints a header for the breakpoint list.
|
270
|
+
#
|
271
|
+
def print_breakpoints_header
|
272
|
+
header = "#{' ' * (max_width - 1)}# Enabled At "
|
273
|
+
|
274
|
+
output.puts text.bold(header)
|
275
|
+
output.puts text.bold('-' * header.size)
|
276
|
+
end
|
277
|
+
|
278
|
+
#
|
279
|
+
# Max width of breakpoints id column
|
280
|
+
#
|
281
|
+
def max_width
|
282
|
+
[Math.log10(Breakpoints.count).ceil, 1].max
|
283
|
+
end
|
256
284
|
end
|
257
285
|
end
|
258
286
|
end
|