daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Nov 18th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top