Sha256: 03f43144cb4f2aff5690a40c0ab66f190eb8c35f743a5b4f244b42a8659003b4

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

module RDF; module Util
  ##
  # 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
  module File
    # Content
    # @return [String] 
    attr_accessor :content_type
    
    ##
    # Open the file, returning or yielding an IO stream and mime_type.
    #
    # @param [String] filename_or_url to open
    # @param  [Hash{Symbol => Object}] options
    #   options are ignored in this implementation. Applications are encouraged
    #   to override this implementation to provide more control over HTTP
    #   headers and redirect following.
    # @option options [Array, String] :headers
    #   HTTP Request headers.
    # @return [IO] File stream
    # @yield [IO] File stream
    def self.open_file(filename_or_url, options = {}, &block)
      filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
      Kernel.open(filename_or_url.to_s, &block)
    end
  end # File
end; end # RDF::Util

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rdf-1.0.2 lib/rdf/util/file.rb
rdf-1.0.1 lib/rdf/util/file.rb
rdf-1.0.0 lib/rdf/util/file.rb
rdf-0.3.11.1 lib/rdf/util/file.rb
rdf-0.3.11 lib/rdf/util/file.rb
rdf-0.3.10 lib/rdf/util/file.rb
rdf-0.3.9 lib/rdf/util/file.rb
rdf-0.3.8 lib/rdf/util/file.rb
rdf-0.3.7 lib/rdf/util/file.rb
rdf-0.3.5.2 lib/rdf/util/file.rb
openlogic-rdf-0.3.7 lib/rdf/util/file.rb
openlogic-rdf-0.3.6 lib/rdf/util/file.rb
rdf-0.3.5.1 lib/rdf/util/file.rb
rdf-0.3.5 lib/rdf/util/file.rb