module PryByebug::Helpers::Breakpoints
Common helpers for breakpoint related commands
Public Instance Methods
bold_puts(msg)
click to toggle source
Prints a message with bold font.
# File lib/pry-byebug/helpers/breakpoints.rb, line 27 def bold_puts(msg) output.puts(text.bold(msg)) end
breakpoints()
click to toggle source
Byebug's array of breakpoints.
# File lib/pry-byebug/helpers/breakpoints.rb, line 12 def breakpoints Pry::Byebug::Breakpoints end
current_file()
click to toggle source
Current file in the target binding. Used as the default breakpoint location.
# File lib/pry-byebug/helpers/breakpoints.rb, line 20 def current_file target.eval("__FILE__") end
max_width()
click to toggle source
Max width of breakpoints id column
# 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()
click to toggle source
Prints a header for the breakpoint list.
# File lib/pry-byebug/helpers/breakpoints.rb, line 65 def print_breakpoints_header header = "#{' ' * (max_width - 1)}# Enabled At " output.puts <<-BREAKPOINTS.gsub(/ {8}/, "") #{text.bold(header)} #{text.bold('-' * header.size)} BREAKPOINTS end
print_full_breakpoint(br)
click to toggle source
Print out full information about a breakpoint.
Includes surrounding code at that point.
# 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 <<-BREAKPOINT.gsub(/ {8}/, "") #{text.bold(header)} #{br} (#{status}) #{condition} #{code} BREAKPOINT end
print_short_breakpoint(breakpoint)
click to toggle source
Print out concise information about a breakpoint.
# 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