class StackProf::CLI
CLI
is a simple wrapper around Pry that defines some helper methods for navigating stackprof dumps.
Public Class Methods
add_methods()
click to toggle source
Add the helper methods to pry
# File lib/stackprof/cli.rb, line 19 def add_methods session = Session.new Pry::Commands.block_command "load-dump", "Load a stackprof dump at file" do |file| session.with_context(self) {|s| s.load_dump(file) } end Pry::Commands.block_command "top", "print the top (n) results by sample time" do |limit| session.with_context(self) {|s| s.top(limit) } end Pry::Commands.block_command "total", "print the top (n) results by total sample time" do |limit| session.with_context(self) {|s| s.total(limit) } end Pry::Commands.block_command "all", "print all results by sample time" do session.with_context(self) {|s| s.all } end Pry::Commands.block_command "method", "scope results to matching methods" do |method| session.with_context(self) {|s| s.print_method(method) } end Pry::Commands.block_command "file", "scope results to matching file" do |method| session.with_context(self) {|s| s.print_file(method) } end end
set_defaults()
click to toggle source
Set prompts and other defaults
# File lib/stackprof/cli.rb, line 11 def set_defaults Pry.config.should_load_rc = false Pry.config.prompt = proc { "stackprof#{@current_report ? " (#{@current_report})" : ""}> " } end
start(file, options = {})
click to toggle source
Start a Pry session with an optional file
# File lib/stackprof/cli.rb, line 42 def start(file, options = {}) set_defaults add_methods initial = file ? StringIO.new("load-dump #{file}") : nil Pry.start(nil, :input => initial) end