Sha256: 6b9c9ae7f084da11c759416248fb88140c698c61bf978fc9d25d255100aa7cc0
Contents?: true
Size: 566 Bytes
Versions: 49
Compression:
Stored size: 566 Bytes
Contents
module Utils class LineBlamer def initialize(file, lineno = 1) @file, @lineno = file, lineno end def self.for_line(line) location = line.source_location and new *location end def self.blame(line) blamer = for_line(line) if blame = blamer.perform blame.sub!(/^[0-9a-f^]+/) { Term::ANSIColor.yellow($&) } blame.sub!(/\(([^)]+)\)/) { "(#{Term::ANSIColor.red($1)})" } end end def perform(options = '') `git 2>/dev/null blame #{options} -L #@lineno,+1 "#@file"`.full? end end end
Version data entries
49 entries across 49 versions & 1 rubygems