Create a gist now

Instantly share code, notes, and snippets.

@rubysolo /empty forked from banister/empty
Created Jun 17, 2011

What would you like to do?
pry(main):4> blame_for(Pry.instance_method(:repl)).display
John Mair def repl(target=TOPLEVEL_BINDING)
John Mair target = Pry.binding_for(target)
John Mair target_self = target.eval('self')
John Mair
John Mair repl_prologue(target)
Mon ouïe
John Mair # cannot rely on nesting.level as
John Mair # nesting.level changes with new sessions
John Mair nesting_level = nesting.size
John Mair
John Mair break_data = catch(:breakout) do
John Mair nesting.push [nesting.size, target_self, self]
John Mair loop do
John Mair rep(target)
John Mair end
John Mair end
John Mair
John Mair return_value = repl_epilogue(target, nesting_level, break_data)
Lee Jarvis return_value || target_self
John Mair end
=> nil
pry(main):4> show-method blame_for
From: (pry) @ line 108:
Number of lines: 11
def blame_for(meth)
@repo ||=".")
start_line = meth.source_location.last
num_lines = meth.source.lines.count
size = num_lines
l = start_line
obj = []
authors = @repo.blame(meth.source_location.first) { |v| v.lineno >= l && v.lineno <= l + size }.map { |v|</).first.strip } { |line, author| obj << ("#{author}".ljust(10) + line) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment