RDF::TriG parses TriG into statements or quads. It also serializes to TriG.
gem install rdf-trig
- 100% free and unencumbered public domain software.
- Implements a complete parser and serializer for TriG.
- Compatible with Ruby 1.8.7+, Ruby 1.9.x, and JRuby 1.4/1.5.
Instantiate a reader from a local file:
repo = RDF::Repository.load("etc/doap.trig", :format => :trig)
@prefix definitions, and use for serialization using
Canonicalize and validate using
Write a repository to a file:
RDF::TriG::Writer.open("etc/test.trig") do |writer| writer << repo end
Note that reading and writing of graphs is also possible, but as graphs have only a single context, it is not particularly interesting for TriG.
Full documentation available on Rubydoc.info.
Interpretations of the spec
It is still not defined what the interpretation of multiple uses of the same
graphIri mean. This implementation takes
the use of multiple graphs having the same
graphIri to be additive, meaning that the statements from each graph
are combined together to create a single graph.
Graphs are written with
context set to the associated
RDF::Repository allows any
RDF::Value, such as a BNode, literal or variable to be used as a context, TriG
only allows the use of an IRI.
The reader uses the Turtle parser, which is based on the LL1::Parser with minor updates for the TriG grammar. The writer also is based on the Turtle writer.
The recommended installation method is via RubyGems.
To install the latest official release of the
RDF::TriG gem, do:
% [sudo] gem install rdf-trig
- Do your best to adhere to the existing coding conventions and idioms.
- Don't use hard tabs, and don't leave trailing whitespace on any line.
- Do document every method you add using YARD annotations. Read the tutorial or just look at the existing code for examples.
- Don't touch the
AUTHORSfiles. If you need to change them, do so on your private branch only.
- Do feel free to add yourself to the
CREDITSfile and the corresponding list in the the
README. Alphabetical order applies.
- Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you.