Skip to content

Commit fd1ac06

Browse files
committed
Finish 3.1.0
2 parents f0b382c + a08c9f2 commit fd1ac06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+77967
-21205
lines changed

.travis.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
language: ruby
2-
bundler_args: --without debug
32
script: "bundle exec rspec spec"
4-
before_install:
5-
- "gem update --system"
6-
- "gem install bundler"
73
env:
8-
- CI=true
4+
global:
5+
- CI=true
96
rvm:
10-
- 2.2
11-
- 2.3
127
- 2.4
138
- 2.5
14-
- jruby-9
15-
- rbx-3
16-
cache: bundler
9+
- 2.6
10+
- 2.7
11+
- jruby
12+
#cache: bundler
1713
sudo: false
1814
matrix:
1915
allow_failures:
20-
- rvm: jruby-9
21-
- rvm: rbx-3
22-
dist: trusty
16+
- rvm: jruby

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* Gregg Kellogg <gregg@kellogg-assoc.com>
1+
* Gregg Kellogg <gregg@greggkellogg.net>

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Community contributions are essential for keeping Ruby RDF great. We want to kee
66

77
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.
88

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)
1010
* Fork and clone the repo:
1111
`git clone [email protected]:your-username/json-ld.git`
1212
* Install bundle:
@@ -30,7 +30,7 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
3030
of thumb, additions larger than about 15 lines of code), we need an
3131
explicit [public domain dedication][PDD] on record from you.
3232

33-
[YARD]: http://yardoc.org/
34-
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
35-
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
33+
[YARD]: https://yardoc.org/
34+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
35+
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
3636
[pr]: https://github.com/ruby-rdf/json-ld/compare/

Gemfile

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
11
source "https://rubygems.org"
2+
gem "nokogiri", '~> 1.8'
3+
gem "nokogumbo", platforms: :mri
24

35
gemspec
4-
gem 'rdf', git: "https://github.com/ruby-rdf/rdf", branch: "develop"
6+
gem 'rdf', git: "https://github.com/ruby-rdf/rdf", branch: "develop"
57

68
group :development do
7-
gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "develop"
8-
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
9-
gem 'linkeddata', git: "https://github.com/ruby-rdf/linkeddata", branch: "develop"
10-
gem 'rdf-spec', git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
11-
gem 'rdf-isomorphic', git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
12-
gem 'rdf-trig', git: "https://github.com/ruby-rdf/rdf-trig", branch: "develop"
13-
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
14-
gem 'rdf-xsd', git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
9+
gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "develop"
10+
gem 'json-ld-preloaded', github: "ruby-rdf/json-ld-preloaded", branch: "develop"
11+
gem 'ld-patch', github: "ruby-rdf/ld-patch", branch: "develop"
12+
gem 'linkeddata', git: "https://github.com/ruby-rdf/linkeddata", branch: "develop"
13+
gem 'rack-linkeddata', git: "https://github.com/ruby-rdf/rack-linkeddata", branch: "develop"
14+
gem 'rdf-aggregate-repo', git: "https://github.com/ruby-rdf/rdf-aggregate-repo", branch: "develop"
15+
gem 'rdf-isomorphic', git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
16+
gem 'rdf-json', github: "ruby-rdf/rdf-json", branch: "develop"
17+
gem 'rdf-microdata', git: "https://github.com/ruby-rdf/rdf-microdata", branch: "develop"
18+
gem 'rdf-n3', github: "ruby-rdf/rdf-n3", branch: "develop"
19+
gem 'rdf-normalize', github: "ruby-rdf/rdf-normalize", branch: "develop"
20+
gem 'rdf-rdfa', git: "https://github.com/ruby-rdf/rdf-rdfa", branch: "develop"
21+
gem 'rdf-rdfxml', git: "https://github.com/ruby-rdf/rdf-rdfxml", branch: "develop"
22+
gem 'rdf-reasoner', github: "ruby-rdf/rdf-reasoner", branch: "develop"
23+
gem 'rdf-spec', git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
24+
gem 'rdf-tabular', github: "ruby-rdf/rdf-tabular", branch: "develop"
25+
gem 'rdf-trig', git: "https://github.com/ruby-rdf/rdf-trig", branch: "develop"
26+
gem 'rdf-trix', github: "ruby-rdf/rdf-trix", branch: "develop"
27+
gem 'rdf-turtle', git: "https://github.com/ruby-rdf/rdf-turtle", branch: "develop"
28+
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
29+
gem 'rdf-xsd', git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
30+
gem 'sinatra-linkeddata', git: "https://github.com/ruby-rdf/sinatra-linkeddata", branch: "develop"
31+
gem 'shex', github: "ruby-rdf/shex", branch: "develop"
32+
gem 'sparql', git: "https://github.com/ruby-rdf/sparql", branch: "develop"
33+
gem 'sparql-client', git: "https://github.com/ruby-rdf/sparql-client", branch: "develop"
34+
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
1535
gem 'fasterer'
1636
gem 'earl-report'
1737
end
1838

1939
group :development, :test do
20-
gem 'simplecov', require: false, platform: :mri
21-
gem 'coveralls', require: false, platform: :mri
40+
gem 'simplecov', platforms: :mri
41+
gem 'coveralls', '~> 0.8', platforms: :mri
2242
gem 'psych', platforms: [:mri, :rbx]
2343
gem 'benchmark-ips'
2444
gem 'rake'
@@ -27,12 +47,3 @@ end
2747
group :debug do
2848
gem "byebug", platforms: :mri
2949
end
30-
31-
platforms :rbx do
32-
gem 'rubysl', '~> 2.0'
33-
gem 'rubinius', '~> 2.0'
34-
end
35-
36-
platforms :jruby do
37-
gem 'gson', '~> 0.6'
38-
end

README.md

Lines changed: 90 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
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)](http://badge.fury.io/rb/json-ld)
6-
[![Build Status](https://secure.travis-ci.org/ruby-rdf/json-ld.png?branch=master)](http://travis-ci.org/ruby-rdf/json-ld)
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)
77
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/json-ld/badge.svg)](https://coveralls.io/r/ruby-rdf/json-ld)
88

99
## Features
1010

11-
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.
1212

1313
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.
1414

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.
1617

1718
[Implementation Report](file.earl.html)
1819

@@ -48,16 +49,16 @@ require 'json/ld'
4849

4950
[{
5051
"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"}]
52+
"http://xmlns.com/foaf/0.1/homepage": [{"@value"=>"https://manu.sporny.org/"}],
53+
"http://xmlns.com/foaf/0.1/avatar": [{"@value": "https://twitter.com/account/profile_image/manusporny"}]
5354
}]
5455
```
5556
### Compact a Document
5657
```ruby
5758
input = JSON.parse %([{
5859
"http://xmlns.com/foaf/0.1/name": ["Manu Sporny"],
59-
"http://xmlns.com/foaf/0.1/homepage": [{"@id": "http://manu.sporny.org/"}],
60-
"http://xmlns.com/foaf/0.1/avatar": [{"@id": "http://twitter.com/account/profile_image/manusporny"}]
60+
"http://xmlns.com/foaf/0.1/homepage": [{"@id": "https://manu.sporny.org/"}],
61+
"http://xmlns.com/foaf/0.1/avatar": [{"@id": "https://twitter.com/account/profile_image/manusporny"}]
6162
}])
6263

6364
context = JSON.parse(%({
@@ -75,8 +76,8 @@ require 'json/ld'
7576
"homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"},
7677
"avatar": {"@id": "http://xmlns.com/foaf/0.1/avatar", "@type": "@id"}
7778
},
78-
"avatar": "http://twitter.com/account/profile_image/manusporny",
79-
"homepage": "http://manu.sporny.org/",
79+
"avatar": "https://twitter.com/account/profile_image/manusporny",
80+
"homepage": "https://manu.sporny.org/",
8081
"name": "Manu Sporny"
8182
}
8283
```
@@ -167,7 +168,7 @@ require 'json/ld'
167168
```ruby
168169
input = JSON.parse %({
169170
"@context": {
170-
"": "http://manu.sporny.org/",
171+
"": "https://manu.sporny.org/",
171172
"foaf": "http://xmlns.com/foaf/0.1/"
172173
},
173174
"@id": "http://example.org/people#joebob",
@@ -192,15 +193,15 @@ require 'json/ld'
192193
input = RDF::Graph.new << RDF::Turtle::Reader.new(%(
193194
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
194195
195-
<http://manu.sporny.org/#me> a foaf:Person;
196+
<https://manu.sporny.org/#me> a foaf:Person;
196197
foaf:knows [ a foaf:Person;
197198
foaf:name "Gregg Kellogg"];
198199
foaf:name "Manu Sporny" .
199200
))
200201

201202
context = JSON.parse %({
202203
"@context": {
203-
"": "http://manu.sporny.org/",
204+
"": "https://manu.sporny.org/",
204205
"foaf": "http://xmlns.com/foaf/0.1/"
205206
}
206207
})
@@ -217,30 +218,30 @@ require 'json/ld'
217218
"http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}]
218219
},
219220
{
220-
"@id": "http://manu.sporny.org/#me",
221+
"@id": "https://manu.sporny.org/#me",
221222
"@type": ["http://xmlns.com/foaf/0.1/Person"],
222223
"http://xmlns.com/foaf/0.1/knows": [{"@id": "_:g70265766605380"}],
223224
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}]
224225
}
225226
]
226227
```
227228
## Use a custom Document Loader
228-
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)).
229230

230231
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:
231232
```ruby
232-
def load_document_local(url, options={}, &block)
233-
if RDF::URI(url, canonicalize: true) == RDF::URI('http://schema.org/')
234-
remote_document = JSON::LD::API::RemoteDocument.new(url, File.read("etc/schema.org.jsonld"))
235-
return block_given? ? yield(remote_document) : remote_document
236-
else
237-
JSON::LD::API.documentLoader(url, options, &block)
238-
end
239-
end
233+
def load_document_local(url, options={}, &block)
234+
if RDF::URI(url, canonicalize: true) == RDF::URI('http://schema.org/')
235+
remote_document = JSON::LD::API::RemoteDocument.new(url, File.read("etc/schema.org.jsonld"))
236+
return block_given? ? yield(remote_document) : remote_document
237+
else
238+
JSON::LD::API.documentLoader(url, options, &block)
239+
end
240+
end
240241
```
241242
Then, when performing something like expansion:
242243
```ruby
243-
JSON::LD::API.expand(input, documentLoader: load_document_local)
244+
JSON::LD::API.expand(input, documentLoader: load_document_local)
244245
```
245246

246247
## Preloading contexts
@@ -433,19 +434,52 @@ Many JSON APIs separate properties from their entities using an intermediate obj
433434
```
434435
In this way, nesting survives round-tripping through expansion, and framed output can include nested properties.
435436

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.
439+
440+
An HTTP header may be constructed as follows:
441+
442+
GET /ordinary-json-document.json HTTP/1.1
443+
Host: example.com
444+
Accept: application/ld+json;profile="http://www.w3.org/ns/json-ld#compacted http://conneg.example.com/context", application/ld+json
445+
446+
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:
474+
475+
$ rackup config.ru
476+
477+
$ curl -iH 'Accept: application/ld+json;profile="http://www.w3.org/ns/json-ld#compacted http://conneg.example.com/context"' http://localhost:9292/hello
438478

439-
* [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.
446480

447481
## 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)
449483

450484
## Differences from [JSON-LD API][]
451485
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
468502
* {JSON::LD::Writer}
469503

470504
## 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)
474508

475509
## Installation
476-
The recommended installation method is via [RubyGems](http://rubygems.org/).
510+
The recommended installation method is via [RubyGems](https://rubygems.org/).
477511
To install the latest official release of the `JSON-LD` gem, do:
478512
```bash
479513
% [sudo] gem install json-ld
@@ -484,10 +518,10 @@ To get a local working copy of the development repository, do:
484518
% git clone git://github.com/ruby-rdf/json-ld.git
485519
```
486520
## Mailing List
487-
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
521+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
488522

489523
## Author
490-
* [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
524+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
491525

492526
## Contributing
493527
* Do your best to adhere to the existing coding conventions and idioms.
@@ -506,17 +540,20 @@ License
506540
-------
507541

508542
This is free and unencumbered public domain software. For more information,
509-
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
510-
511-
[Ruby]: http://ruby-lang.org/
512-
[RDF]: http://www.w3.org/RDF/
513-
[YARD]: http://yardoc.org/
514-
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
515-
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
516-
[RDF.rb]: http://rubygems.org/gems/rdf
517-
[Backports]: http://rubygems.org/gems/backports
518-
[JSON-LD]: http://www.w3.org/TR/json-ld/ "JSON-LD 1.0"
519-
[JSON-LD API]: http://www.w3.org/TR/json-ld-api/ "JSON-LD 1.0 Processing Algorithms and API"
520-
[JSON-LD Framing]: http://json-ld.org/spec/latest/json-ld-framing/ "JSON-LD Framing 1.0"
521-
[Promises]: http://dom.spec.whatwg.org/#promises
543+
see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
544+
545+
[Ruby]: https://ruby-lang.org/
546+
[RDF]: https://www.w3.org/RDF/
547+
[YARD]: https://yardoc.org/
548+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
549+
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
550+
[RDF.rb]: https://rubygems.org/gems/rdf
551+
[Rack::LinkedData]: https://rubygems.org/gems/rack-linkeddata
552+
[Backports]: https://rubygems.org/gems/backports
553+
[JSON-LD]: https://www.w3.org/TR/json-ld11/ "JSON-LD 1.1"
554+
[JSON-LD API]: https://www.w3.org/TR/json-ld11-api/ "JSON-LD 1.1 Processing Algorithms and API"
555+
[JSON-LD Framing]: https://www.w3.org/TR/json-ld11-framing/ "JSON-LD Framing 1.1"
556+
[Promises]: https://dom.spec.whatwg.org/#promises
522557
[jsonlint]: https://rubygems.org/gems/jsonlint
558+
[Sinatra]: https://www.sinatrarb.com/
559+
[Rack]: https://rack.github.com/

0 commit comments

Comments
 (0)