Skip to content

Commit

Permalink
Release 1.1.10:
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
gkellogg committed Sep 22, 2015
2 parents 51b91e7 + d8162cc commit f2a9160
Show file tree
Hide file tree
Showing 11 changed files with 1,243 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ rvm:
- 1.9.3
- 2.0
- 2.1
- 2.2
- 2.2.1
- jruby
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: 2.2
- rbx-2

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ If the [jsonlint][] gem is installed, it will be used when validating an input d

Install with `gem install json-ld`

### MultiJson parser
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.

### JSON-LD Streaming Profile
This gem implements an optimized streaming writer used for generating JSON-LD from large repositories. Such documents result in the JSON-LD Streaming Profile:

Expand Down Expand Up @@ -219,6 +222,24 @@ This gem implements an optimized streaming writer used for generating JSON-LD fr
}
]

## Use a custom Document Loader
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.

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:

def load_document_local(url, options={}, &block)
if RDF::URI(url, canonicalize: true) == RDF::URI('http://schema.org/')
remote_document = JSON::LD::API::RemoteDocument.new(url, File.read("etc/schema.org.jsonld"))
return block_given? ? yield(remote_document) : remote_document
else
JSON::LD::API.documentLoader(url, options, &block)
end
end

Then, when performing something like expansion:

JSON::LD::API.expand(input, documentLoader: load_document_local)

## RDF Reader and Writer
{JSON::LD} also acts as a normal RDF reader and writer, using the standard RDF.rb reader/writer interfaces:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.9
1.1.10

0 comments on commit f2a9160

Please sign in to comment.