module Pry::Byebug::Breakpoints
Wrapper for Byebug.breakpoints that respects our Processor and has better failure behavior. Acts as an Enumerable.
Public Instance Methods
Source
# File lib/pry/byebug/breakpoints.rb, line 63 def add_file(file, line, expression = nil) real_file = (file != Pry.eval_path) raise(ArgumentError, "Invalid file!") if real_file && !File.exist?(file) validate_expression expression path = (real_file ? File.expand_path(file) : file) bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) breakpoints << bp bp end
Adds a file breakpoint.
Source
# File lib/pry/byebug/breakpoints.rb, line 51 def add_method(method, expression = nil) validate_expression expression owner, name = method.split(/[\.#]/) byebug_bp = ::Byebug::Breakpoint.add(owner, name.to_sym, expression) bp = MethodBreakpoint.new byebug_bp, method breakpoints << bp bp end
Adds a method breakpoint.
Source
# File lib/pry/byebug/breakpoints.rb, line 44 def breakpoints @breakpoints ||= [] end
Source
# File lib/pry/byebug/breakpoints.rb, line 78 def change(id, expression = nil) validate_expression expression breakpoint = find_by_id(id) breakpoint.expr = expression breakpoint end
Changes the conditional expression for a breakpoint.
Source
# File lib/pry/byebug/breakpoints.rb, line 89 def delete(id) deleted = ::Byebug::Breakpoint.remove(id) && breakpoints.delete(find_by_id(id)) raise(ArgumentError, "No breakpoint ##{id}") unless deleted end
Deletes an existing breakpoint with the given ID.
Source
# File lib/pry/byebug/breakpoints.rb, line 100 def delete_all @breakpoints = [] ::Byebug.breakpoints.clear end
Deletes all breakpoints.
Source
# File lib/pry/byebug/breakpoints.rb, line 115 def disable(id) change_status id, false end
Disables a breakpoint with the given ID.
Source
# File lib/pry/byebug/breakpoints.rb, line 122 def disable_all each do |breakpoint| breakpoint.enabled = false end end
Disables all breakpoints.
Source
# File lib/pry/byebug/breakpoints.rb, line 136 def each(&block) to_a.each(&block) end
Source
# File lib/pry/byebug/breakpoints.rb, line 108 def enable(id) change_status id, true end
Enables a disabled breakpoint with the given ID.
Source
# File lib/pry/byebug/breakpoints.rb, line 144 def find_by_id(id) breakpoint = find { |b| b.id == id } raise(ArgumentError, "No breakpoint ##{id}!") unless breakpoint breakpoint end
Private Instance Methods
Source
# File lib/pry/byebug/breakpoints.rb, line 153 def change_status(id, enabled = true) breakpoint = find_by_id(id) breakpoint.enabled = enabled breakpoint end
Source
# File lib/pry/byebug/breakpoints.rb, line 159 def validate_expression(exp) valid = exp && (exp.empty? || !Pry::Code.complete_expression?(exp)) return unless valid raise("Invalid breakpoint conditional: #{expression}") end