You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Community contributions are essential for keeping Ruby RDF great. We want to kee
6
6
7
7
This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
8
8
9
-
* create or respond to an issue on the [Github Repository](http://github.com/ruby-rdf/json-ld/issues)
9
+
* create or respond to an issue on the [Github Repository](https://github.com/ruby-rdf/json-ld/issues)
JSON::LD parses and serializes [JSON-LD][] into [RDF][] and implements expansion, compaction and framing API interfaces.
11
+
JSON::LD parses and serializes [JSON-LD][] into [RDF][] and implements expansion, compaction and framing API interfaces. It also extracts JSON-LD from HTML.
12
12
13
13
JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and optionally include a JSON-LD representation of the ontology itself. This is currently accessed through the `script/gen_context` script.
14
14
15
-
If the [jsonlint][] gem is installed, it will be used when validating an input document.
15
+
* If the [jsonlint][] gem is installed, it will be used when validating an input document.
16
+
* If available, uses [Nokogiri][] and/or [Nokogumbo][] for parsing HTML, falls back to REXML otherwise.
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.
229
+
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 (however, see [json-ld-preloaded](https://rubygems.org/gems/json-ld-preloaded)).
229
230
230
231
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:
@@ -433,19 +434,52 @@ Many JSON APIs separate properties from their entities using an intermediate obj
433
434
```
434
435
In this way, nesting survives round-tripping through expansion, and framed output can include nested properties.
435
436
436
-
### Framing Updates
437
-
The [JSON-LD Framing 1.1 Specification]() improves on previous un-released versions.
437
+
## Sinatra/Rack support
438
+
JSON-LD 1.1 describes support for the _profile_ parameter to a media type in an HTTP ACCEPT header. This allows an HTTP request to specify the format (expanded/compacted/flattened/framed) along with a reference to a context or frame to use to format the returned document.
This tells a server that the top priority is to return JSON-LD compacted using a context at `http://conneg.example.com/context`, and if not available, to just return any form of JSON-LD.
447
+
448
+
The {JSON::LD::ContentNegotiation} class provides a [Rack][Rack]`call` method, and [Sinatra][Sinatra]`registered` class method to allow content-negotiation using such profile parameters. For example:
449
+
450
+
#!/usr/bin/env rackup
451
+
require 'sinatra/base'
452
+
require 'json/ld'
453
+
454
+
module My
455
+
class Application < Sinatra::Base
456
+
register JSON::LD::ContentNegotiation
457
+
458
+
get '/hello' do
459
+
[{
460
+
"http://example.org/input": [{
461
+
"@id": "http://example.com/g1",
462
+
"@graph": [{
463
+
"http://example.org/value": [{"@value": "x"}]
464
+
}]
465
+
}]
466
+
}])
467
+
end
468
+
end
469
+
end
470
+
471
+
run My::Application
472
+
473
+
The {JSON::LD::ContentNegotiation#call} method looks for a result which includes an object, with an acceptable `Accept` header and formats the result as JSON-LD, considering the profile parameters. This can be tested using something like the following:
*[More Specific Frame matching](https://github.com/json-ld/json-ld.org/issues/110) – Allows framing to extend to elements of value objects, and objects are matched through recursive frame matching. `{}` is used as a wildcard, and `[]` as matching nothing.
440
-
*[Graph framing](https://github.com/json-ld/json-ld.org/issues/118) – previously, only the merged graph can be framed, this update allows arbitrary graphs to be framed.
441
-
* Use `@graph` in frame, matches the default graph, not the merged graph.
442
-
* Use `@graph` in property value, causes the apropriatly named graph to be used for filling in values.
443
-
*[Reverse properties](https://github.com/json-ld/json-ld.org/issues/311) – `@reverse` (or a property defined with `@reverse`) can cause matching values to be included, allowing a matched object to include reverse references to any objects referencing it.
444
-
*[@omitDefault behavior](https://github.com/json-ld/json-ld.org/issues/389) – In addition to `true` and `false`, `@omitDefault` can take `@last`, `@always`, `@never`, and `@link`.
445
-
*[multiple `@id` matching](https://github.com/json-ld/json-ld.org/issues/424) – A frame can match based on one or more specific object `@id` values.
479
+
See [Rack::LinkedData][] to do the same thing with an RDF Graph or Dataset as the source, rather than Ruby objects.
446
480
447
481
## Documentation
448
-
Full documentation available on [RubyDoc](http://rubydoc.info/gems/json-ld/file/README.md)
482
+
Full documentation available on [RubyDoc](https://rubydoc.info/gems/json-ld/file/README.md)
449
483
450
484
## Differences from [JSON-LD API][]
451
485
The specified JSON-LD API is based on a WebIDL definition implementing [Promises][] intended for use within a browser.
@@ -468,12 +502,12 @@ Note, the API method signatures differed in versions before 1.0, in that they al
468
502
* {JSON::LD::Writer}
469
503
470
504
## Dependencies
471
-
*[Ruby](http://ruby-lang.org/) (>= 2.2.2)
472
-
*[RDF.rb](http://rubygems.org/gems/rdf) (~> 3.0)
473
-
*[JSON](https://rubygems.org/gems/json) (>= 2.1)
505
+
*[Ruby](https://ruby-lang.org/) (>= 2.4)
506
+
*[RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
507
+
*[JSON](https://rubygems.org/gems/json) (>= 2.2)
474
508
475
509
## Installation
476
-
The recommended installation method is via [RubyGems](http://rubygems.org/).
510
+
The recommended installation method is via [RubyGems](https://rubygems.org/).
477
511
To install the latest official release of the `JSON-LD` gem, do:
478
512
```bash
479
513
% [sudo] gem install json-ld
@@ -484,10 +518,10 @@ To get a local working copy of the development repository, do:
0 commit comments