Skip to content

Commit 7f91961

Browse files
committed
Finish 2.1.3
2 parents 4e3e9e6 + 149df22 commit 7f91961

34 files changed

+29032
-1358
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ script: "bundle exec rspec spec"
44
env:
55
- CI=true
66
rvm:
7-
- 2.2.6
8-
- 2.3.3
7+
- 2.2
8+
- 2.3
99
- 2.4
10-
- jruby
11-
- rbx
10+
- jruby-9
11+
- rbx-3
1212
cache: bundler
1313
sudo: false
1414
matrix:
1515
allow_failures:
16-
- rvm: jruby
17-
- rvm: rbx
18-
- rvm: 2.4
16+
- rvm: jruby-9
17+
- rvm: rbx-3
18+
dist: trusty

.yardopts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
AUTHORS
1010
VERSION
1111
UNLICENSE
12+
etc/earl.html

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ group :development do
1212
gem 'rdf-vocab', github: "ruby-rdf/rdf-vocab", branch: "develop"
1313
gem 'rdf-xsd', github: "ruby-rdf/rdf-xsd", branch: "develop"
1414
gem 'fasterer'
15+
gem 'earl-report'
1516
end
1617

1718
group :development, :test do
18-
gem 'simplecov', require: false, platform: :mri
19+
gem 'simplecov', require: false, platform: :mri, github: "colszowka/simplecov" # Until Fixnum issues solved
1920
gem 'coveralls', require: false, platform: :mri
2021
gem 'psych', platforms: [:mri, :rbx]
2122
gem 'benchmark-ips'

README.md

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and
1414

1515
If the [jsonlint][] gem is installed, it will be used when validating an input document.
1616

17+
[Implementation Report](file.earl.html)
18+
1719
Install with `gem install json-ld`
1820

1921
### MultiJson parser
@@ -45,9 +47,9 @@ This gem implements an optimized streaming writer used for generating JSON-LD fr
4547
JSON::LD::API.expand(input) =>
4648

4749
[{
48-
"http://xmlns.com/foaf/0.1/name": ["Manu Sporny"],
49-
"http://xmlns.com/foaf/0.1/homepage": ["http://manu.sporny.org/"],
50-
"http://xmlns.com/foaf/0.1/avatar": ["http://twitter.com/account/profile_image/manusporny"]
50+
"http://xmlns.com/foaf/0.1/name": [{"@value"=>"Manu Sporny"}],
51+
"http://xmlns.com/foaf/0.1/homepage": [{"@value"=>"http://manu.sporny.org/"}],
52+
"http://xmlns.com/foaf/0.1/avatar": [{"@value": "http://twitter.com/account/profile_image/manusporny"}]
5153
}]
5254

5355
### Compact a Document
@@ -261,6 +263,107 @@ A context may be serialized to Ruby to speed this process using `Context#to_rb`.
261263

262264
As JSON-LD may come from many different sources, included as an embedded script tag within an HTML document, the RDF Reader will strip input before the leading `{` or `[` and after the trailing `}` or `]`.
263265

266+
## Extensions from JSON-LD 1.0
267+
This implementation is being used as a test-bed for features planned for an upcoming JSON-LD 1.1 Community release.
268+
269+
### Scoped Contexts
270+
A term definition can include `@context`, which is applied to values of that object. This is also used when compacting. Taken together, this allows framing to effectively include context definitions more deeply within the framed structure.
271+
272+
{
273+
"@context": {
274+
"ex": "http://example.com/",
275+
"foo": {
276+
"@id": "ex:foo",
277+
"@type": "@vocab"
278+
"@context": {
279+
"Bar": "ex:Bar",
280+
"Baz": "ex:Baz"
281+
}
282+
}
283+
},
284+
"foo": "Bar"
285+
}
286+
287+
### @id and @type maps
288+
The value of `@container` in a term definition can include `@id` or `@type`, in addition to `@set`, `@list`, `@language`, and `@index`. This allows value indexing based on either the `@id` or `@type` of associated objects.
289+
290+
{
291+
"@context": {
292+
"@vocab": "http://example/",
293+
"idmap": {"@container": "@id"}
294+
},
295+
"idmap": {
296+
"http://example.org/foo": {"label": "Object with @id <foo>"},
297+
"_:bar": {"label": "Object with @id _:bar"}
298+
}
299+
}
300+
301+
### Transparent Nesting
302+
Many JSON APIs separate properties from their entities using an intermediate object. For example, a set of possible labels may be grouped under a common property:
303+
304+
{
305+
"@context": {
306+
"skos": "http://www.w3.org/2004/02/skos/core#",
307+
"labels": "@nest",
308+
"main_label": {"@id": "skos:prefLabel"},
309+
"other_label": {"@id": "skos:altLabel"},
310+
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
311+
},
312+
"@id":"http://example.org/myresource",
313+
"homepage": "http://example.org",
314+
"labels": {
315+
"main_label": "This is the main label for my resource",
316+
"other_label": "This is the other label"
317+
}
318+
}
319+
320+
In this case, the `labels` property is semantically meaningless. Defining it as equivalent to `@nest` causes it to be ignored when expanding, making it equivalent to the following:
321+
322+
{
323+
"@context": {
324+
"skos": "http://www.w3.org/2004/02/skos/core#",
325+
"labels": "@nest",
326+
"main_label": {"@id": "skos:prefLabel"},
327+
"other_label": {"@id": "skos:altLabel"},
328+
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
329+
},
330+
"@id":"http://example.org/myresource",
331+
"homepage": "http://example.org",
332+
"main_label": "This is the main label for my resource",
333+
"other_label": "This is the other label"
334+
}
335+
336+
Similarly, properties may be marked with "@nest": "nest-term", to cause them to be nested. Note that the `@nest` keyword can also be aliased in the context.
337+
338+
{
339+
"@context": {
340+
"skos": "http://www.w3.org/2004/02/skos/core#",
341+
"labels": "@nest",
342+
"main_label": {"@id": "skos:prefLabel", "@nest": "labels"},
343+
"other_label": {"@id": "skos:altLabel", "@nest": "labels"},
344+
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
345+
},
346+
"@id":"http://example.org/myresource",
347+
"homepage": "http://example.org",
348+
"labels": {
349+
"main_label": "This is the main label for my resource",
350+
"other_label": "This is the other label"
351+
}
352+
}
353+
354+
In this way, nesting survives round-tripping through expansion, and framed output can include nested properties.
355+
356+
### Framing Updates
357+
The [JSON-LD Framing 1.1 Specification]() improves on previous un-released versions.
358+
359+
* [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.
360+
* [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.
361+
* Use `@graph` in frame, matches the default graph, not the merged graph.
362+
* Use `@graph` in property value, causes the apropriatly named graph to be used for filling in values.
363+
* [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.
364+
* [@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`.
365+
* [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.
366+
264367
## Documentation
265368
Full documentation available on [RubyDoc](http://rubydoc.info/gems/json-ld/file/README.md)
266369

@@ -286,7 +389,7 @@ Note, the API method signatures differed in versions before 1.0, in that they al
286389

287390
## Dependencies
288391
* [Ruby](http://ruby-lang.org/) (>= 2.2.2)
289-
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0)
392+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.2)
290393
* [JSON](https://rubygems.org/gems/json) (>= 1.5)
291394

292395
## Installation

Rakefile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
2020
spec.rspec_opts = %w(--options spec/spec.opts) if File.exists?('spec/spec.opts')
2121
end
2222

23-
desc "Run specs through RCov"
24-
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
25-
spec.rcov = true
26-
spec.rcov_opts = %q[--exclude "spec"]
27-
end
28-
29-
desc "Generate HTML report specs"
30-
RSpec::Core::RakeTask.new("doc:spec") do |spec|
31-
spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
32-
end
33-
3423
desc "Generate schema.org context"
3524
task :schema_context do
3625
%x(
@@ -42,6 +31,29 @@ task :schema_context do
4231
)
4332
end
4433

34+
desc "Create concatenated test manifests"
35+
file "etc/manifests.nt" do
36+
require 'rdf'
37+
require 'json/ld'
38+
require 'rdf/ntriples'
39+
graph = RDF::Graph.new do |g|
40+
%w( http://json-ld.org/test-suite/tests/compact-manifest.jsonld
41+
http://json-ld.org/test-suite/tests/error-manifest.jsonld
42+
http://json-ld.org/test-suite/tests/expand-manifest.jsonld
43+
http://json-ld.org/test-suite/tests/flatten-manifest.jsonld
44+
http://json-ld.org/test-suite/tests/frame-manifest.jsonld
45+
http://json-ld.org/test-suite/tests/fromRdf-manifest.jsonld
46+
http://json-ld.org/test-suite/tests/remote-doc-manifest.jsonld
47+
http://json-ld.org/test-suite/tests/toRdf-manifest.jsonld
48+
).each do |man|
49+
puts "load #{man}"
50+
g.load(man, unique_bnodes: true)
51+
end
52+
end
53+
puts "write"
54+
RDF::NTriples::Writer.open("etc/manifests.nt", unique_bnodes: true, validate: false) {|w| w << graph}
55+
end
56+
4557
# Presentation building
4658
namespace :presentation do
4759
desc "Clean presentation files"

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.2
1+
2.1.3

etc/.earl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
:format: :json
3+
:manifest: manifests.nt
4+
:bibRef: ! '[[json-ld-api]]'
5+
:name: JSON-LD 1.1 Processing Algorithms and API

etc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.byebug_history

etc/README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This is a collection of individual EARL reports for
2+
test subjects claiming Turtle processor conformance.
3+
4+
The consolodated report is saved to index.html generated
5+
using the earl-report Ruby gem. Run it as follows:
6+
7+
gem install earl-report
8+
9+
rm manifest.nt && (cd ..; rake manifest.nt)
10+
earl-report --format json -o earl.jsonld earl.ttl
11+
earl-report --json --format html --template template.haml -o earl.html earl.jsonld

0 commit comments

Comments
 (0)