Module: RDF::Util::File

Defined in:
lib/rdf/util/file.rb

Overview

Wrapper for Kernel.open. Allows implementations to override to get more suffisticated behavior for HTTP resources (e.g., Accept header).

Also supports the file: scheme for access to local files.

Classes include this module when they represent some form of a file as a base resource, for instance an HTTP resource representing the serialization of a Graph.

This module may be monkey-patched to allow for more options and interfaces.

Since:

  • 0.2.4

Class Method Summary collapse

Class Method Details

.open_gzipfile(filename_or_url, options = {}) {|IO| ... } ⇒ IO

Open the file, returning or yielding an IO stream and mime_type.

any options to pass through to the underlying UUID library

Parameters:

  • filename_or_url (String)

    to open

  • options (Hash{Symbol => Object}) (defaults to: {})

Yields:

  • (IO)

    File stream

Returns:

  • (IO)

    File stream

Since:

  • 0.2.4



25
26
27
28
# File 'lib/rdf/util/file.rb', line 25

def self.open_gzipfile(filename_or_url, options = {}, &block)
  filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
  f = Zlib::GzipReader.open(filename_or_url.to_s, &block)
end