Guest User

Untitled

a guest
Nov 18th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. module BuildCanary
  2. class Leak < Struct.new(:location, :line, :pattern)
  3. def short_lines(context_length = 30)
  4. matchdata = pattern.match(line)
  5. [].tap do |lines|
  6. 0.upto(matchdata.size-1) do |i|
  7. start, finish = matchdata.offset(i)
  8. start -= context_length
  9.  
  10. lines << self.line[start, matchdata[i].size + (context_length*2)]
  11. end
  12. end
  13. end
  14. end
  15. end
Add Comment
Please, Sign In to add comment