module RDF::Util::File

Public Class Methods

_turtle_reader_original_open_file(filename_or_url, options = {}, &block)
Alias for: open_file
open_file(filename_or_url, options = {}, &block) click to toggle source
# File lib/turtle_reader/rdf/compression.rb, line 75
def open_file(filename_or_url, options = {}, &block)
  klass = begin
    case filename_or_url
      when /\.bz(?:ip)?2?\z/i then RBzip2::Decompressor
      when /\.gz(?:ip)?\z/i   then Zlib::GzipReader
    end
  rescue NameError => err
    err.message.sub!('Module::', '')
    raise
  end

  if klass
    original_block, block = block, lambda { |file|
      original_block[file.is_a?(IO) ? klass.new(file) : file]
    }
  end

  _turtle_reader_original_open_file(filename_or_url, options, &block)
end