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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/README.md +7 -6
  4. data/lib/byebug/processors/pry_processor.rb +3 -5
  5. data/lib/pry-byebug.rb +1 -3
  6. data/lib/pry-byebug/cli.rb +1 -2
  7. data/lib/pry-byebug/commands.rb +8 -0
  8. data/lib/pry-byebug/commands/breakpoint.rb +135 -0
  9. data/lib/pry-byebug/commands/continue.rb +37 -0
  10. data/lib/pry-byebug/commands/down.rb +33 -0
  11. data/lib/pry-byebug/commands/finish.rb +26 -0
  12. data/lib/pry-byebug/commands/frame.rb +33 -0
  13. data/lib/pry-byebug/commands/next.rb +37 -0
  14. data/lib/pry-byebug/commands/step.rb +32 -0
  15. data/lib/pry-byebug/commands/up.rb +33 -0
  16. data/lib/pry-byebug/helpers/breakpoints.rb +84 -0
  17. data/lib/pry-byebug/helpers/multiline.rb +21 -0
  18. data/lib/pry-byebug/helpers/navigation.rb +17 -0
  19. data/lib/pry-byebug/version.rb +1 -1
  20. data/lib/pry/byebug/breakpoints.rb +4 -0
  21. metadata +23 -45
  22. data/.gitignore +0 -18
  23. data/.rubocop.yml +0 -14
  24. data/.rubocop_todo.yml +0 -20
  25. data/.travis.yml +0 -9
  26. data/Gemfile +0 -14
  27. data/Rakefile +0 -17
  28. data/lib/pry/commands/breakpoint.rb +0 -216
  29. data/lib/pry/commands/frames.rb +0 -79
  30. data/lib/pry/commands/stepping.rb +0 -88
  31. data/pry-byebug.gemspec +0 -23
  32. data/test/base_test.rb +0 -16
  33. data/test/breakpoints_test.rb +0 -146
  34. data/test/examples/break1.rb +0 -23
  35. data/test/examples/break2.rb +0 -21
  36. data/test/examples/deep_stepping.rb +0 -9
  37. data/test/examples/frames.rb +0 -14
  38. data/test/examples/stepping.rb +0 -29
  39. data/test/frames_test.rb +0 -58
  40. data/test/processor_test.rb +0 -40
  41. data/test/pry_ext_test.rb +0 -4
  42. data/test/pry_remote_ext_test.rb +0 -4
  43. data/test/stepping_test.rb +0 -78
  44. data/test/test_helper.rb +0 -35
@@ -0,0 +1,32 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+
3
+ module PryByebug
4
+ #
5
+ # Run a number of Ruby statements and then stop again
6
+ #
7
+ class StepCommand < Pry::ClassCommand
8
+ include Helpers::Navigation
9
+
10
+ match 'step'
11
+ group 'Byebug'
12
+ description 'Step execution into the next line or method.'
13
+
14
+ banner <<-BANNER
15
+ Usage: step [TIMES]
16
+
17
+ Step execution forward. By default, moves a single step.
18
+
19
+ Examples:
20
+ step #=> Move a single step forward.
21
+ step 5 #=> Execute the next 5 steps.
22
+ BANNER
23
+
24
+ def process
25
+ PryByebug.check_file_context(target)
26
+
27
+ breakout_navigation :step, times: args.first
28
+ end
29
+ end
30
+ end
31
+
32
+ Pry::Commands.add_command(PryByebug::StepCommand)
@@ -0,0 +1,33 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+
3
+ module PryByebug
4
+ #
5
+ # Travel up the frame stack
6
+ #
7
+ class UpCommand < Pry::ClassCommand
8
+ include Helpers::Navigation
9
+
10
+ match 'up'
11
+ group 'Byebug'
12
+
13
+ description 'Move current frame up.'
14
+
15
+ banner <<-BANNER
16
+ Usage: up [TIMES]
17
+
18
+ Move current frame up. By default, moves by 1 frame.
19
+
20
+ Examples:
21
+ up #=> Move up 1 frame.
22
+ up 5 #=> Move up 5 frames.
23
+ BANNER
24
+
25
+ def process
26
+ PryByebug.check_file_context(target)
27
+
28
+ breakout_navigation :up, times: args.first
29
+ end
30
+ end
31
+ end
32
+
33
+ Pry::Commands.add_command(PryByebug::UpCommand)
@@ -0,0 +1,84 @@
1
+ require 'byebug'
2
+
3
+ module PryByebug
4
+ module Helpers
5
+ #
6
+ # Common helpers for breakpoint related commands
7
+ #
8
+ module Breakpoints
9
+ #
10
+ # Byebug's array of breakpoints.
11
+ #
12
+ def breakpoints
13
+ Pry::Byebug::Breakpoints
14
+ end
15
+
16
+ #
17
+ # Current file in the target binding. Used as the default breakpoint
18
+ # location.
19
+ #
20
+ def current_file
21
+ target.eval('__FILE__')
22
+ end
23
+
24
+ #
25
+ # Prints a message with bold font.
26
+ #
27
+ def bold_puts(msg)
28
+ output.puts(text.bold(msg))
29
+ end
30
+
31
+ #
32
+ # Print out full information about a breakpoint.
33
+ #
34
+ # Includes surrounding code at that point.
35
+ #
36
+ def print_full_breakpoint(br)
37
+ header = "Breakpoint #{br.id}:"
38
+ status = br.enabled? ? 'Enabled' : 'Disabled'
39
+ code = br.source_code.with_line_numbers.to_s
40
+ condition = br.expr ? "#{text.bold('Condition:')} #{br.expr}\n" : ''
41
+
42
+ output.puts <<-EOP.gsub(/ {8}/, '')
43
+
44
+ #{text.bold(header)} #{br} (#{status}) #{condition}
45
+
46
+ #{code}
47
+
48
+ EOP
49
+ end
50
+
51
+ #
52
+ # Print out concise information about a breakpoint.
53
+ #
54
+ def print_short_breakpoint(breakpoint)
55
+ id = format('%*d', max_width, breakpoint.id)
56
+ status = breakpoint.enabled? ? 'Yes' : 'No '
57
+ expr = breakpoint.expr ? " #{breakpoint.expr} " : ''
58
+
59
+ output.puts(" #{id} #{status} #{breakpoint}#{expr}")
60
+ end
61
+
62
+ #
63
+ # Prints a header for the breakpoint list.
64
+ #
65
+ def print_breakpoints_header
66
+ header = "#{' ' * (max_width - 1)}# Enabled At "
67
+
68
+ output.puts <<-EOP.gsub(/ {8}/, '')
69
+
70
+ #{text.bold(header)}
71
+ #{text.bold('-' * header.size)}
72
+
73
+ EOP
74
+ end
75
+
76
+ #
77
+ # Max width of breakpoints id column
78
+ #
79
+ def max_width
80
+ breakpoints.last ? breakpoints.last.id.to_s.length : 1
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,21 @@
1
+ module PryByebug
2
+ module Helpers
3
+ #
4
+ # Helpers to help handling multiline inputs
5
+ #
6
+ module Multiline
7
+ #
8
+ # Returns true if we are in a multiline context and, as a side effect,
9
+ # updates the partial evaluation string with the current input.
10
+ #
11
+ # Returns false otherwise
12
+ #
13
+ def check_multiline_context
14
+ return false if eval_string.empty?
15
+
16
+ eval_string.replace("#{eval_string}#{match} #{arg_string}\n")
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module PryByebug
2
+ module Helpers
3
+ #
4
+ # Helpers to aid breaking out of the REPL loop
5
+ #
6
+ module Navigation
7
+ #
8
+ # Breaks out of the REPL loop and signals tracer
9
+ #
10
+ def breakout_navigation(action, options = {})
11
+ _pry_.binding_stack.clear
12
+
13
+ throw :breakout_nav, action: action, options: options, pry: _pry_
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,5 +2,5 @@
2
2
  # Main container module for Pry-Byebug functionality
3
3
  #
4
4
  module PryByebug
5
- VERSION = '3.1.0'
5
+ VERSION = '3.2.0'
6
6
  end
@@ -135,6 +135,10 @@ class Pry
135
135
  to_a.each(&block)
136
136
  end
137
137
 
138
+ def last
139
+ to_a.last
140
+ end
141
+
138
142
  def find_by_id(id)
139
143
  breakpoint = find { |b| b.id == id }
140
144
  fail(ArgumentError, "No breakpoint ##{id}!") unless breakpoint
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodríguez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-14 00:00:00.000000000 Z
12
+ date: 2015-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -31,56 +31,47 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '4.0'
34
+ version: '5.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '4.0'
41
+ version: '5.0'
42
42
  description: |-
43
- Combine 'pry' with 'byebug'. Adds 'step', 'next',
44
- 'finish', 'continue' and 'break' commands to control execution.
43
+ Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish',
44
+ 'continue' and 'break' commands to control execution.
45
45
  email: deivid.rodriguez@gmail.com
46
46
  executables: []
47
47
  extensions: []
48
- extra_rdoc_files: []
48
+ extra_rdoc_files:
49
+ - CHANGELOG.md
50
+ - README.md
49
51
  files:
50
- - ".gitignore"
51
- - ".rubocop.yml"
52
- - ".rubocop_todo.yml"
53
- - ".travis.yml"
54
52
  - CHANGELOG.md
55
- - Gemfile
56
53
  - LICENSE
57
54
  - README.md
58
- - Rakefile
59
55
  - lib/byebug/processors/pry_processor.rb
60
56
  - lib/pry-byebug.rb
61
57
  - lib/pry-byebug/base.rb
62
58
  - lib/pry-byebug/cli.rb
59
+ - lib/pry-byebug/commands.rb
60
+ - lib/pry-byebug/commands/breakpoint.rb
61
+ - lib/pry-byebug/commands/continue.rb
62
+ - lib/pry-byebug/commands/down.rb
63
+ - lib/pry-byebug/commands/finish.rb
64
+ - lib/pry-byebug/commands/frame.rb
65
+ - lib/pry-byebug/commands/next.rb
66
+ - lib/pry-byebug/commands/step.rb
67
+ - lib/pry-byebug/commands/up.rb
68
+ - lib/pry-byebug/helpers/breakpoints.rb
69
+ - lib/pry-byebug/helpers/multiline.rb
70
+ - lib/pry-byebug/helpers/navigation.rb
63
71
  - lib/pry-byebug/pry_ext.rb
64
72
  - lib/pry-byebug/pry_remote_ext.rb
65
73
  - lib/pry-byebug/version.rb
66
74
  - lib/pry/byebug/breakpoints.rb
67
- - lib/pry/commands/breakpoint.rb
68
- - lib/pry/commands/frames.rb
69
- - lib/pry/commands/stepping.rb
70
- - pry-byebug.gemspec
71
- - test/base_test.rb
72
- - test/breakpoints_test.rb
73
- - test/examples/break1.rb
74
- - test/examples/break2.rb
75
- - test/examples/deep_stepping.rb
76
- - test/examples/frames.rb
77
- - test/examples/stepping.rb
78
- - test/frames_test.rb
79
- - test/processor_test.rb
80
- - test/pry_ext_test.rb
81
- - test/pry_remote_ext_test.rb
82
- - test/stepping_test.rb
83
- - test/test_helper.rb
84
75
  homepage: https://github.com/deivid-rodriguez/pry-byebug
85
76
  licenses:
86
77
  - MIT
@@ -101,21 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
92
  version: '0'
102
93
  requirements: []
103
94
  rubyforge_project:
104
- rubygems_version: 2.4.6
95
+ rubygems_version: 2.4.5
105
96
  signing_key:
106
97
  specification_version: 4
107
98
  summary: Fast debugging with Pry.
108
- test_files:
109
- - test/base_test.rb
110
- - test/breakpoints_test.rb
111
- - test/examples/break1.rb
112
- - test/examples/break2.rb
113
- - test/examples/deep_stepping.rb
114
- - test/examples/frames.rb
115
- - test/examples/stepping.rb
116
- - test/frames_test.rb
117
- - test/processor_test.rb
118
- - test/pry_ext_test.rb
119
- - test/pry_remote_ext_test.rb
120
- - test/stepping_test.rb
121
- - test/test_helper.rb
99
+ test_files: []
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- tmp
2
- pkg
3
- doc
4
-
5
- .bundle
6
- .config
7
- .yardoc
8
- .gdb_history
9
- .rvmrc
10
- .ruby-gemset
11
- .ruby-version
12
-
13
- Gemfile.lock
14
- InstalledFiles
15
- _yardoc
16
- coverage
17
- lib/bundler/man
18
- rdoc
@@ -1,14 +0,0 @@
1
- Lint/Debugger:
2
- Exclude:
3
- - test/examples/*.rb
4
-
5
- Style/FileName:
6
- Exclude:
7
- - lib/pry-byebug.rb
8
- - lib/pry-byebug/cli.rb
9
- - test/test_helper.rb
10
-
11
- Style/ModuleFunction:
12
- Enabled: false
13
-
14
- inherit_from: .rubocop_todo.yml
@@ -1,20 +0,0 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-03-13 12:00:51 -0300 using RuboCop version 0.29.1.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Offense count: 1
9
- Metrics/AbcSize:
10
- Max: 39
11
-
12
- # Offense count: 1
13
- # Configuration parameters: CountComments.
14
- Metrics/ClassLength:
15
- Max: 142
16
-
17
- # Offense count: 1
18
- # Configuration parameters: CountComments.
19
- Metrics/MethodLength:
20
- Max: 23
@@ -1,9 +0,0 @@
1
- rvm:
2
- - 2.0.0
3
- - 2.1
4
- - 2.2
5
- - ruby-head
6
-
7
- matrix:
8
- allow_failures:
9
- - rvm: ruby-head
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'rake', '~> 10.4'
6
-
7
- group :development do
8
- gem 'rubocop', '0.29.1'
9
- end
10
-
11
- group :test do
12
- gem 'mocha', '~> 1.1'
13
- gem 'minitest', '~> 5.5'
14
- end
data/Rakefile DELETED
@@ -1,17 +0,0 @@
1
- require 'bundler/gem_tasks'
2
-
3
- require 'rake/testtask'
4
-
5
- desc 'Run tests'
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.ruby_opts += ['-w']
9
- t.pattern = 'test/**/*_test.rb'
10
- end
11
-
12
- require 'rubocop/rake_task'
13
-
14
- desc 'Run RuboCop'
15
- task(:rubocop) { RuboCop::RakeTask.new }
16
-
17
- task default: [:test, :rubocop]
@@ -1,216 +0,0 @@
1
- require 'pry/byebug/breakpoints'
2
-
3
- #
4
- # Main Pry class.
5
- #
6
- # We're going to add to it custom breakpoint commands for Pry-Byebug
7
- #
8
- class Pry
9
- BreakpointCommands = CommandSet.new do
10
- create_command 'break' do
11
- description 'Set or edit a breakpoint.'
12
-
13
- banner <<-BANNER
14
- Usage: break <METHOD | FILE:LINE | LINE> [if CONDITION]
15
- break --condition N [CONDITION]
16
- break [--show | --delete | --enable | --disable] N
17
- break [--delete-all | --disable-all]
18
- Aliases: breakpoint
19
-
20
- Set a breakpoint. Accepts a line number in the current file, a file and
21
- line number, or a method, and an optional condition.
22
-
23
- Pass appropriate flags to manipulate existing breakpoints.
24
-
25
- Examples:
26
-
27
- break SomeClass#run Break at the start of `SomeClass#run`.
28
- break Foo#bar if baz? Break at `Foo#bar` only if `baz?`.
29
- break app/models/user.rb:15 Break at line 15 in user.rb.
30
- break 14 Break at line 14 in the current file.
31
-
32
- break --condition 4 x > 2 Add/change condition on breakpoint #4.
33
- break --condition 3 Remove the condition on breakpoint #3.
34
-
35
- break --delete 5 Delete breakpoint #5.
36
- break --disable-all Disable all breakpoints.
37
-
38
- break List all breakpoints.
39
- break --show 2 Show details about breakpoint #2.
40
- BANNER
41
-
42
- def options(opt)
43
- defaults = { argument: true, as: Integer }
44
-
45
- opt.on :c, :condition, 'Change condition of a breakpoint.', defaults
46
- opt.on :s, :show, 'Show breakpoint details and source.', defaults
47
- opt.on :D, :delete, 'Delete a breakpoint.', defaults
48
- opt.on :d, :disable, 'Disable a breakpoint.', defaults
49
- opt.on :e, :enable, 'Enable a disabled breakpoint.', defaults
50
- opt.on :'disable-all', 'Disable all breakpoints.'
51
- opt.on :'delete-all', 'Delete all breakpoints.'
52
- end
53
-
54
- def process
55
- all = %w(condition show delete disable enable disable-all delete-all)
56
- all.each do |option|
57
- next unless opts.present?(option)
58
-
59
- return send("process_#{option.gsub('-', '_')}")
60
- end
61
-
62
- new_breakpoint unless args.empty?
63
- end
64
-
65
- %w(delete disable enable).each do |command|
66
- define_method(:"process_#{command}") do
67
- breakpoints.send(command, opts[command])
68
- run 'breakpoints'
69
- end
70
- end
71
-
72
- %w(disable-all delete-all).each do |command|
73
- method_name = command.gsub('-', '_')
74
- define_method(:"process_#{method_name}") do
75
- breakpoints.send(method_name)
76
- run 'breakpoints'
77
- end
78
- end
79
-
80
- def process_show
81
- print_full_breakpoint(breakpoints.find_by_id(opts[:show]))
82
- end
83
-
84
- def process_condition
85
- expr = args.empty? ? nil : args.join(' ')
86
- breakpoints.change(opts[:condition], expr)
87
- end
88
-
89
- def new_breakpoint
90
- place = args.shift
91
- condition = args.join(' ') if 'if' == args.shift
92
-
93
- bp =
94
- case place
95
- when /^(\d+)$/
96
- errmsg = 'Line number declaration valid only in a file context.'
97
- PryByebug.check_file_context(target, errmsg)
98
-
99
- file, lineno = target.eval('__FILE__'), Regexp.last_match[1].to_i
100
- breakpoints.add_file(file, lineno, condition)
101
- when /^(.+):(\d+)$/
102
- file, lineno = Regexp.last_match[1], Regexp.last_match[2].to_i
103
- breakpoints.add_file(file, lineno, condition)
104
- when /^(.*)[.#].+$/ # Method or class name
105
- if Regexp.last_match[1].strip.empty?
106
- errmsg = 'Method name declaration valid only in a file context.'
107
- PryByebug.check_file_context(target, errmsg)
108
- place = target.eval('self.class.to_s') + place
109
- end
110
- breakpoints.add_method(place, condition)
111
- else
112
- fail(ArgumentError, 'Cannot identify arguments as breakpoint')
113
- end
114
-
115
- print_full_breakpoint(bp)
116
- end
117
- end
118
- alias_command 'breakpoint', 'break'
119
-
120
- create_command 'breakpoints' do
121
- description 'List defined breakpoints.'
122
-
123
- banner <<-BANNER
124
- Usage: breakpoints [OPTIONS]
125
- Aliases: breaks
126
-
127
- List registered breakpoints and their current status.
128
- BANNER
129
-
130
- def options(opt)
131
- opt.on :v, :verbose, 'Print source around each breakpoint.'
132
- end
133
-
134
- def process
135
- return bold_puts('No breakpoints defined.') if breakpoints.count == 0
136
-
137
- if opts.verbose?
138
- breakpoints.each { |b| print_full_breakpoint(b) }
139
- else
140
- print_breakpoints_header
141
- breakpoints.each { |b| print_short_breakpoint(b) }
142
- end
143
- end
144
- end
145
- alias_command 'breaks', 'breakpoints'
146
-
147
- helpers do
148
- #
149
- # Byebug's array of breakpoints.
150
- #
151
- def breakpoints
152
- Byebug::Breakpoints
153
- end
154
-
155
- #
156
- # Prints a message with bold font.
157
- #
158
- def bold_puts(msg)
159
- output.puts(text.bold(msg))
160
- end
161
-
162
- #
163
- # Print out full information about a breakpoint.
164
- #
165
- # Includes surrounding code at that point.
166
- #
167
- def print_full_breakpoint(br)
168
- header = "Breakpoint #{br.id}:"
169
- status = br.enabled? ? 'Enabled' : 'Disabled'
170
- code = br.source_code.with_line_numbers.to_s
171
- condition = br.expr ? "#{text.bold('Condition:')} #{br.expr}\n" : ''
172
-
173
- output.puts <<-EOP.gsub(/ {8}/, '')
174
-
175
- #{text.bold(header)} #{br} (#{status}) #{condition}
176
-
177
- #{code}
178
-
179
- EOP
180
- end
181
-
182
- #
183
- # Print out concise information about a breakpoint.
184
- #
185
- def print_short_breakpoint(breakpoint)
186
- id = format('%*d', max_width, breakpoint.id)
187
- status = breakpoint.enabled? ? 'Yes' : 'No'
188
- expr = breakpoint.expr ? breakpoint.expr : ''
189
-
190
- output.puts(" #{id} #{status} #{breakpoint} #{expr}")
191
- end
192
-
193
- #
194
- # Prints a header for the breakpoint list.
195
- #
196
- def print_breakpoints_header
197
- header = "#{' ' * (max_width - 1)}# Enabled At "
198
-
199
- output.puts <<-EOP.gsub(/ {8}/, '')
200
-
201
- #{text.bold(header)}
202
- #{text.bold('-' * header.size)}
203
- EOP
204
- end
205
-
206
- #
207
- # Max width of breakpoints id column
208
- #
209
- def max_width
210
- ::Byebug.breakpoints.last.id.to_s.length
211
- end
212
- end
213
- end
214
-
215
- Pry.commands.import(BreakpointCommands)
216
- end