pry / pry-stack_explorer

Walk the stack in a Pry session
Other
455 stars 28 forks source link

Move up/down using Regex (uses Class#name syntax) [2012] #4

Closed grstearns closed 1 year ago

grstearns commented 12 years ago

We added the feature @banister requested to use more specific syntax to jump stack frames.

This included a minor refactor of find_frame_by_regex in commands to avoid code duplication.

banister commented 12 years ago

Thanks seems to work great for the Class#method case :) But it doesn't appear to work for just Class syntax. But perhaps this doesn't matter so much, thanks for your code :))

nonetheless i've enclosed my code showing the problem, your branch is checked out below:

[7] (pry) #<V>: 0> show-stack                                                                                                                                                              

Showing all accessible frames in stack (9 in total):
--
=> #0 [method]  zeta <Object#zeta()>
   #1 [method]  gamma <V#gamma()>
   #2 [method]  beta <V#beta()>
   #3 [method]  c <Object#c()>
   #4 [block]   block in b <Object#b()>
   #5 [method]  b <Object#b()>
   #6 [method]  alphabet <J#alphabet(y)>
   #7 [eval]    <main> 
   #8 [top]     <main> 
[8] (pry) #<V>: 0> up J                                                                                                                                                             
Error: No frame that matches J found!
[9] (pry) #<V>: 0> up J#alphabet                                                                                                                                             

Frame number: 6/8
Frame type: method

From: /Users/john/ruby/projects/pry-stack_explorer/examples/example3.rb @ line 39 J#alphabet:

    39:     def alphabet(y)
    40:       x = 20
 => 41:       b
    42:     end

[10] (pry) #<J>: 0> 
grstearns commented 12 years ago

Got it.

banister commented 12 years ago

@grstearns ah thanks! I already pushed a gem with your previous changes (0.4.5) i'll look at your new changes and probably apply them later tonight, cool!

joallard commented 4 years ago

Hi, is this still current? (#3)

joallard commented 4 years ago

Quoting #3:

e.g up Hello #=> first frame that has Hello method OR (more likely) first frame that's instance of Hello class e.g up Hello#method #=> first frame that is an invocation of Hello#method

should still work based on regex can regex on class name e.g up Hel or on method name e.g up Hello#met or both, e.g: up Hel#met should attempt Hello as method first, if fail, then try as class