Common OWL/RDFS Vocabularies for use with Ruby RDF.rb
This gem extends RDF::Vocabulary
with #to_ttl
, #to_jsonld
, and #to_html
methods to create special-purpose vocabulary serializations. The HTML version is templated using a Haml template to allow output to be customized.
Also extends RDF::Vocabulary::Format
with the gen-vocab
command extension to the rdf
executable.
As loading vocabularies can dominate processing time, the RDF::Vocabulary.limit_vocabs
method can be used to set a specific set of vocabularies over which to reason. For example:
RDF::Vocabulary.limit_vocabs(:rdf, :rdf, :schema)
will limit the vocabularies which are returned from RDF::Vocabulary.each
, which is used for reasoning and other operations over vocabularies and terms.
Add to your Gemfile
gem "rdf-vocab"
then
bundle install
require "rdf/vocab"
This will load all the vocabulary classes in the library.
Also adds the gen-vocab
command to the rdf
command-line executable to generate specifically generated output in Turtle, JSON-LD, and HTML+RDFa for either built-in or arbitrary vocabularies. Other output serialization formats are also supported as generic RDF Writers and may lack the vocabulary-specific formatting of Turtle, JSON-LD, and HTML+RDFa.
Vocabularies should only be added to this gem if they are widely used. An equivalent process can be used to add a vocabulary to an arbitrary Ruby application or gem if it is more application specific.
New vocabularies should be generated via a pull request after cloning from GitHub. Be sure to use a custom branch name before creating the PR.
First, add an entry to lib/rdf/vocab.rb
, the key is used to identify the vocabulary, and as the default basis for the prefix label to use for the vocabulary. The key names of the object value come from the following:
For more information, see the documentation on RDF::Vocabulary.
lib/rdf/vocab
based on the key name for
your vocabulary. For example, if you've added the vocabulary :foo
, create a
new empty file at lib/rdf/vocab/foo.rb
.rake gen_vocabs
.After the PR is merged, it will be available in the develop
branch until the next library release.
The following definition is for the EARL vocabulary, which uses the patch
capability to address inherent problems in the vocabulary definition.
earl: {
uri: "http://www.w3.org/ns/earl#",
source: "http://www.w3.org/ns/earl",
patch: %{
@prefix earl: <http://www.w3.org/ns/earl#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
AddNew {
# Extends EARL to talk about collections of assertions
earl:Report a rdfs:Class, owl:Class ;
rdfs:label "Report" ;
rdfs:comment "A collection of earl:Assertion" .
earl:assertion a owl:ObjectProperty, rdfs:Property ;
rdfs:label "assertion" ;
rdfs:comment "Test Assertions associated with an earl:Report or earl:TestCase" ;
rdfs:domain [
a owl:Class ;
owl:unionOf (earl:Report earl:TestCase)
] ;
rdfs:range earl:Assertion .
} .
}
}
This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.
git diff --check
to make sure of this..gemspec
or VERSION
files. If you need to change them,
do so on your private branch only.This is free and unencumbered public domain software. For more information, see https://unlicense.org/ or the accompanying {file:LICENSE} file.