module Warc

Constants

VERSION

Public Class Methods

open_stream(path,mode='r+') click to toggle source
# File lib/warc/stream.rb, line 4
def self.open_stream(path,mode='r+')
      
  gzipped = path.match(/.*\.warc\.gz$/)
  warc = path.match(/.*\.warc$/)
  
  if (gzipped || warc)
    fh = ::File.exists?(path) ? ::File.new(path,mode) : path
    return Stream::Gzip.new(fh) if gzipped
    return Stream::Plain.new(fh) if warc
  else
    return Stream::Gzip.new(path)
  end
end