lib/json/ld/api.rb in json-ld-1.0.6 vs lib/json/ld/api.rb in json-ld-1.0.7

- old
+ new

@@ -64,12 +64,14 @@ # If set to a value that is not `false`, the JSON-LD processor must modify the output of the Compaction Algorithm or the Expansion Algorithm by coalescing all properties associated with each subject via the Flattening Algorithm. The value of `flatten must` be either an _IRI_ value representing the name of the graph to flatten, or `true`. If the value is `true`, then the first graph encountered in the input document is selected and flattened. # @option options [String] :processingMode ("json-ld-1.0") # If set to "json-ld-1.0", the JSON-LD processor must produce exactly the same results as the algorithms defined in this specification. If set to another value, the JSON-LD processor is allowed to extend or modify the algorithms defined in this specification to enable application-specific optimizations. The definition of such optimizations is beyond the scope of this specification and thus not defined. Consequently, different implementations may implement different optimizations. Developers must not define modes beginning with json-ld as they are reserved for future versions of this specification. # @option options [String] :produceGeneralizedRdf (false) # Unless the produce generalized RDF flag is set to true, RDF triples containing a blank node predicate are excluded from output. - # @option options [Boolean] :useNativeTypes (true) + # @option options [Boolean] :useNativeTypes (false) # If set to `true`, the JSON-LD processor will use native datatypes for expression xsd:integer, xsd:boolean, and xsd:double values, otherwise, it will use the expanded form. + # @option options [Boolean] :useRdfType (false) + # If set to `true`, the JSON-LD processor will treat `rdf:type` like a normal property instead of using `@type`. # @option options [Boolean] :rename_bnodes (true) # Rename bnodes as part of expansion, or keep them the same. # @yield [api] # @yieldparam [API] def initialize(input, context, options = {}, &block) @@ -495,11 +497,11 @@ raise JSON::LD::JsonLdError::MultipleContextLinkHeaders, "expected at most 1 Link header with rel=jsonld:context, got #{links.length}" end end - yield remote_document if block_given? + return block_given? ? yield(remote_document) : remote_document when Net::HTTPRedirection # Follow redirection parsed_url = ::URI.parse(response["Location"]) else raise JSON::LD::JsonLdError::LoadingDocumentFailed, "<#{parsed_url}>: #{response.msg}(#{response.code})" @@ -517,13 +519,12 @@ raise JSON::LD::JsonLdError::LoadingDocumentFailed, "content_type: #{content_type}" if main != 'application' || sub !~ /^(.*\+)?json$/ end - yield remote_document if block_given? + return block_given? ? yield(remote_document) : remote_document end end - remote_document end ## # A {RemoteDocument} is returned from a {documentLoader}. class RemoteDocument