Wrapper for Debugger.breakpoints that respects our Processor and has better failure behavior. Acts as an Enumerable.
Add a new breakpoint.
# File lib/pry-debugger/breakpoints.rb, line 12 def add(file, line, expression = nil) if !File.exist?(file) && file != Pry.eval_path raise ArgumentError, 'Invalid file!' unless File.exist?(file) end validate_expression expression Pry.processor.debugging = true path = file == Pry.eval_path ? file : File.expand_path(file) Debugger.add_breakpoint(path, line, expression) end
Change the conditional expression for a breakpoint.
# File lib/pry-debugger/breakpoints.rb, line 25 def change(id, expression = nil) validate_expression expression breakpoint = find_by_id(id) breakpoint.expr = expression breakpoint end
Delete all breakpoints.
# File lib/pry-debugger/breakpoints.rb, line 42 def clear Debugger.breakpoints.clear if Debugger.started? Pry.processor.debugging = false end
Delete an existing breakpoint with the given ID.
# File lib/pry-debugger/breakpoints.rb, line 34 def delete(id) unless Debugger.started? && Debugger.remove_breakpoint(id) raise ArgumentError, "No breakpoint ##{id}" end Pry.processor.debugging = false if to_a.empty? end
Disable a breakpoint with the given ID.
# File lib/pry-debugger/breakpoints.rb, line 53 def disable(id) change_status id, false end
Disable all breakpoints.
# File lib/pry-debugger/breakpoints.rb, line 58 def disable_all each do |breakpoint| breakpoint.enabled = false end end
# File lib/pry-debugger/breakpoints.rb, line 72 def each(&block) to_a.each(&block) end
Enable a disabled breakpoint with the given ID.
# File lib/pry-debugger/breakpoints.rb, line 48 def enable(id) change_status id, true end
# File lib/pry-debugger/breakpoints.rb, line 76 def find_by_id(id) breakpoint = find { |b| b.id == id } raise ArgumentError, "No breakpoint ##{id}!" unless breakpoint breakpoint end
# File lib/pry-debugger/breakpoints.rb, line 68 def size to_a.size end
# File lib/pry-debugger/breakpoints.rb, line 64 def to_a Debugger.started? ? Debugger.breakpoints : [] end