Sha256: 83364357da7ec386e13df8dedb6f96f0b59b8123d16db8f69cb45346e1745e2c
Contents?: true
Size: 796 Bytes
Versions: 65
Compression:
Stored size: 796 Bytes
Contents
# -*- coding: utf-8 -*- require 'milkode/common/string_snip' class GrenSnip MAX_LINE_SIZE = 256 HEADER_SIZE = 32 MARGIN_SIZE = 32 DELIMITER = '<<snip>>' def self.snip(str, match_datas) return str if (str.size <= MAX_LINE_SIZE) ranges = [] ranges << (0..HEADER_SIZE-1) ranges << (-HEADER_SIZE..-1) match_datas.each do |m| ranges << (m.begin(0)-MARGIN_SIZE..m.end(0)+MARGIN_SIZE) end snipper = StringSnip.new(MAX_LINE_SIZE, DELIMITER) return snipper.snip(str, ranges) end def self.coloring(line, match_datas) match_datas.each do |m| line = line.split(m[0]).join(HighLine::ON_GREEN + m[0] + HighLine::CLEAR) end line = line.split(DELIMITER).join(HighLine::ON_CYAN + DELIMITER + HighLine::CLEAR) line end end
Version data entries
65 entries across 65 versions & 1 rubygems