Skip to content

Commit 4619258

Browse files
committed
Finish 3.1.6
2 parents cdece75 + 4658876 commit 4619258

File tree

20 files changed

+837
-33
lines changed

20 files changed

+837
-33
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.
2+
3+
name: CI
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the develop branch
8+
push:
9+
branches: [ '**' ]
10+
pull_request:
11+
branches: [ develop ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
tests:
20+
name: Ruby ${{ matrix.ruby }}
21+
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
22+
runs-on: ubuntu-latest
23+
env:
24+
CI: true
25+
ALLOW_FAILURES: false ${{ endsWith(matrix.ruby, 'head') }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
ruby:
30+
- 2.4
31+
- 2.5
32+
- 2.6
33+
- 2.7
34+
# - ruby-head # net-http-persistent
35+
- jruby
36+
steps:
37+
- name: Clone repository
38+
uses: actions/checkout@v2
39+
- name: Set up Ruby
40+
uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: ${{ matrix.ruby }}
43+
- name: Install dependencies
44+
run: bundle install --jobs 4 --retry 3
45+
- name: Run tests
46+
run: bundle exec rspec spec || $ALLOW_FAILURES
47+

README.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
[JSON-LD][] reader/writer for [RDF.rb][RDF.rb] and fully conforming [JSON-LD API][] processor. Additionally this gem implements [JSON-LD Framing][].
44

5-
[![Gem Version](https://badge.fury.io/rb/json-ld.png)](https://badge.fury.io/rb/json-ld)
6-
[![Build Status](https://secure.travis-ci.org/ruby-rdf/json-ld.png?branch=master)](https://travis-ci.org/ruby-rdf/json-ld)
7-
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/json-ld/badge.svg)](https://coveralls.io/r/ruby-rdf/json-ld)
5+
[![Gem Version](https://badge.fury.io/rb/json-ld.png)](https://rubygems.org/gems/json-ld)
6+
[![Build Status](https://secure.travis-ci.org/ruby-rdf/json-ld.png?branch=develop)](https://github.com/ruby-rdf/json-ld/actions?query=workflow%3ACI)
7+
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/json-ld/badge.svg)](https://coveralls.io/github/ruby-rdf/json-ld)
8+
[![Gitter chat](https://badges.gitter.im/ruby-rdf.png)](https://gitter.im/gitterHQ/gitter)
89

910
## Features
1011

@@ -14,6 +15,7 @@ JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and
1415

1516
* If the [jsonlint][] gem is installed, it will be used when validating an input document.
1617
* If available, uses [Nokogiri][] and/or [Nokogumbo][] for parsing HTML, falls back to REXML otherwise.
18+
* Provisional support for [JSON-LD*][JSON-LD*].
1719

1820
[Implementation Report](file.earl.html)
1921

@@ -35,6 +37,59 @@ The order of triples retrieved from the `RDF::Enumerable` dataset determines the
3537
### MultiJson parser
3638
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.
3739

40+
### JSON-LD* (RDFStar)
41+
42+
The {JSON::LD::API.toRdf} and {JSON::LD::API.fromRdf} API methods, along with the {JSON::LD::Reader} and {JSON::LD::Writer}, include provisional support for [JSON-LD*][JSON-LD*].
43+
44+
Internally, an `RDF::Statement` is treated as another resource, along with `RDF::URI` and `RDF::Node`, which allows an `RDF::Statement` to have a `#subject` or `#object` which is also an `RDF::Statement`.
45+
46+
In JSON-LD, with the `rdfstar` option set, the value of `@id`, in addition to an IRI or Blank Node Identifier, can be a JSON-LD node object having exactly one property with an optional `@id`, which may also be an embedded object. (It may also have `@context` and `@index` values).
47+
48+
{
49+
"@id": {
50+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
51+
"@index": "ignored",
52+
"@id": "bob",
53+
"foaf:age" 23
54+
},
55+
"ex:certainty": 0.9
56+
}
57+
58+
**Note: This feature is subject to change or elimination as the standards process progresses.**
59+
60+
#### Serializing a Graph containing embedded statements
61+
62+
require 'json-ld'
63+
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
64+
graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
65+
graph.dump(:jsonld, validate: false, standard_prefixes: true)
66+
# => {"@id": {"@id": "bob", "foaf:age" 23}, "ex:certainty": 0.9}
67+
68+
Alternatively, using the {JSON::LD::API.fromRdf} method:
69+
70+
JSON::LD::API::fromRdf(graph)
71+
# => {"@id": {"@id": "bob", "foaf:age" 23}, "ex:certainty": 0.9}
72+
73+
#### Reading a Graph containing embedded statements
74+
75+
By default, {JSON::LD::API.toRdf} (and {JSON::LD::Reader}) will reject a document containing a subject resource.
76+
77+
jsonld = %({
78+
"@id": {
79+
"@id": "bob", "foaf:age" 23
80+
},
81+
"ex:certainty": 0.9
82+
})
83+
graph = RDF::Graph.new << JSON::LD::API.toRdf(input)
84+
# => JSON::LD::JsonLdError::InvalidIdValue
85+
86+
{JSON::LD::API.toRdf} (and {JSON::LD::Reader}) support a boolean valued `rdfstar` option; only one statement is asserted, although the reified statement is contained within the graph.
87+
88+
graph = RDF::Graph.new do |graph|
89+
JSON::LD::Reader.new(jsonld, rdfstar: true) {|reader| graph << reader}
90+
end
91+
graph.count #=> 1
92+
3893
## Examples
3994

4095
```ruby
@@ -568,6 +623,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
568623
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
569624
[PDD]: https://unlicense.org/#unlicensing-contributions
570625
[RDF.rb]: https://rubygems.org/gems/rdf
626+
[JSON-LD*]: https://json-ld.github.io/json-ld-star/
571627
[Rack::LinkedData]: https://rubygems.org/gems/rack-linkeddata
572628
[Backports]: https://rubygems.org/gems/backports
573629
[JSON-LD]: https://www.w3.org/TR/json-ld11/ "JSON-LD 1.1"

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.5
1+
3.1.6

etc/doap.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@type": "doap:Project",
2727
"doap:name": "JSON::LD",
2828
"doap:homepage": "https://github.com/ruby-rdf/json-ld/",
29-
"doap:license": "https://unlicense.org/",
29+
"doap:license": "https://unlicense.org/1.0/",
3030
"doap:shortdesc": "JSON-LD support for RDF.rb.",
3131
"doap:description": "RDF.rb extension for parsing/serializing JSON-LD data.",
3232
"doap:created": "2011-05-07",

etc/doap.nt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#implements> <https://www.w3.org/TR/json-ld11-api/> .
1515
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#implements> <https://www.w3.org/TR/json-ld11-framing/> .
1616
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#implements> <https://www.w3.org/TR/json-ld11/> .
17-
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#license> <https://unlicense.org/> .
17+
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#license> <https://unlicense.org/1.0/> .
1818
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#maintainer> <https://greggkellogg.net/foaf#me> .
1919
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#name> "JSON::LD" .
2020
<https://rubygems.org/gems/json-ld> <http://usefulinc.com/ns/doap#programming-language> "Ruby" .

etc/doap.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
doap:implements <https://www.w3.org/TR/json-ld11/>,
2020
<https://www.w3.org/TR/json-ld11-api/>,
2121
<https://www.w3.org/TR/json-ld11-framing/>;
22-
doap:license <https://unlicense.org/>;
22+
doap:license <https://unlicense.org/1.0/>;
2323
doap:maintainer <https://greggkellogg.net/foaf#me>;
2424
doap:name "JSON::LD"^^xsd:string;
2525
doap:programming-language "Ruby";

etc/earl-stream.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
doap:implements <https://www.w3.org/TR/json-ld11/>,
1919
<https://www.w3.org/TR/json-ld11-api/>,
2020
<https://www.w3.org/TR/json-ld11-framing/>;
21-
doap:license <https://unlicense.org/>;
21+
doap:license <https://unlicense.org/1.0/>;
2222
doap:maintainer <https://greggkellogg.net/foaf#me>;
2323
doap:name "JSON::LD"^^xsd:string;
2424
doap:programming-language "Ruby"^^xsd:string;

etc/earl.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
doap:implements <https://www.w3.org/TR/json-ld11/>,
1919
<https://www.w3.org/TR/json-ld11-api/>,
2020
<https://www.w3.org/TR/json-ld11-framing/>;
21-
doap:license <https://unlicense.org/>;
21+
doap:license <https://unlicense.org/1.0/>;
2222
doap:maintainer <https://greggkellogg.net/foaf#me>;
2323
doap:name "JSON::LD"^^xsd:string;
2424
doap:programming-language "Ruby"^^xsd:string;

example-files/bob-star.jsonld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"@context": {
3+
"@base": "http://example.org/",
4+
"ex": "http://example.org/",
5+
"foaf": "http://xmlns.com/foaf/0.1/"
6+
},
7+
"@id": {
8+
"@id": "bob",
9+
"foaf:age": 23
10+
},
11+
"ex:certainty": 0.8
12+
}

lib/json/ld.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class InvalidLocalContext < JsonLdError; @code = "invalid local context"; end
137137
class InvalidNestValue < JsonLdError; @code = "invalid @nest value"; end
138138
class InvalidPrefixValue < JsonLdError; @code = "invalid @prefix value"; end
139139
class InvalidPropagateValue < JsonLdError; @code = "invalid @propagate value"; end
140+
class InvalidEmbeddedNode < JsonLdError; @code = "invalid reified node"; end
140141
class InvalidRemoteContext < JsonLdError; @code = "invalid remote context"; end
141142
class InvalidReverseProperty < JsonLdError; @code = "invalid reverse property"; end
142143
class InvalidReversePropertyMap < JsonLdError; @code = "invalid reverse property map"; end

0 commit comments

Comments
 (0)