Module: JSON::LD

Defined in:
lib/json/ld.rb,
lib/json/ld/format.rb,
lib/json/ld/reader.rb,
lib/json/ld/writer.rb

Overview

**‘JSON::LD`** is a JSON-LD plugin for RDF.rb.

Examples:

Requiring the ‘JSON::LD` module

require 'json/ld'

Parsing RDF statements from a JSON-LD file

JSON::LD::Reader.open("etc/foaf.jld") do |reader|
  reader.each_statement do |statement|
    puts statement.inspect
  end
end

See Also:

Author:

Defined Under Namespace

Classes: Format, JSONLD, Reader, Writer

Constant Summary collapse

BASE =

Keywords

'@base'.freeze
COERCE =
'@coerce'.freeze
CONTEXT =
'@context'.freeze
DATATYPE =
'@datatype'.freeze
IRI =
'@iri'.freeze
LANGUAGE =
'@language'.freeze
LITERAL =
'@literal'.freeze
SUBJECT =
'@subject'.freeze
TYPE =
'@type'.freeze
VOCAB =
'@vocab'.freeze
DEFAULT_CONTEXT =

Default context

{
  'rdf'           => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
  'rdfs'          => 'http://www.w3.org/2000/01/rdf-schema#',
  'owl'           => 'http://www.w3.org/2002/07/owl#',
  'xsd'           => 'http://www.w3.org/2001/XMLSchema#',
  'dcterms'       => 'http://purl.org/dc/terms/',
  'foaf'          => 'http://xmlns.com/foaf/0.1/',
  'cal'           => 'http://www.w3.org/2002/12/cal/ical#',
  'vcard'         => 'http://www.w3.org/2006/vcard/ns# ',
  'geo'           => 'http://www.w3.org/2003/01/geo/wgs84_pos#',
  'cc'            => 'http://creativecommons.org/ns#',
  'sioc'          => 'http://rdfs.org/sioc/ns#',
  'doap'          => 'http://usefulinc.com/ns/doap#',
  'com'           => 'http://purl.org/commerce#',
  'ps'            => 'http://purl.org/payswarm#',
  'gr'            => 'http://purl.org/goodrelations/v1#',
  'sig'           => 'http://purl.org/signature#',
  'ccard'         => 'http://purl.org/commerce/creditcard#',
  '@coerce'       => {
    # Note: rdf:type is not in the document, but necessary for this implementation
    'xsd:anyURI'  => ['rdf:type', 'rdf:rest', 'foaf:homepage', 'foaf:member'],
    'xsd:integer' => 'foaf:age',
  }
}.freeze
DEFAULT_COERCE =

Default type coercion, in property => datatype order

{
  RDF.type           => RDF::XSD.anyURI,
  RDF.first          => false,            # Make sure @coerce isn't generated for this
  RDF.rest           => RDF::XSD.anyURI,
  RDF::FOAF.homepage => RDF::XSD.anyURI,
  RDF::FOAF.member   => RDF::XSD.anyURI,
  RDF::FOAF.age      => RDF::XSD.integer,
}.freeze

Class Method Summary collapse

Class Method Details

.debug=(value) ⇒ Object



80
# File 'lib/json/ld.rb', line 80

def self.debug=(value); @debug = value; end

.debug?Boolean

Returns:

  • (Boolean)


79
# File 'lib/json/ld.rb', line 79

def self.debug?; @debug; end