Sha256: dbd77748c1d756092f23ba3de62dff7b6f723a321c1fa947ccafb75bce68929e

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require 'rack'
require 'linkeddata'

module Rack
  module LinkedData
    autoload :ContentNegotiation, 'rack/linkeddata/conneg'
    autoload :VERSION,            'rack/linkeddata/version'

    ##
    # Registers all known RDF formats with Rack's MIME types registry.
    #
    # @param  [Hash{Symbol => Object}] options
    # @option options [Boolean]        :overwrite (false)
    # @return [void]
    def self.register_mime_types!(options = {})
      if defined?(Rack::Mime::MIME_TYPES)
        RDF::Format.each do |format|
          if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{format.to_sym}") || options[:overwrite]
            Rack::Mime::MIME_TYPES.merge!(file_ext => format.content_type.first)
          end
        end
        RDF::Format.file_extensions.each do |file_ext, formats|
          if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{file_ext}") || options[:overwrite]
            Rack::Mime::MIME_TYPES.merge!(file_ext => formats.first.content_type.first)
          end
        end
      end
    end
  end
end

Rack::LinkedData.register_mime_types!

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rack-linkeddata-3.0.0 lib/rack/linkeddata.rb
rack-linkeddata-2.2.3 lib/rack/linkeddata.rb
rack-linkeddata-2.2.2 lib/rack/linkeddata.rb
rack-linkeddata-2.2.1 lib/rack/linkeddata.rb
rack-linkeddata-2.0.0 lib/rack/linkeddata.rb
rack-linkeddata-2.0.0.beta1 lib/rack/linkeddata.rb
rack-linkeddata-1.1.0 lib/rack/linkeddata.rb
rack-linkeddata-1.0.0 lib/rack/linkeddata.rb