module PryStack
Constants
- Commands
Public Class Methods
Simple test to check whether two ‘Binding` objects are equal. @param [Binding] b1 First binding. @param [Binding] b2 Second binding. @return [Boolean] Whether the `Binding`s are equal.
# File lib/pry-stack.rb, line 104 def bindings_equal?(b1, b2) (b1.eval('self').equal?(b2.eval('self'))) && (b1.eval('__method__') == b2.eval('__method__')) && (b1.eval('local_variables').map { |v| b1.eval("#{v}") }.equal?( b2.eval('local_variables').map { |v| b2.eval("#{v}") })) end
Clear the stack of frame managers for the Pry instance @param [Pry] pry The Pry instance associated with the frame managers
# File lib/pry-stack.rb, line 88 def clear_frame_managers(_pry_) pop_frame_manager(_pry_) until frame_managers(_pry_).empty? frame_hash.delete(_pry_) # this line should be unnecessary! end
Create a ‘Pry::FrameManager` object and push it onto the frame manager stack for the relevant `pry` instance. @param [Array] bindings The array of bindings (frames) @param [Pry] pry The Pry instance associated with the frame manager
# File lib/pry-stack.rb, line 30 def create_and_push_frame_manager(bindings, _pry_, options={}) fm = FrameManager.new(bindings, _pry_) frame_hash[_pry_].push fm push_helper(fm, options) fm end
@return [Hash] The hash storing all frames for all Pry instances for
the current thread.
# File lib/pry-stack.rb, line 14 def frame_hash Thread.current[:__pry_frame_managers__] ||= Hash.new { |h, k| h[k] = [] } end
@return [PryStack::FrameManager] The currently active frame manager
# File lib/pry-stack.rb, line 96 def frame_manager(_pry_) frame_hash[_pry_].last end
Return the complete frame manager stack for the Pry instance @param [Pry] pry The Pry instance associated with the frame
managers
@return [Array] The stack of Pry::FrameManager objections
# File lib/pry-stack.rb, line 22 def frame_managers(_pry_) frame_hash[_pry_] end
Delete the currently active frame manager @param [Pry] pry The Pry instance associated with the frame
managers.
@return [Pry::FrameManager] The popped frame manager.
# File lib/pry-stack.rb, line 55 def pop_frame_manager(_pry_) return if frame_managers(_pry_).empty? popped_fm = frame_managers(_pry_).pop pop_helper(popped_fm, _pry_) popped_fm end
Private Class Methods
Restore the Pry instance to operate on the previous binding. Also responsible for restoring Pry instance’s backtrace. @param [Pry::FrameManager] popped_fm The recently popped frame manager. @param [Pry] pry The Pry instance associated with the frame managers.
# File lib/pry-stack.rb, line 67 def pop_helper(popped_fm, _pry_) if frame_managers(_pry_).empty? if _pry_.binding_stack.empty? _pry_.binding_stack.push popped_fm.prior_binding else _pry_.binding_stack[-1] = popped_fm.prior_binding end frame_hash.delete(_pry_) else frame_manager(_pry_).refresh_frame(false) end # restore backtrace _pry_.backtrace = popped_fm.prior_backtrace end
Update the Pry instance to operate on the specified frame for the current frame manager. @param [PryStack::FrameManager] fm The active frame manager. @param [Hash] options The options hash.
# File lib/pry-stack.rb, line 41 def push_helper(fm, options={}) options = { :initial_frame => 0 }.merge!(options) fm.change_frame_to(options[:initial_frame], false) end