Module: Pry::Byebug::Breakpoints
- Extended by:
- Enumerable, Breakpoints
- Included in:
- Breakpoints
- Defined in:
- lib/pry/byebug/breakpoints.rb
Overview
Wrapper for Byebug.breakpoints that respects our Processor and has better failure behavior. Acts as an Enumerable.
Defined Under Namespace
Classes: FileBreakpoint, MethodBreakpoint
Instance Method Summary collapse
-
#add_file(file, line, expression = nil) ⇒ Object
Adds a file breakpoint.
-
#add_method(method, expression = nil) ⇒ Object
Adds a method breakpoint.
- #breakpoints ⇒ Object
-
#change(id, expression = nil) ⇒ Object
Changes the conditional expression for a breakpoint.
-
#delete(id) ⇒ Object
Deletes an existing breakpoint with the given ID.
-
#delete_all ⇒ Object
Deletes all breakpoints.
-
#disable(id) ⇒ Object
Disables a breakpoint with the given ID.
-
#disable_all ⇒ Object
Disables all breakpoints.
- #each(&block) ⇒ Object
-
#enable(id) ⇒ Object
Enables a disabled breakpoint with the given ID.
- #find_by_id(id) ⇒ Object
- #last ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
Instance Method Details
#add_file(file, line, expression = nil) ⇒ Object
Adds a file breakpoint.
63 64 65 66 67 68 69 70 71 72 73 |
# 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.(file) : file) bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) breakpoints << bp bp end |
#add_method(method, expression = nil) ⇒ Object
Adds a method breakpoint.
51 52 53 54 55 56 57 58 |
# 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 |
#breakpoints ⇒ Object
44 45 46 |
# File 'lib/pry/byebug/breakpoints.rb', line 44 def breakpoints @breakpoints ||= [] end |
#change(id, expression = nil) ⇒ Object
Changes the conditional expression for a breakpoint.
78 79 80 81 82 83 84 |
# 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 |
#delete(id) ⇒ Object
Deletes an existing breakpoint with the given ID.
89 90 91 92 93 94 95 |
# 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 |
#delete_all ⇒ Object
Deletes all breakpoints.
100 101 102 103 |
# File 'lib/pry/byebug/breakpoints.rb', line 100 def delete_all @breakpoints = [] ::Byebug.breakpoints.clear end |
#disable(id) ⇒ Object
Disables a breakpoint with the given ID.
115 116 117 |
# File 'lib/pry/byebug/breakpoints.rb', line 115 def disable(id) change_status id, false end |
#disable_all ⇒ Object
Disables all breakpoints.
122 123 124 125 126 |
# File 'lib/pry/byebug/breakpoints.rb', line 122 def disable_all each do |breakpoint| breakpoint.enabled = false end end |
#each(&block) ⇒ Object
136 137 138 |
# File 'lib/pry/byebug/breakpoints.rb', line 136 def each(&block) to_a.each(&block) end |
#enable(id) ⇒ Object
Enables a disabled breakpoint with the given ID.
108 109 110 |
# File 'lib/pry/byebug/breakpoints.rb', line 108 def enable(id) change_status id, true end |
#find_by_id(id) ⇒ Object
144 145 146 147 148 149 |
# 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 |
#last ⇒ Object
140 141 142 |
# File 'lib/pry/byebug/breakpoints.rb', line 140 def last to_a.last end |
#size ⇒ Object
132 133 134 |
# File 'lib/pry/byebug/breakpoints.rb', line 132 def size to_a.size end |
#to_a ⇒ Object
128 129 130 |
# File 'lib/pry/byebug/breakpoints.rb', line 128 def to_a breakpoints end |