pry-byebug 3.1.0 → 3.2.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/CHANGELOG.md +17 -1
- data/README.md +7 -6
- data/lib/byebug/processors/pry_processor.rb +3 -5
- data/lib/pry-byebug.rb +1 -3
- data/lib/pry-byebug/cli.rb +1 -2
- data/lib/pry-byebug/commands.rb +8 -0
- data/lib/pry-byebug/commands/breakpoint.rb +135 -0
- data/lib/pry-byebug/commands/continue.rb +37 -0
- data/lib/pry-byebug/commands/down.rb +33 -0
- data/lib/pry-byebug/commands/finish.rb +26 -0
- data/lib/pry-byebug/commands/frame.rb +33 -0
- data/lib/pry-byebug/commands/next.rb +37 -0
- data/lib/pry-byebug/commands/step.rb +32 -0
- data/lib/pry-byebug/commands/up.rb +33 -0
- data/lib/pry-byebug/helpers/breakpoints.rb +84 -0
- data/lib/pry-byebug/helpers/multiline.rb +21 -0
- data/lib/pry-byebug/helpers/navigation.rb +17 -0
- data/lib/pry-byebug/version.rb +1 -1
- data/lib/pry/byebug/breakpoints.rb +4 -0
- metadata +23 -45
- data/.gitignore +0 -18
- data/.rubocop.yml +0 -14
- data/.rubocop_todo.yml +0 -20
- data/.travis.yml +0 -9
- data/Gemfile +0 -14
- data/Rakefile +0 -17
- data/lib/pry/commands/breakpoint.rb +0 -216
- data/lib/pry/commands/frames.rb +0 -79
- data/lib/pry/commands/stepping.rb +0 -88
- data/pry-byebug.gemspec +0 -23
- data/test/base_test.rb +0 -16
- data/test/breakpoints_test.rb +0 -146
- data/test/examples/break1.rb +0 -23
- data/test/examples/break2.rb +0 -21
- data/test/examples/deep_stepping.rb +0 -9
- data/test/examples/frames.rb +0 -14
- data/test/examples/stepping.rb +0 -29
- data/test/frames_test.rb +0 -58
- data/test/processor_test.rb +0 -40
- data/test/pry_ext_test.rb +0 -4
- data/test/pry_remote_ext_test.rb +0 -4
- data/test/stepping_test.rb +0 -78
- data/test/test_helper.rb +0 -35
data/lib/pry/commands/frames.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Main Pry class.
|
3
|
-
#
|
4
|
-
# We're going to add to it custom frame commands for Pry-Byebug
|
5
|
-
#
|
6
|
-
class Pry
|
7
|
-
FrameCommands = CommandSet.new do
|
8
|
-
create_command 'up' do
|
9
|
-
description 'Move current frame up.'
|
10
|
-
|
11
|
-
banner <<-BANNER
|
12
|
-
Usage: up [TIMES]
|
13
|
-
|
14
|
-
Move current frame up. By default, moves by 1 frame.
|
15
|
-
|
16
|
-
Examples:
|
17
|
-
up #=> Move up 1 frame.
|
18
|
-
up 5 #=> Move up 5 frames.
|
19
|
-
BANNER
|
20
|
-
|
21
|
-
def process
|
22
|
-
PryByebug.check_file_context(target)
|
23
|
-
|
24
|
-
frame_navigation :up, times: args.first
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
create_command 'down' do
|
29
|
-
description 'Move current frame down.'
|
30
|
-
|
31
|
-
banner <<-BANNER
|
32
|
-
Usage: down [TIMES]
|
33
|
-
|
34
|
-
Move current frame down. By default, moves by 1 frame.
|
35
|
-
|
36
|
-
Examples:
|
37
|
-
down #=> Move down 1 frame.
|
38
|
-
down 5 #=> Move down 5 frames.
|
39
|
-
BANNER
|
40
|
-
|
41
|
-
def process
|
42
|
-
PryByebug.check_file_context(target)
|
43
|
-
|
44
|
-
frame_navigation :down, times: args.first
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
create_command 'frame' do
|
49
|
-
description 'Move to specified frame #.'
|
50
|
-
|
51
|
-
banner <<-BANNER
|
52
|
-
Usage: frame [TIMES]
|
53
|
-
|
54
|
-
Move to specified frame #.
|
55
|
-
|
56
|
-
Examples:
|
57
|
-
frame #=> Show current frame #.
|
58
|
-
frame 5 #=> Move to frame 5.
|
59
|
-
BANNER
|
60
|
-
|
61
|
-
def process
|
62
|
-
PryByebug.check_file_context(target)
|
63
|
-
|
64
|
-
frame_navigation :frame, index: args.first
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
helpers do
|
69
|
-
def frame_navigation(action, options = {})
|
70
|
-
_pry_.binding_stack.clear # Clear the binding stack.
|
71
|
-
|
72
|
-
# Break out of the REPL loop and signal tracer
|
73
|
-
throw :breakout_nav, action: action, options: options, pry: _pry_
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
Pry.commands.import(FrameCommands)
|
79
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Main Pry class.
|
3
|
-
#
|
4
|
-
# We're going to add to it custom stepping commands for Pry-Byebug
|
5
|
-
#
|
6
|
-
class Pry
|
7
|
-
SteppingCommands = CommandSet.new do
|
8
|
-
create_command 'step' do
|
9
|
-
description 'Step execution into the next line or method.'
|
10
|
-
|
11
|
-
banner <<-BANNER
|
12
|
-
Usage: step [TIMES]
|
13
|
-
|
14
|
-
Step execution forward. By default, moves a single step.
|
15
|
-
|
16
|
-
Examples:
|
17
|
-
step #=> Move a single step forward.
|
18
|
-
step 5 #=> Execute the next 5 steps.
|
19
|
-
BANNER
|
20
|
-
|
21
|
-
def process
|
22
|
-
PryByebug.check_file_context(target)
|
23
|
-
|
24
|
-
breakout_navigation :step, times: args.first
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
create_command 'next' do
|
29
|
-
description 'Execute the next line within the current stack frame.'
|
30
|
-
|
31
|
-
banner <<-BANNER
|
32
|
-
Usage: next [LINES]
|
33
|
-
|
34
|
-
Step over within the same frame. By default, moves forward a single
|
35
|
-
line.
|
36
|
-
|
37
|
-
Examples:
|
38
|
-
next #=> Move a single line forward.
|
39
|
-
next 4 #=> Execute the next 4 lines.
|
40
|
-
BANNER
|
41
|
-
|
42
|
-
def process
|
43
|
-
PryByebug.check_file_context(target)
|
44
|
-
|
45
|
-
breakout_navigation :next, lines: args.first
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
create_command 'finish' do
|
50
|
-
description 'Execute until current stack frame returns.'
|
51
|
-
|
52
|
-
banner <<-BANNER
|
53
|
-
Usage: finish
|
54
|
-
BANNER
|
55
|
-
|
56
|
-
def process
|
57
|
-
PryByebug.check_file_context(target)
|
58
|
-
|
59
|
-
breakout_navigation :finish
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
create_command 'continue' do
|
64
|
-
description 'Continue program execution and end the Pry session.'
|
65
|
-
|
66
|
-
banner <<-BANNER
|
67
|
-
Usage: continue
|
68
|
-
BANNER
|
69
|
-
|
70
|
-
def process
|
71
|
-
PryByebug.check_file_context(target)
|
72
|
-
|
73
|
-
breakout_navigation :continue
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
helpers do
|
78
|
-
def breakout_navigation(action, options = {})
|
79
|
-
_pry_.binding_stack.clear # Clear the binding stack.
|
80
|
-
|
81
|
-
# Break out of the REPL loop and signal tracer
|
82
|
-
throw :breakout_nav, action: action, options: options, pry: _pry_
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
Pry.commands.import(SteppingCommands)
|
88
|
-
end
|
data/pry-byebug.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/lib/pry-byebug/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |gem|
|
4
|
-
gem.name = 'pry-byebug'
|
5
|
-
gem.version = PryByebug::VERSION
|
6
|
-
gem.authors = ['David Rodríguez', 'Gopal Patel']
|
7
|
-
gem.email = 'deivid.rodriguez@gmail.com'
|
8
|
-
gem.license = 'MIT'
|
9
|
-
gem.homepage = 'https://github.com/deivid-rodriguez/pry-byebug'
|
10
|
-
gem.summary = 'Fast debugging with Pry.'
|
11
|
-
gem.description = "Combine 'pry' with 'byebug'. Adds 'step', 'next',
|
12
|
-
'finish', 'continue' and 'break' commands to control execution."
|
13
|
-
|
14
|
-
gem.files = `git ls-files`.split("\n")
|
15
|
-
gem.test_files = `git ls-files -- test/*`.split("\n")
|
16
|
-
gem.require_paths = ['lib']
|
17
|
-
|
18
|
-
# Dependencies
|
19
|
-
gem.required_ruby_version = '>= 2.0.0'
|
20
|
-
|
21
|
-
gem.add_runtime_dependency 'pry', '~> 0.10'
|
22
|
-
gem.add_runtime_dependency 'byebug', '~> 4.0'
|
23
|
-
end
|
data/test/base_test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Checks current pry-byebug's context.
|
5
|
-
#
|
6
|
-
class BaseTest < MiniTest::Spec
|
7
|
-
def test_main_file_context
|
8
|
-
Pry.stubs eval_path: '<main>'
|
9
|
-
assert PryByebug.file_context?(TOPLEVEL_BINDING)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_other_file_context
|
13
|
-
Pry.stubs eval_path: 'something'
|
14
|
-
refute PryByebug.file_context?(TOPLEVEL_BINDING)
|
15
|
-
end
|
16
|
-
end
|
data/test/breakpoints_test.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Tests for pry-byebug breakpoints.
|
5
|
-
#
|
6
|
-
class BreakpointsTestGeneral < MiniTest::Spec
|
7
|
-
#
|
8
|
-
# Minimal dummy example class.
|
9
|
-
#
|
10
|
-
class Tester
|
11
|
-
def self.class_method; end
|
12
|
-
def instance_method; end
|
13
|
-
end
|
14
|
-
|
15
|
-
def breakpoints_class
|
16
|
-
Pry::Byebug::Breakpoints
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_add_file_raises_argument_error
|
20
|
-
Pry.stubs eval_path: 'something'
|
21
|
-
File.stubs :exist?
|
22
|
-
assert_raises(ArgumentError) do
|
23
|
-
breakpoints_class.add_file('file', 1)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_add_method_adds_instance_method_breakpoint
|
28
|
-
Pry.stub :processor, Byebug::PryProcessor.new do
|
29
|
-
breakpoints_class.add_method 'BreakpointsTest::Tester#instance_method'
|
30
|
-
bp = Byebug.breakpoints.last
|
31
|
-
assert_equal 'BreakpointsTest::Tester', bp.source
|
32
|
-
assert_equal 'instance_method', bp.pos
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_add_method_adds_class_method_breakpoint
|
37
|
-
Pry.stub :processor, Byebug::PryProcessor.new do
|
38
|
-
breakpoints_class.add_method 'BreakpointsTest::Tester.class_method'
|
39
|
-
bp = Byebug.breakpoints.last
|
40
|
-
assert_equal 'BreakpointsTest::Tester', bp.source
|
41
|
-
assert_equal 'class_method', bp.pos
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# Some common specs for breakpoints
|
48
|
-
#
|
49
|
-
module BreakpointSpecs
|
50
|
-
def test_shows_breakpoint_enabled
|
51
|
-
@output.string.must_match @regexp
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_shows_breakpoint_hit
|
55
|
-
result = @output.string
|
56
|
-
result.must_match(@regexp)
|
57
|
-
match = result.match(@regexp)
|
58
|
-
result.must_match(/^ Breakpoint #{match[:id]}\. First hit/)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_shows_breakpoint_line
|
62
|
-
@output.string.must_match(/\=> \s*#{@line}:/)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# Tests for breakpoint commands
|
68
|
-
#
|
69
|
-
class BreakpointsTestCommands < Minitest::Spec
|
70
|
-
let(:break_first_file) { test_file('break1') }
|
71
|
-
let(:break_second_file) { test_file('break2') }
|
72
|
-
|
73
|
-
before do
|
74
|
-
Pry.color, Pry.pager, Pry.hooks = false, false, Pry::DEFAULT_HOOKS
|
75
|
-
@input = InputTester.new 'break --delete-all'
|
76
|
-
redirect_pry_io(@input, StringIO.new) do
|
77
|
-
binding.pry # rubocop:disable Lint/Debugger
|
78
|
-
end
|
79
|
-
Object.send :remove_const, :Break1Example if defined? Break1Example
|
80
|
-
Object.send :remove_const, :Break2Example if defined? Break2Example
|
81
|
-
@output = StringIO.new
|
82
|
-
end
|
83
|
-
|
84
|
-
describe 'Set Breakpoints' do
|
85
|
-
describe 'set by line number' do
|
86
|
-
before do
|
87
|
-
@input = InputTester.new('break 6')
|
88
|
-
redirect_pry_io(@input, @output) { load break_first_file }
|
89
|
-
@line = 6
|
90
|
-
@regexp = / Breakpoint (?<id>\d+): #{break_first_file} @ 6 \(Enabled\)/
|
91
|
-
end
|
92
|
-
|
93
|
-
include BreakpointSpecs
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'set by method_id' do
|
97
|
-
before do
|
98
|
-
@input = InputTester.new('break Break1Example#a')
|
99
|
-
redirect_pry_io(@input, @output) { load break_first_file }
|
100
|
-
@line = 5
|
101
|
-
@regexp = / Breakpoint (?<id>\d+): Break1Example#a \(Enabled\)/
|
102
|
-
end
|
103
|
-
|
104
|
-
include BreakpointSpecs
|
105
|
-
end
|
106
|
-
|
107
|
-
describe 'set by method_id when its a bang method' do
|
108
|
-
before do
|
109
|
-
@input = InputTester.new('break Break1Example#c!')
|
110
|
-
redirect_pry_io(@input, @output) { load break_first_file }
|
111
|
-
@line = 15
|
112
|
-
@regexp = / Breakpoint (?<id>\d+): Break1Example#c! \(Enabled\)/
|
113
|
-
end
|
114
|
-
|
115
|
-
include BreakpointSpecs
|
116
|
-
end
|
117
|
-
|
118
|
-
describe 'set by method_id within context' do
|
119
|
-
before do
|
120
|
-
@input = InputTester.new('break #b')
|
121
|
-
redirect_pry_io(@input, @output) { load break_second_file }
|
122
|
-
@line = 7
|
123
|
-
@regexp = / Breakpoint (?<id>\d+): Break2Example#b \(Enabled\)/
|
124
|
-
end
|
125
|
-
|
126
|
-
include BreakpointSpecs
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe 'List breakpoints' do
|
131
|
-
before do
|
132
|
-
@input = InputTester.new('break #b', 'breakpoints')
|
133
|
-
redirect_pry_io(@input, @output) { load break_second_file }
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'shows all breakpoints' do
|
137
|
-
@output.string.must_match(/Yes \s*Break2Example#b/)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'properly aligns headers' do
|
141
|
-
width = Byebug.breakpoints.last.id.to_s.length
|
142
|
-
@output.string.must_match(/ {#{width - 1}}# Enabled At/)
|
143
|
-
@output.string.must_match(/ \d{#{width}} Yes Break2Example#b/)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
data/test/examples/break1.rb
DELETED
data/test/examples/break2.rb
DELETED
data/test/examples/frames.rb
DELETED
data/test/examples/stepping.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
binding.pry
|
2
|
-
|
3
|
-
#
|
4
|
-
# Toy class for testing steps
|
5
|
-
#
|
6
|
-
class SteppingExample
|
7
|
-
def method_a
|
8
|
-
z = 2
|
9
|
-
z + method_b
|
10
|
-
end
|
11
|
-
|
12
|
-
def method_b
|
13
|
-
c = Math::PI / 2
|
14
|
-
c += method_c
|
15
|
-
c + 1
|
16
|
-
end
|
17
|
-
|
18
|
-
def method_c
|
19
|
-
z = 4
|
20
|
-
z
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
ex = SteppingExample.new.method_a
|
25
|
-
2.times do
|
26
|
-
ex += 1
|
27
|
-
end
|
28
|
-
|
29
|
-
_foo = ex
|