Turtle Examples

This page contains some (WIP!) examples of Turtle, as used in the SPARQLy Ruby portion of the SPARQLy project.

Ruby Gems

Each Gem has a name, version, and platform. Assorted information can be harvested from the Gem's spec file and by processing the Gem's contents (eg, Ruby code) using tools such as YARD.


Let's begin by defining some relationships and vocabulary:  

@prefix                rdf:               <http://.../22-rdf-syntax-ns#> .
@prefix                rdfs:              <http://.../rdf-schema#> .

@prefix                item:              <http://.../SG_item/> .             
@prefix                spec:              <http://.../SG_spec#> .
@prefix                term:              <http://.../SG_term#> .

term:partOf            owl:inverseOf      rdf:hasPart .

term:Gem               rdf:type           owl:Class .

term:Constant          rdf:type           owl:Class;
                       term:partOf        term:Module .
term:Module            rdfs:subTypeOf     term:Constant .
term:Class             rdfs:subTypeOf     term:Module .

term:Method            rdf:type           owl:Class;
                       term:partOf        term:Module .
term:ClassMethod       rdfs:subTypeOf     term:Method .
term:InstanceMethod    rdfs:subTypeOf     term:Method .

Example items

Next, let's define some example items (eg, class, constant, gem, method, module):  

  rdf:type         term:Gem;
  spec:author      "Rich Morin";
  spec:name        "foo";
  spec:platform    "x86";
  spec:version     "1.2.3";
  ... .

  rdf:type         term:Module;
  term:bareName    "Foo";
  term:partOf      item:foo-1.2.3-x86;
  term:rubyName    "Foo";
  ... .

  rdf:type         term:ClassMethod;
  term:bareName    "c_method";
  term:partOf      item:foo-1.2.3-x86/Foo;
  term:rubyName    "Foo.c_method";
  ... .

  rdf:type         term:Class;
  term:bareName    "Foo";
  term:partOf      item:foo-1.2.3-x86/Foo;
  term:rubyName    "Foo::Bar";
  ... .

  rdf:type         term:InstanceMethod;
  term:bareName    "bazzle";
  term:partOf      item:foo-1.2.3-x86/Foo/Bar;
  term:rubyName    "Foo::Bar#i_method";
  ... .

  rdf:type         term:Constant;
  term:bareName    "Answer";
  term:hasValue    42;
  term:partOf      item:foo-1.2.3-x86/Foo/Bar;
  ... .

Open issues

  • Are the definitions and items:

    • appropriate for expected use cases?
    • consistent with Gems, Ruby, etc?
    • convenient for use with SPARQL?
    • easy to encode in JSON-LD?

  • Is the use of a slash going to be problematic in SPARQL?
    (eg, in matching namespaces)

This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r5 - 24 Jan 2012, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email