Module: Warc

Defined in:
lib/warc.rb,
lib/warc/cli.rb,
lib/warc/http.rb,
lib/warc/parser.rb,
lib/warc/record.rb,
lib/warc/stream.rb,
lib/warc/version.rb,
lib/warc/proxy/proxy.rb,
lib/warc/stream/gzip.rb,
lib/warc/ext/net_http.rb,
lib/warc/stream/plain.rb,
lib/warc/record/header.rb,
lib/warc/record/validator.rb,
lib/warc/utils/header_hash.rb

Defined Under Namespace

Modules: Proxy Classes: CLI, HTTP, HeaderHash, Parser, Record, Stream, StubSocket

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.open_stream(path, mode = 'r+') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# 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