Skip to content

Commit f2a9160

Browse files
committed
Release 1.1.10:
* Use MutliJson for parsing, allows adapter to be set in options, or the best available used automtaictally. * Add some JRuby test workarounds, and README notification on feature. * In context, keep query and fragment for base URI, and don't canonicalize unless the option indicates to do so. * Add README entry on creating a custom documentLoader.
2 parents 51b91e7 + d8162cc commit f2a9160

File tree

11 files changed

+1243
-43
lines changed

11 files changed

+1243
-43
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ rvm:
77
- 1.9.3
88
- 2.0
99
- 2.1
10-
- 2.2
10+
- 2.2.1
1111
- jruby
1212
cache: bundler
1313
sudo: false
1414
matrix:
1515
allow_failures:
16-
- rvm: 2.2
1716
- rbx-2
1817

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ If the [jsonlint][] gem is installed, it will be used when validating an input d
1616

1717
Install with `gem install json-ld`
1818

19+
### MultiJson parser
20+
The [MultiJson](https://rubygems.org/gems/multi_json) gem is used for parsing JSON; this defaults to the native JSON parser, but will use a more performant parser if one is available. A specific parser can be specified by adding the `:adapter` option to any API call. See [MultiJson](https://rubygems.org/gems/multi_json) for more information.
21+
1922
### JSON-LD Streaming Profile
2023
This gem implements an optimized streaming writer used for generating JSON-LD from large repositories. Such documents result in the JSON-LD Streaming Profile:
2124

@@ -219,6 +222,24 @@ This gem implements an optimized streaming writer used for generating JSON-LD fr
219222
}
220223
]
221224

225+
## Use a custom Document Loader
226+
In some cases, the built-in document loader {JSON::LD::API.documentLoader} is inadequate; for example, when using `http://schema.org` as a remote context, it will be re-loaded every time.
227+
228+
All entries into the {JSON::LD::API} accept a `:documentLoader` option, which can be used to provide an alternative method to use when loading remote documents. For example:
229+
230+
def load_document_local(url, options={}, &block)
231+
if RDF::URI(url, canonicalize: true) == RDF::URI('http://schema.org/')
232+
remote_document = JSON::LD::API::RemoteDocument.new(url, File.read("etc/schema.org.jsonld"))
233+
return block_given? ? yield(remote_document) : remote_document
234+
else
235+
JSON::LD::API.documentLoader(url, options, &block)
236+
end
237+
end
238+
239+
Then, when performing something like expansion:
240+
241+
JSON::LD::API.expand(input, documentLoader: load_document_local)
242+
222243
## RDF Reader and Writer
223244
{JSON::LD} also acts as a normal RDF reader and writer, using the standard RDF.rb reader/writer interfaces:
224245

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.9
1+
1.1.10

0 commit comments

Comments
 (0)