Sha256: 9fcd2c8f6282adfc1ee1a30195ba9e39bf6614c46855218cc7425b0b9987767b

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

module ActiveAnnotations
  module DocumentLoader
    class << self
      def local_document_loader(url, options={}, &block)
        if RDF::URI(url) == RDF::URI(RDFAnnotation::CONTEXT_URI)
          remote_document = JSON::LD::API::RemoteDocument.new(File.read(File.expand_path('../oa.jsonld',__FILE__)), base: url)
          block_given? ? yield(remote_document) : remote_document
        else
          # :nocov:
          JSON::LD::API.documentLoader(url, options, &block)
          # :nocov:
        end
      end
      
      def document_loader
        ENV['NO_RDF_CACHE'] == '1' ? JSON::LD::API.method(:documentLoader) : self.method(:local_document_loader)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_annotations-0.5.0 lib/active_annotations/document_loader.rb
active_annotations-0.4.0 lib/active_annotations/document_loader.rb
active_annotations-0.3.0 lib/active_annotations/document_loader.rb