Skip to content

Commit

Permalink
Finish 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed May 30, 2020
2 parents 0d06bb3 + 03545a8 commit babb6fc
Show file tree
Hide file tree
Showing 17 changed files with 1,182 additions and 800 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ group :development, :test do
gem 'rdf-spec', git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
gem 'rdf-isomorphic', git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem 'rdf-xsd', git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
gem "redcarpet", platforms: :ruby
gem 'simplecov', platforms: :mri
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Install with `gem install rdf-turtle`
* Implements a complete parser for [Turtle][].
* Compatible with Ruby >= 2.2.2.
* Optional streaming writer, to serialize large graphs
* Provisional support for [Turtle*][RDF*].

## Usage
Instantiate a reader from a local file:
Expand All @@ -35,6 +36,50 @@ Write a graph to a file:
writer << graph
end

## Turtle* (RDFStar)

Both reader and writer include provisional support for [Turtle*][RDF*].

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

**Note: This feature is subject to change or elimination as the standards process progresses.**

### Serializing a Graph containing embedded statements

require 'rdf/turtle'
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
graph.dump(:ttl, validate: false, standard_prefixes: true)
# => '<<<bob> foaf:age 23>> <ex:certainty> 9.0e-1 .'

### Reading a Graph containing embedded statements

By default, the Turtle reader will reject a document containing a subject resource.

ttl = %(
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
<<<bob> foaf:age 23>> ex:certainty 9.0e-1 .
)
graph = RDF::Graph.new do |graph|
RDF::Turtle::Reader.new(ttl) {|reader| graph << reader}
end
# => RDF::ReaderError

Readers support a `rdfstar` option with either `:PG` (Property Graph) or `:SA` (Separate Assertions) modes. In `:PG` mode, statements that are used in the subject or object positions are also implicitly added to the graph:

graph = RDF::Graph.new do |graph|
RDF::Turtle::Reader.new(ttl, rdfstar: :PG) {|reader| graph << reader}
end
graph.count #=> 2

When using the `:SA` mode, only one statement is asserted, although the reified statement is contained within the graph.

graph = RDF::Graph.new do |graph|
RDF::Turtle::Reader.new(ttl, rdfstar: :SA) {|reader| graph << reader}
end
graph.count #=> 1

## Documentation
Full documentation available on [Rubydoc.info][Turtle doc]

Expand Down Expand Up @@ -133,6 +178,7 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
[Backports]: https://rubygems.org/gems/backports
[N-Triples]: https://www.w3.org/TR/rdf-testcases/#ntriples
[Turtle]: https://www.w3.org/TR/2012/WD-turtle-20120710/
[RDF*]: https://lists.w3.org/Archives/Public/public-rdf-star/
[Turtle doc]: https://rubydoc.info/github/ruby-rdf/rdf-turtle/master/file/README.md
[Turtle EBNF]: https://dvcs.w3.org/hg/rdf/file/default/rdf-turtle/turtle.bnf
[Freebase Dumps]: https://developers.google.com/freebase/data
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
29 changes: 12 additions & 17 deletions etc/doap-ntriples.ttl
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
@base <https://rubygems.org/gems/rdf> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix earl: <http://www.w3.org/ns/earl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://rubygems.org/gems/rdf> a doap:Project ;
<> a doap:Project ;
doap:name "RDF.rb" ;
doap:homepage <https://rubygems.org/gems/rdf> ;
doap:license <http://creativecommons.org/licenses/publicdomain/> ;
doap:license <https://unlicense.org/1.0/> ;
doap:shortdesc "A Ruby library for working with Resource Description Framework (RDF) data."@en ;
doap:description "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en ;
doap:created "2007-10-23" ;
doap:platform "Ruby" ;
doap:programming-language "Ruby" ;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
doap:implements <https://www.w3.org/TR/rdf11-concepts/>,
<https://www.w3.org/TR/n-quads/>,
<https://www.w3.org/TR/n-triples/> ;
doap:implements <http://www.w3.org/TR/rdf11-concepts/>,
<http://www.w3.org/TR/n-quads/>,
<http://www.w3.org/TR/n-triples/> ;
doap:download-page <https://rubygems.org/gems/rdf/> ;
doap:bug-database <https://github.com/ruby-rdf/rdf/issues> ;
doap:blog <https://ar.to/>, <http://blog.datagraph.org/> ;
doap:vendor <http://datagraph.org/> ;
doap:blog <https://ar.to/>, <https://greggkellogg.net/> ;
doap:developer <https://ar.to/#self>, <https://bhuga.net/#ben>, <https://greggkellogg.net/foaf#me> ;
doap:maintainer <https://ar.to/#self>, <https://bhuga.net/#ben>, <https://greggkellogg.net/foaf#me> ;
doap:maintainer <https://greggkellogg.net/foaf#me> ;
doap:documenter <https://ar.to/#self>, <https://bhuga.net/#ben>, <https://greggkellogg.net/foaf#me> ;
doap:helper [a foaf:Person ;
foaf:name "Călin Ardelean" ;
Expand Down Expand Up @@ -63,19 +60,17 @@
foaf:mbox_sha1sum "a033f652c84a4d73b8c26d318c2395699dd2bdfb",
"d0737cceb55eb7d740578d2db1bc0727e3ed49ce" ;
foaf:homepage <https://ar.to/> ;
foaf:made <> ;
rdfs:isDefinedBy <http://datagraph.org/bendiken/foaf> .
foaf:made <> .

<https://bhuga.net/#ben> a foaf:Person ;
foaf:name "Ben Lavender" ;
foaf:mbox <mailto:[email protected]> ;
foaf:mbox_sha1sum "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" ;
foaf:homepage <https://bhuga.net/> ;
rdfs:isDefinedBy <http://datagraph.org/bhuga/foaf> .
foaf:homepage <https://bhuga.net/> .

<https://greggkellogg.net/foaf#me> a foaf:Person ;
foaf:name "Gregg Kellogg" ;
foaf:mbox <mailto:[email protected]> ;
foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" ;
foaf:homepage <https://greggkellogg.net/>;
rdfs:isDefinedBy <https://greggkellogg.net/foaf> .
rdfs:isDefinedBy <https://greggkellogg.net/foaf> .
2 changes: 1 addition & 1 deletion etc/doap.nt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<https://rubygems.org/gems/rdf-turtle> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/earl#Software> .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#name> "RDF::Turtle" .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#homepage> <https://ruby-rdf.github.com/rdf-turtle> .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#license> <https://unlicense.org/1.0/> .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#shortdesc> "Turtle reader/writer for Ruby."@en .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#description> "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en .
<https://rubygems.org/gems/rdf-turtle> <http://usefulinc.com/ns/doap#created> "2011-08-29"^^<http://www.w3.org/2001/XMLSchema#date> .
Expand Down
7 changes: 4 additions & 3 deletions etc/doap.ttl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@base <https://rubygems.org/gems/rdf-turtle> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://purl.org/dc/terms/> .
Expand All @@ -7,18 +8,18 @@
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://rubygems.org/gems/rdf-turtle> a doap:Project, earl:TestSubject, earl:Software ;
<> a doap:Project, earl:TestSubject, earl:Software ;
doap:name "RDF::Turtle" ;
doap:homepage <https://ruby-rdf.github.com/rdf-turtle> ;
doap:license <http://creativecommons.org/licenses/publicdomain/> ;
doap:license <https://unlicense.org/1.0/> ;
doap:shortdesc "Turtle reader/writer for Ruby."@en ;
doap:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
doap:created "2011-08-29"^^xsd:date ;
doap:programming-language "Ruby" ;
doap:implements <https://www.w3.org/TR/turtle/> ;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
doap:download-page <https://rubygems.org/gems/rdf-turtle> ;
doap:download-page <> ;
doap:mailing-list <https://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
doap:bug-database <https://github.com/ruby-rdf/rdf-turtle/issues> ;
doap:blog <https://greggkellogg.net/> ;
Expand Down
Loading

0 comments on commit babb6fc

Please sign in to comment.