Last active
December 21, 2015 20:39
-
-
Save saboyutaka/6362504 to your computer and use it in GitHub Desktop.
Prevent outputting 'Frame number' when guard is executed. pry-stack_explorer が Guard 実行時に常に表示されるのを防ぐ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# monkey-patch the whereami command to show some frame information, | |
# useful for navigating stack. | |
Pry.config.commands.before_command("whereami") do |num| | |
if PryStackExplorer.frame_manager(_pry_) && !internal_binding?(target) | |
bindings = PryStackExplorer.frame_manager(_pry_).bindings | |
binding_index = PryStackExplorer.frame_manager(_pry_).binding_index | |
# Add here | |
# Ignore outputs when Frame number: 0/0 or 0/1 | |
unless binding_index == 0 && bindings.size <= 2 | |
output.puts "\n" | |
output.puts "#{Pry::Helpers::Text.bold('Frame number:')} #{binding_index}/#{bindings.size - 1}" | |
output.puts "#{Pry::Helpers::Text.bold('Frame type:')} #{bindings[binding_index].frame_type}" if bindings[binding_index].frame_type | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment