Skip to content

Commit

Permalink
Finish 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 29, 2017
2 parents 4e3e9e6 + 149df22 commit 7f91961
Show file tree
Hide file tree
Showing 34 changed files with 29,032 additions and 1,358 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Expand Up @@ -4,15 +4,15 @@ script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.2.6
- 2.3.3
- 2.2
- 2.3
- 2.4
- jruby
- rbx
- jruby-9
- rbx-3
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: jruby
- rvm: rbx
- rvm: 2.4
- rvm: jruby-9
- rvm: rbx-3
dist: trusty
1 change: 1 addition & 0 deletions .yardopts
Expand Up @@ -9,3 +9,4 @@
AUTHORS
VERSION
UNLICENSE
etc/earl.html
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -12,10 +12,11 @@ group :development do
gem 'rdf-vocab', github: "ruby-rdf/rdf-vocab", branch: "develop"
gem 'rdf-xsd', github: "ruby-rdf/rdf-xsd", branch: "develop"
gem 'fasterer'
gem 'earl-report'
end

group :development, :test do
gem 'simplecov', require: false, platform: :mri
gem 'simplecov', require: false, platform: :mri, github: "colszowka/simplecov" # Until Fixnum issues solved
gem 'coveralls', require: false, platform: :mri
gem 'psych', platforms: [:mri, :rbx]
gem 'benchmark-ips'
Expand Down
111 changes: 107 additions & 4 deletions README.md
Expand Up @@ -14,6 +14,8 @@ JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and

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

[Implementation Report](file.earl.html)

Install with `gem install json-ld`

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

[{
"http://xmlns.com/foaf/0.1/name": ["Manu Sporny"],
"http://xmlns.com/foaf/0.1/homepage": ["http://manu.sporny.org/"],
"http://xmlns.com/foaf/0.1/avatar": ["http://twitter.com/account/profile_image/manusporny"]
"http://xmlns.com/foaf/0.1/name": [{"@value"=>"Manu Sporny"}],
"http://xmlns.com/foaf/0.1/homepage": [{"@value"=>"http://manu.sporny.org/"}],
"http://xmlns.com/foaf/0.1/avatar": [{"@value": "http://twitter.com/account/profile_image/manusporny"}]
}]

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

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 `]`.

## Extensions from JSON-LD 1.0
This implementation is being used as a test-bed for features planned for an upcoming JSON-LD 1.1 Community release.

### Scoped Contexts
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.

{
"@context": {
"ex": "http://example.com/",
"foo": {
"@id": "ex:foo",
"@type": "@vocab"
"@context": {
"Bar": "ex:Bar",
"Baz": "ex:Baz"
}
}
},
"foo": "Bar"
}

### @id and @type maps
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.

{
"@context": {
"@vocab": "http://example/",
"idmap": {"@container": "@id"}
},
"idmap": {
"http://example.org/foo": {"label": "Object with @id <foo>"},
"_:bar": {"label": "Object with @id _:bar"}
}
}

### Transparent Nesting
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:

{
"@context": {
"skos": "http://www.w3.org/2004/02/skos/core#",
"labels": "@nest",
"main_label": {"@id": "skos:prefLabel"},
"other_label": {"@id": "skos:altLabel"},
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
},
"@id":"http://example.org/myresource",
"homepage": "http://example.org",
"labels": {
"main_label": "This is the main label for my resource",
"other_label": "This is the other label"
}
}

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:

{
"@context": {
"skos": "http://www.w3.org/2004/02/skos/core#",
"labels": "@nest",
"main_label": {"@id": "skos:prefLabel"},
"other_label": {"@id": "skos:altLabel"},
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
},
"@id":"http://example.org/myresource",
"homepage": "http://example.org",
"main_label": "This is the main label for my resource",
"other_label": "This is the other label"
}

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.

{
"@context": {
"skos": "http://www.w3.org/2004/02/skos/core#",
"labels": "@nest",
"main_label": {"@id": "skos:prefLabel", "@nest": "labels"},
"other_label": {"@id": "skos:altLabel", "@nest": "labels"},
"homepage": {"@id":"http://schema.org/description", "@type":"@id"}
},
"@id":"http://example.org/myresource",
"homepage": "http://example.org",
"labels": {
"main_label": "This is the main label for my resource",
"other_label": "This is the other label"
}
}

In this way, nesting survives round-tripping through expansion, and framed output can include nested properties.

### Framing Updates
The [JSON-LD Framing 1.1 Specification]() improves on previous un-released versions.

* [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.
* [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.
* Use `@graph` in frame, matches the default graph, not the merged graph.
* Use `@graph` in property value, causes the apropriatly named graph to be used for filling in values.
* [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.
* [@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`.
* [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.

## Documentation
Full documentation available on [RubyDoc](http://rubydoc.info/gems/json-ld/file/README.md)

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

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

## Installation
Expand Down
34 changes: 23 additions & 11 deletions Rakefile
Expand Up @@ -20,17 +20,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = %w(--options spec/spec.opts) if File.exists?('spec/spec.opts')
end

desc "Run specs through RCov"
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
spec.rcov = true
spec.rcov_opts = %q[--exclude "spec"]
end

desc "Generate HTML report specs"
RSpec::Core::RakeTask.new("doc:spec") do |spec|
spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
end

desc "Generate schema.org context"
task :schema_context do
%x(
Expand All @@ -42,6 +31,29 @@ task :schema_context do
)
end

desc "Create concatenated test manifests"
file "etc/manifests.nt" do
require 'rdf'
require 'json/ld'
require 'rdf/ntriples'
graph = RDF::Graph.new do |g|
%w( http://json-ld.org/test-suite/tests/compact-manifest.jsonld
http://json-ld.org/test-suite/tests/error-manifest.jsonld
http://json-ld.org/test-suite/tests/expand-manifest.jsonld
http://json-ld.org/test-suite/tests/flatten-manifest.jsonld
http://json-ld.org/test-suite/tests/frame-manifest.jsonld
http://json-ld.org/test-suite/tests/fromRdf-manifest.jsonld
http://json-ld.org/test-suite/tests/remote-doc-manifest.jsonld
http://json-ld.org/test-suite/tests/toRdf-manifest.jsonld
).each do |man|
puts "load #{man}"
g.load(man, unique_bnodes: true)
end
end
puts "write"
RDF::NTriples::Writer.open("etc/manifests.nt", unique_bnodes: true, validate: false) {|w| w << graph}
end

# Presentation building
namespace :presentation do
desc "Clean presentation files"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.1.2
2.1.3
5 changes: 5 additions & 0 deletions etc/.earl
@@ -0,0 +1,5 @@
---
:format: :json
:manifest: manifests.nt
:bibRef: ! '[[json-ld-api]]'
:name: JSON-LD 1.1 Processing Algorithms and API
1 change: 1 addition & 0 deletions etc/.gitignore
@@ -0,0 +1 @@
/.byebug_history
11 changes: 11 additions & 0 deletions etc/README
@@ -0,0 +1,11 @@
This is a collection of individual EARL reports for
test subjects claiming Turtle processor conformance.

The consolodated report is saved to index.html generated
using the earl-report Ruby gem. Run it as follows:

gem install earl-report

rm manifest.nt && (cd ..; rake manifest.nt)
earl-report --format json -o earl.jsonld earl.ttl
earl-report --json --format html --template template.haml -o earl.html earl.jsonld

0 comments on commit 7f91961

Please sign in to comment.