pry-byebug-reloaded 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac5c1a8ef056c4fda6d4517ee478ddbc804b1f1cf1fc85b2cd851bb7ec8696fb
4
+ data.tar.gz: eed33b1993ad70645eef3676c041022845c71fb2e3d61251a58bde53d3ce4de3
5
+ SHA512:
6
+ metadata.gz: cd49c629b3b8b8fed2583ccfd60f4e0989d951d322e0715de367318cdc1757afb00270477e726b090372962da2922fe3a80a17b9f05076f9a5bb1938b06dbfb3
7
+ data.tar.gz: 509840deca1bead6f397d8f737eceba6e3f6b3910a6dc7ce780f331fbcb00a605a9244c0a7d857b0b10b52a1618e667b40be8fe6eeea2949a35157c7f91bb678
data/CHANGELOG.md ADDED
@@ -0,0 +1,230 @@
1
+ # CHANGELOG
2
+
3
+ ## Master (Unreleased)
4
+
5
+ ## 3.10.1 (2022-08-16)
6
+
7
+ ### Fixed
8
+
9
+ * Rails console loading a debugger REPL instead of the standard Pry REPL (#392)
10
+
11
+ ## 3.10.0 (2022-08-15)
12
+
13
+ ### Added
14
+
15
+ * Support for pry 0.14 (#346, #386). NOTE: pry-byebug now needs to be explicitly required from `~/.pryrc` since plugin autoloading has been removed from Pry.
16
+
17
+ ### Removed
18
+
19
+ * Support for Ruby 2.4, 2.5, and 2.6. Pry-byebug no longer installs on these platforms (#380).
20
+
21
+ ## 3.9.0 (2020-03-21)
22
+
23
+ ### Fixed
24
+
25
+ * Dependency on pry being too loose. Now breaking minor releases of pry won't affect pry-byebug users (#289).
26
+
27
+ ### Added
28
+
29
+ * Support for pry 0.13.0 (#266).
30
+
31
+ ### Removed
32
+
33
+ * Support for pry older than 0.13.0 (#289).
34
+
35
+ ## 3.8.0 (2020-01-22)
36
+
37
+ ### Fixed
38
+
39
+ * Use `Binding#source_location` instead of evaluating `__FILE__` to avoid
40
+ warnings on Ruby 2.7 and on Ruby 2.6 in verbose mode (#221).
41
+
42
+ ### Removed
43
+
44
+ * Support for Ruby 2.3. Pry-byebug no longer installs on this platform.
45
+
46
+ ## 3.7.0 (2019-02-21)
47
+
48
+ * Byebug 11 compatibility, with ruby 2.6 support.
49
+
50
+ ## 3.6.0 (2018-02-07)
51
+
52
+ ### Added
53
+
54
+ * Byebug 10 compatibility, with ruby 2.5 support.
55
+
56
+ ## 3.5.1 (2017-11-27)
57
+
58
+ ### Fixed
59
+
60
+ * Allow other threads like Pry (#142).
61
+
62
+ ## 3.5.0 (2017-08-23)
63
+
64
+ ### Added
65
+
66
+ * Byebug 9.1 support. As a result, Ruby 2.0 & Ruby 2.1 support has been dropped.
67
+ Pry-byebug no longer installs on these platforms.
68
+
69
+ ## 3.4.3 (2017-08-22)
70
+
71
+ ### Fixed
72
+
73
+ * Installation on old rubies after byebug dropping support for them.
74
+
75
+ ## 3.4.2 (2016-12-06)
76
+
77
+ ### Fixed
78
+
79
+ * Byebug doesn't start after `disable-pry` command.
80
+
81
+ ## 3.4.1 (2016-11-22)
82
+
83
+ ### Fixed
84
+
85
+ * control_d handler not being required properly when `pry-byebug` loaded
86
+ as a `pry` plugin and not through explicit require.
87
+
88
+ ## 3.4.0 (2016-05-15)
89
+
90
+ ### Fixed
91
+
92
+ * Byebug 9 compatibility.
93
+
94
+ ### Added
95
+
96
+ * A new `backtrace` command.
97
+
98
+ ## 3.3.0 (2015-11-05)
99
+
100
+ ### Fixed
101
+
102
+ * Byebug 8 compatibility.
103
+ * Fix encoding error in gemspec file (#70).
104
+ * Debugger being too slow (#80, thanks @k0kubun).
105
+
106
+ ## 3.2.0 (2015-07-18)
107
+
108
+ ### Added
109
+
110
+ * `continue` can now receive a line number argument (#56).
111
+
112
+ ### Fixed
113
+
114
+ * Conflicts with `break` and `next` Ruby keywords inside multiline statements
115
+ (#44).
116
+
117
+ ### Removed
118
+
119
+ * `breaks` command. It was broken anyways (#47).
120
+
121
+ ## 3.1.0 (2015-04-14)
122
+
123
+ ### Added
124
+
125
+ * Frame navigation commands `up`, `down` and `frame`.
126
+
127
+ ## 3.0.1 (2015-04-02)
128
+
129
+ ### Fixed
130
+
131
+ * Several formatting and alignment issues.
132
+
133
+ ## 3.0.0 (2015-02-02)
134
+
135
+ ### Fixed
136
+
137
+ * `binding.pry` would not stop at the correct place when called at the last
138
+ line of a method/block.
139
+
140
+ ### Removed
141
+
142
+ * Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and `continue`
143
+ (`c`). See #34.
144
+
145
+ ## 2.0.0 (2014-01-09)
146
+
147
+ ### Fixed
148
+
149
+ * Byebug 3 compatibility.
150
+ * Pry not starting at the first line after `binding.pry` but at `binding.pry`.
151
+ * `continue` not finishing pry instance (#13).
152
+
153
+ ## 1.3.3 (2014-25-06)
154
+
155
+ ### Fixed
156
+
157
+ * Pry 0.10 series and further minor version level releases compatibility.
158
+
159
+ ## 1.3.2 (2014-24-02)
160
+
161
+ ### Fixed
162
+
163
+ * Bug inherited from `byebug`.
164
+
165
+ ## 1.3.1 (2014-08-02)
166
+
167
+ ### Fixed
168
+
169
+ * Bug #22 (thanks @andreychernih).
170
+
171
+ ## 1.3.0 (2014-05-02)
172
+
173
+ ### Added
174
+
175
+ * Breakpoints on method names (thanks @andreychernih & @palkan).
176
+
177
+ ### Fixed
178
+
179
+ * "Undefined method `interface`" error (huge thanks to @andreychernih).
180
+
181
+ ## 1.2.1 (2013-30-12)
182
+
183
+ ### Fixed
184
+
185
+ * "Uncaught throw :breakout_nav" error (thanks @lukebergen).
186
+
187
+ ## 1.2.0 (2013-24-09)
188
+
189
+ ### Fixed
190
+
191
+ * Compatibility with byebug's 2.x series
192
+
193
+ ## 1.1.2 (2013-11-07)
194
+
195
+ ### Fixed
196
+
197
+ * Compatibility with backwards compatible byebug versions.
198
+
199
+ ## 1.1.1 (2013-02-07)
200
+
201
+ ### Fixed
202
+
203
+ * Bug when doing `step n` or `next n` where n > 1 right after `binding.pry`.
204
+
205
+ ## 1.1.0 (2013-06-06)
206
+
207
+ ### Added
208
+
209
+ * `s`, `n`, `f` and `c` aliases (thanks @jgakos!).
210
+
211
+ ## 1.0.1 (2013-05-07)
212
+
213
+ ### Fixed
214
+
215
+ * Unwanted debugging printf.
216
+
217
+ ## 1.0.0 (2013-05-07)
218
+
219
+ ### Added
220
+
221
+ * Initial release forked from
222
+ [pry-debugger](https://github.com/nixme/pry-debugger) to support byebug.
223
+
224
+ ### Removed
225
+
226
+ * pry-remote support.
227
+
228
+ ## Older releases
229
+
230
+ * Check [pry-debugger](https://github.com/nixme/pry-debugger)'s CHANGELOG.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 David Rodríguez <deivid.rodriguez@riseup.net>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # pry-byebug-reloaded
2
+
3
+ [![Version][VersionBadge]][VersionURL]
4
+ [![Build][CIBadge]][CIURL]
5
+ [![Inline docs][InchCIBadge]][InchCIURL]
6
+
7
+ A version-relaxed fork of
8
+ [pry-byebug-reloaded](https://github.com/deivid-rodriguez/pry-byebug) with some patches
9
+ applied:
10
+
11
+ * https://github.com/deivid-rodriguez/pry-byebug-reloaded/pull/339
12
+
13
+ Adds step-by-step debugging and stack navigation capabilities to [pry] using
14
+ [byebug].
15
+
16
+ To use, invoke pry normally. No need to start your script or app differently.
17
+ Execution will stop in the first statement after your `binding.pry`.
18
+
19
+ ```ruby
20
+ def some_method
21
+ puts 'Hello World' # Run 'step' in the console to move here
22
+ end
23
+
24
+ binding.pry
25
+ some_method # Execution will stop here.
26
+ puts 'Goodbye World' # Run 'next' in the console to move here.
27
+ ```
28
+
29
+ ## Requirements
30
+
31
+ MRI 2.4.0 or higher.
32
+
33
+ ## Installation
34
+
35
+ Add
36
+
37
+ ```ruby
38
+ gem 'pry-byebug-reloaded'
39
+ ```
40
+
41
+ to your Gemfile and run
42
+
43
+ ```console
44
+ bundle install
45
+ ```
46
+
47
+ Make sure you include the gem globally or inside the `:test` group if you plan
48
+ to use it to debug your tests!
49
+
50
+ ## Commands
51
+
52
+ ### Step-by-step debugging
53
+
54
+ **break:** Manage breakpoints.
55
+
56
+ **step:** Step execution into the next line or method. Takes an optional numeric
57
+ argument to step multiple times.
58
+
59
+ **next:** Step over to the next line within the same frame. Also takes an
60
+ optional numeric argument to step multiple lines.
61
+
62
+ **finish:** Execute until current stack frame returns.
63
+
64
+ **continue:** Continue program execution and end the Pry session.
65
+
66
+ ### Callstack navigation
67
+
68
+ **backtrace:** Shows the current stack. You can use the numbers on the left
69
+ side with the `frame` command to navigate the stack.
70
+
71
+ **up:** Moves the stack frame up. Takes an optional numeric argument to move
72
+ multiple frames.
73
+
74
+ **down:** Moves the stack frame down. Takes an optional numeric argument to move
75
+ multiple frames.
76
+
77
+ **frame:** Moves to a specific frame. Called without arguments will show the
78
+ current frame.
79
+
80
+ ## Matching Byebug Behaviour
81
+
82
+ If you're coming from Byebug or from pry-byebug-reloaded versions previous to 3.0, you
83
+ may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands.
84
+ These aliases were removed by default because they usually conflict with
85
+ scratch variable names. But it's very easy to reenable them if you still want
86
+ them, just add the following shortcuts to your `~/.pryrc` file:
87
+
88
+ ```ruby
89
+ if defined?(PryByebug)
90
+ Pry.commands.alias_command 'c', 'continue'
91
+ Pry.commands.alias_command 's', 'step'
92
+ Pry.commands.alias_command 'n', 'next'
93
+ Pry.commands.alias_command 'f', 'finish'
94
+ end
95
+ ```
96
+
97
+ Also, you might find useful as well the repeat the last command by just hitting
98
+ the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to
99
+ your `~/.pryrc` file:
100
+
101
+ ```ruby
102
+ # Hit Enter to repeat last command
103
+ Pry::Commands.command /^$/, "repeat last command" do
104
+ pry_instance.run_command Pry.history.to_a.last
105
+ end
106
+ ```
107
+
108
+ ## Breakpoints
109
+
110
+ You can set and adjust breakpoints directly from a Pry session using the
111
+ `break` command:
112
+
113
+ **break:** Set a new breakpoint from a line number in the current file, a file
114
+ and line number, or a method. Pass an optional expression to create a
115
+ conditional breakpoint. Edit existing breakpoints via various flags.
116
+
117
+ Examples:
118
+
119
+ ```ruby
120
+ break SomeClass#run # Break at the start of `SomeClass#run`.
121
+ break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`.
122
+ break app/models/user.rb:15 # Break at line 15 in user.rb.
123
+ break 14 # Break at line 14 in the current file.
124
+
125
+ break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'.
126
+ break --condition 3 # Remove the condition on breakpoint #3.
127
+
128
+ break --delete 5 # Delete breakpoint #5.
129
+ break --disable-all # Disable all breakpoints.
130
+
131
+ break # List all breakpoints.
132
+ break --show 2 # Show details about breakpoint #2.
133
+ ```
134
+
135
+ Type `break --help` from a Pry session to see all available options.
136
+
137
+ ## Alternatives
138
+
139
+ Note that all of the alternatives here are incompatible with pry-byebug-reloaded. If
140
+ your platform is supported by pry-byebug-reloaded, you should remove any of the gems
141
+ mentioned here if they are present in your Gemfile.
142
+
143
+ * [pry-debugger]: Provides step-by-step debugging for MRI 1.9.3 or older
144
+ rubies. If you're still using those and need a step-by-step debugger to help
145
+ with the upgrade, pry-debugger can be handy.
146
+
147
+ * [pry-stack_explorer]: Provides stack navigation capabilities for MRI 1.9.3 or
148
+ older rubies. If you're still using those and need to navigate your stack to
149
+ help with the upgrade, pry-stack_explorer can be handy.
150
+
151
+ * [pry-nav]: Provides step-by-step debugging for JRuby.
152
+
153
+ ## Contribute
154
+
155
+ See [Getting Started with Development](CONTRIBUTING.md).
156
+
157
+ ## Funding
158
+
159
+ Subscribe to [Tidelift] to ensure pry-byebug-reloaded stays actively maintained, and at
160
+ the same time get licensing assurances and timely security notifications for
161
+ your open source dependencies.
162
+
163
+ You can also help `pry-byebug-reloaded` by leaving a small (or big) tip through [Liberapay].
164
+
165
+ [Tidelift]: https://tidelift.com/subscription/pkg/rubygems-pry-byebug-reloaded?utm_source=rubygems-pry-byebug-reloaded&utm_medium=referral&utm_campaign=readme
166
+ [Liberapay]: https://liberapay.com/pry-byebug-reloaded/donate
167
+
168
+ ## Security contact information
169
+
170
+ Please use the Tidelift security contact to [report a security vulnerability].
171
+ Tidelift will coordinate the fix and disclosure.
172
+
173
+ [report a security vulnerability]: https://tidelift.com/security
174
+
175
+ ## Credits
176
+
177
+ * Gopal Patel (@nixme), creator of [pry-debugger], and everybody who contributed
178
+ to it. pry-byebug-reloaded is a fork of pry-debugger so it wouldn't exist as it is
179
+ without those contributions.
180
+ * John Mair (@banister), creator of [pry].
181
+
182
+ Patches and bug reports are welcome.
183
+
184
+ [pry]: https://pry.github.io
185
+ [byebug]: https://github.com/Jack12816/byebug
186
+ [pry-debugger]: https://github.com/nixme/pry-debugger
187
+ [pry-nav]: https://github.com/nixme/pry-nav
188
+ [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer
189
+
190
+ [VersionBadge]: https://badge.fury.io/rb/pry-byebug-reloaded.svg
191
+ [VersionURL]: http://badge.fury.io/rb/pry-byebug-reloaded
192
+ [CIBadge]: https://github.com/Jack12816/pry-byebug-reloaded/workflows/ubuntu/badge.svg?branch=master
193
+ [CIURL]: https://github.com/Jack12816/pry-byebug-reloaded/actions?query=workflow%3Aubuntu
194
+ [InchCIBadge]: http://inch-ci.org/github/Jack12816/pry-byebug-reloaded.svg?branch=master
195
+ [InchCIURL]: http://inch-ci.org/github/Jack12816/pry-byebug-reloaded
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/core"
4
+
5
+ module Byebug
6
+ #
7
+ # Extends raw byebug's processor.
8
+ #
9
+ class PryProcessor < CommandProcessor
10
+ attr_accessor :pry
11
+
12
+ extend Forwardable
13
+ def_delegators :@pry, :output
14
+ def_delegators Pry::Helpers::Text, :bold
15
+
16
+ def self.start
17
+ Byebug.start
18
+ Setting[:autolist] = false
19
+ Context.processor = self
20
+ Byebug.current_context.step_out(5, true)
21
+ end
22
+
23
+ #
24
+ # Wrap a Pry REPL to catch navigational commands and act on them.
25
+ #
26
+ def run(&_block)
27
+ return_value = nil
28
+
29
+ command = catch(:breakout_nav) do # Throws from PryByebug::Commands
30
+ return_value = allowing_other_threads { yield }
31
+ {} # Nothing thrown == no navigational command
32
+ end
33
+
34
+ # Pry instance to resume after stepping
35
+ @pry = command[:pry]
36
+
37
+ perform(command[:action], command[:options])
38
+
39
+ return_value
40
+ end
41
+
42
+ #
43
+ # Set up a number of navigational commands to be performed by Byebug.
44
+ #
45
+ def perform(action, options = {})
46
+ return unless %i[
47
+ backtrace
48
+ down
49
+ finish
50
+ frame
51
+ next
52
+ step
53
+ up
54
+ ].include?(action)
55
+
56
+ send("perform_#{action}", options)
57
+ end
58
+
59
+ # --- Callbacks from byebug C extension ---
60
+
61
+ #
62
+ # Called when the debugger wants to stop at a regular line
63
+ #
64
+ def at_line
65
+ resume_pry
66
+ end
67
+
68
+ #
69
+ # Called when the debugger wants to stop right before a method return
70
+ #
71
+ def at_return(_return_value)
72
+ resume_pry
73
+ end
74
+
75
+ #
76
+ # Called when a breakpoint is hit. Note that `at_line`` is called
77
+ # inmediately after with the context's `stop_reason == :breakpoint`, so we
78
+ # must not resume the pry instance here
79
+ #
80
+ def at_breakpoint(breakpoint)
81
+ @pry ||= Pry.new
82
+
83
+ output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint)
84
+
85
+ expr = breakpoint.expr
86
+ return unless expr
87
+
88
+ output.puts bold("Condition: ") + expr
89
+ end
90
+
91
+ private
92
+
93
+ def n_hits(breakpoint)
94
+ n_hits = breakpoint.hit_count
95
+
96
+ n_hits == 1 ? "First hit" : "Hit #{n_hits} times."
97
+ end
98
+
99
+ #
100
+ # Resume an existing Pry REPL at the paused point.
101
+ #
102
+ def resume_pry
103
+ new_binding = frame._binding
104
+
105
+ run do
106
+ if defined?(@pry) && @pry
107
+ @pry.repl(new_binding)
108
+ else
109
+ @pry = Pry::REPL.start_without_pry_byebug(target: new_binding)
110
+ end
111
+ end
112
+ end
113
+
114
+ def perform_backtrace(_options)
115
+ Byebug::WhereCommand.new(self, "backtrace").execute
116
+
117
+ resume_pry
118
+ end
119
+
120
+ def perform_next(options)
121
+ lines = (options[:lines] || 1).to_i
122
+ context.step_over(lines, frame.pos)
123
+ end
124
+
125
+ def perform_step(options)
126
+ times = (options[:times] || 1).to_i
127
+ context.step_into(times, frame.pos)
128
+ end
129
+
130
+ def perform_finish(*)
131
+ context.step_out(1)
132
+ end
133
+
134
+ def perform_up(options)
135
+ times = (options[:times] || 1).to_i
136
+
137
+ Byebug::UpCommand.new(self, "up #{times}").execute
138
+
139
+ resume_pry
140
+ end
141
+
142
+ def perform_down(options)
143
+ times = (options[:times] || 1).to_i
144
+
145
+ Byebug::DownCommand.new(self, "down #{times}").execute
146
+
147
+ resume_pry
148
+ end
149
+
150
+ def perform_frame(options)
151
+ index = options[:index] ? options[:index].to_i : ""
152
+
153
+ Byebug::FrameCommand.new(self, "frame #{index}").execute
154
+
155
+ resume_pry
156
+ end
157
+ end
158
+ end