midwire
8/24/2017 - 3:50 PM

[My .pryrc] It's awesome! #ruby

[My .pryrc] It's awesome! #ruby

require 'irb/completion'

Pry.commands.alias_command 'wh', 'whereami'

if defined?(PryNav)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
end

if defined?(PryByebug)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

if defined?(PryDebugger)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

if defined?(PryStackExplorer)
  Pry.commands.alias_command 'ss', 'show-stack'
  Pry.commands.alias_command 'fr', 'frame'
end


def what_methods(obj)
  (obj.public_methods - Object.public_methods - Object.instance_methods).sort
end

def wm(obj)
  what_methods(obj)
end

def predicates(obj)
  what_methods(obj).grep(/\?$/)
end

def locate(obj, method)
  obj.method(method.to_sym).source_location
end