Sha256: 0fc52d0ad112439f44a34f6c6d9e1bd9cba1610cfc529568f745788e9bb43da5
Contents?: true
Size: 560 Bytes
Versions: 8
Compression:
Stored size: 560 Bytes
Contents
module Embulk class GuessNewline < TextGuessPlugin Plugin.register_guess('newline', self) def guess_text(config, sample_text) cr_count = sample_text.count("\r") lf_count = sample_text.count("\n") crlf_count = sample_text.scan(/\r\n/).length if crlf_count > cr_count / 2 && crlf_count > lf_count / 2 return {"parser" => {"newline" => "CRLF"}} elsif cr_count > lf_count / 2 return {"parser" => {"newline" => "CR"}} else return {"parser" => {"newline" => "LF"}} end end end end
Version data entries
8 entries across 8 versions & 1 rubygems