Module: PryByebug::Helpers::Breakpoints
- Included in:
- BreakCommand, ContinueCommand
- Defined in:
- lib/pry-byebug/helpers/breakpoints.rb
Overview
Common helpers for breakpoint related commands
Instance Method Summary collapse
-
#bold_puts(msg) ⇒ Object
Prints a message with bold font.
-
#breakpoints ⇒ Object
Byebug’s array of breakpoints.
-
#current_file ⇒ Object
Current file in the target binding.
-
#max_width ⇒ Object
Max width of breakpoints id column.
-
#print_breakpoints_header ⇒ Object
Prints a header for the breakpoint list.
-
#print_full_breakpoint(br) ⇒ Object
Print out full information about a breakpoint.
-
#print_short_breakpoint(breakpoint) ⇒ Object
Print out concise information about a breakpoint.
Instance Method Details
#bold_puts(msg) ⇒ Object
Prints a message with bold font.
27 28 29 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 27 def bold_puts(msg) output.puts(text.bold(msg)) end |
#breakpoints ⇒ Object
Byebug’s array of breakpoints.
12 13 14 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 12 def breakpoints Pry::Byebug::Breakpoints end |
#current_file ⇒ Object
Current file in the target binding. Used as the default breakpoint location.
20 21 22 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 20 def current_file target.eval('__FILE__') end |
#max_width ⇒ Object
Max width of breakpoints id column
79 80 81 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 79 def max_width breakpoints.last ? breakpoints.last.id.to_s.length : 1 end |
#print_breakpoints_header ⇒ Object
Prints a header for the breakpoint list.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 65 def print_breakpoints_header header = "#{' ' * (max_width - 1)}# Enabled At " output.puts <<-EOP.gsub(/ {8}/, '') #{text.bold(header)} #{text.bold('-' * header.size)} EOP end |
#print_full_breakpoint(br) ⇒ Object
Print out full information about a breakpoint.
Includes surrounding code at that point.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 36 def print_full_breakpoint(br) header = "Breakpoint #{br.id}:" status = br.enabled? ? 'Enabled' : 'Disabled' code = br.source_code.with_line_numbers.to_s condition = br.expr ? "#{text.bold('Condition:')} #{br.expr}\n" : '' output.puts <<-EOP.gsub(/ {8}/, '') #{text.bold(header)} #{br} (#{status}) #{condition} #{code} EOP end |
#print_short_breakpoint(breakpoint) ⇒ Object
Print out concise information about a breakpoint.
54 55 56 57 58 59 60 |
# File 'lib/pry-byebug/helpers/breakpoints.rb', line 54 def print_short_breakpoint(breakpoint) id = format('%*d', max_width, breakpoint.id) status = breakpoint.enabled? ? 'Yes' : 'No ' expr = breakpoint.expr ? " #{breakpoint.expr} " : '' output.puts(" #{id} #{status} #{breakpoint}#{expr}") end |