Guest User

Untitled

a guest
Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. command "cd", "Move into a new context (use `cd ..` to go back and `cd /` to return to Pry top-level)" do |obj|
  2. path = arg_string.split(/\//)
  3. stack = _pry_.binding_stack.dup
  4.  
  5. # special case when we only get a single "/", return to root
  6. stack = [stack.first] if path.empty?
  7.  
  8. resolve_failure = false
  9. path.each do |context|
  10. begin
  11. case context
  12. when ""
  13. stack = [stack.first]
  14. when "."
  15. next
  16. when ".."
  17. if stack.one?
  18. _pry_.binding_stack.clear
  19. throw(:breakout)
  20. else
  21. stack.pop
  22. end
  23. else
  24. stack.push(Pry.binding_for(stack.last.eval(context)))
  25. end
  26.  
  27. rescue RescuableException
  28. output.puts "Bad object path: #{arg_string}. Failed trying to resolve: #{context}"
  29. resolve_failure = true
  30. end
  31. end
  32.  
  33. next if resolve_failure
  34.  
  35. _pry_.binding_stack = stack
  36. end
Add Comment
Please, Sign In to add comment