Module: RDF

Included in:
LinkedData, SPARQL::Algebra
Defined in:
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-n3-8fd20193c115/lib/rdf/n3/extensions.rb,
lib/rdf/distiller.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/json-ld-97d0daa4ff8f/lib/json/ld/extensions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/cli.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/query.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/format.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/nquads.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/reader.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/writer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/version.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/ntriples.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/changeset.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/uri.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/file.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/uuid.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocab/owl.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocab/xsd.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/list.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/node.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/term.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/repository.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/cache.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocab/rdfs.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocab/rdfv.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocabulary.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/graph.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/value.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/transaction.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/logger.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/vocab/writer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/durable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/mutable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/dataset.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/query/pattern.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/aliasing.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/readable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/writable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/resource.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/util/coercions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/countable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/indexable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/queryable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/statement.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/query/solutions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/enumerable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/enumerator.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/type_check.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/mixin/transactable.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/date.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/time.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/token.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/double.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/boolean.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/decimal.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/integer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/numeric.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/model/literal/datetime.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf/query/hash_pattern_normalizer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-aggregate-repo-c83f4f154c2c/lib/rdf/aggregate_repo.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-aggregate-repo-c83f4f154c2c/lib/rdf/aggregate_repo/merge_graph.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-isomorphic-7565b54588b0/lib/rdf/isomorphic.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-json-378566cbfa7d/lib/rdf/json.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-json-378566cbfa7d/lib/rdf/json/version.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-microdata-5fe0cadcda10/lib/rdf/microdata.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-microdata-5fe0cadcda10/lib/rdf/microdata/vocab.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-n3-8fd20193c115/lib/rdf/n3.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-normalize-d2cc2beeeb2c/lib/rdf/normalize.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-ordered-repo-8e81a910c24b/lib/rdf/ordered_repo.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-rdfa-17421be4d458/lib/rdf/rdfa.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-rdfa-17421be4d458/lib/rdf/rdfa/vocab.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-rdfxml-f800559d4bc4/lib/rdf/rdfxml.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-reasoner-bfa7ce119263/lib/rdf/reasoner.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-reasoner-bfa7ce119263/lib/rdf/reasoner/extensions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-spec-8ec503ea107d/lib/rdf/spec.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-spec-8ec503ea107d/lib/rdf/spec/version.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-spec-8ec503ea107d/lib/rdf/spec/matchers.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-tabular-4e0282309457/lib/rdf/tabular.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-trig-a0acf1b2acfb/lib/rdf/trig.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-trix-6881e1fedeb2/lib/rdf/trix.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-turtle-71b3a0937286/lib/rdf/turtle.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-vocab-22de070a4ec6/lib/rdf/vocab.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-vocab-22de070a4ec6/lib/rdf/vocab/extensions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/xml.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/date.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/binary.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/double.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/any_uri.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/integer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/duration.rb

Overview

Monkey-patch RDF::Vocab.each to load all vocabularies

Defined Under Namespace

Modules: Countable, DataObjects, Distiller, Durable, Enumerable, Indexable, Isomorphic, JSON, Microdata, Mutable, N3, NQuads, NTriples, Normalize, Queryable, RDFXML, RDFa, Readable, Reasoner, Resource, Spec, Tabular, Term, Transactable, TriG, TriX, Turtle, TypeCheck, Util, VERSION, Value, Vocab, Writable Classes: AggregateRepo, CLI, Changeset, Dataset, Format, FormatError, Graph, HCalendar, HCard, List, Literal, MD, MergeGraph, Node, OWL, OrderedRepo, Query, RDFA, RDFS, RDFV, Reader, ReaderError, Repository, Statement, StrictVocabulary, Transaction, URI, Vocabulary, Writer, WriterError, XSD

Constant Summary collapse

VOCABS =
{
  owl: {uri: "http://www.w3.org/2002/07/owl#", class_name: "OWL"},
  rdfs: {uri: "http://www.w3.org/2000/01/rdf-schema#", class_name: "RDFS"},
  rdfv: {uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", class_name: "RDFV"},
  xsd: {uri: "http://www.w3.org/2001/XMLSchema#", class_name: "XSD"},
}
RDF_N_REGEXP =
%r{_\d+}.freeze
IRI =

RDF::IRI is a synonym for RDF::URI

URI
XML =
Class.new(Vocabulary("http://www.w3.org/XML/1998/namespace"))
XSI =
Class.new(Vocabulary("http://www.w3.org/2001/XMLSchema-instance"))

Class Method Summary collapse

Class Method Details

.[](property) ⇒ #to_s, URI

Returns:

  • (#to_s)

    property

  • (URI)


239
240
241
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 239

def self.[](property)
  property.to_s.match?(%r{_\d+}) ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV[property]
end

.configObject

Note:

cache configurations must be set before initial use, when the caches are allocated.

Configuration, used open for configuring constants used within the codebase.

Defaults:

  • cache_size: -1
  • uri_cache_size: cache_size
  • node_cache_size: cache_size

Examples:

set default cache size to be at most 10,000 entries


RDF.config.cache_size = 10_000

set cache size for interned URIs to 5,000 entries


RDF.config.uri_cache_size = 5_000

Returns:

See Also:

  • RDF::Util::Cache.new


102
103
104
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 102

def self.config
  @config ||= OpenStruct.new(cache_size: -1, uri_cache_size: nil, node_cache_size: nil)
end

.enum_for(method = :each_statement, *args) ⇒ RDF::Enumerable::Enumerator Also known as: to_enum

Return an enumerator over Statement defined for this vocabulary.

Returns:

See Also:

  • Object#enum_for


247
248
249
250
251
252
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 247

def self.enum_for(method = :each_statement, *args)
  # Ensure that enumerators are, themselves, queryable
  Enumerable::Enumerator.new do |yielder|
    RDF::RDFV.send(method, *args) {|*y| yielder << (y.length > 1 ? y : y.first)}
  end
end

.Graph(**options, &block) ⇒ RDF::Graph

Alias for RDF::Graph.new.

Parameters:

  • graph_name (RDF::Resource)

    The graph_name from the associated Queryable associated with this graph as provided with the :data option (only for Queryable instances supporting named graphs).

  • data (RDF::Queryable)

    (RDF::Repository.new) Storage behind this graph.

Returns:



157
158
159
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 157

def self.Graph(**options, &block)
  Graph.new(**options, &block)
end

.ListRDF::URI .List(*args) ⇒ RDF::List .List(array) ⇒ RDF::List .List(list) ⇒ RDF::List

Overloads:



176
177
178
179
180
181
182
183
184
185
186
187
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 176

def self.List(*args)
  case
  when args.empty?
    RDF[:List]
  when args.length == 1 && args.first.is_a?(RDF::List)
    args.first
  when args.length == 1 && args.first.is_a?(Array)
    List[*args.first]
  else
    List[*args]
  end
end

.Literal(literal, **options) ⇒ RDF::Literal

Alias for RDF::Literal.new.

Parameters:

  • value (Object)
  • language (Symbol)

    (nil) Language is downcased to ensure proper matching

  • lexical (String)

    (nil) Supplied lexical representation of this literal, otherwise it comes from transforming value to a string form..

  • datatype (URI)

    (nil)

  • validate (Boolean)

    (false)

  • canonicalize (Boolean)

    (false)

Returns:



145
146
147
148
149
150
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 145

def self.Literal(literal, **options)
  case literal
    when RDF::Literal then literal
    else Literal.new(literal, **options)
  end
end

.method_missing(property, *args, &block) ⇒ Object

Delegate other methods to RDF::RDFV



267
268
269
270
271
272
273
274
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 267

def self.method_missing(property, *args, &block)
  if args.empty?
    # Special-case rdf:_n for all integers
    RDF_N_REGEXP.match?(property) ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV.send(property)
  else
    super
  end
end

.Node(*args) ⇒ RDF::Node

Alias for RDF::Node.new.

Parameters:

  • id (#to_s)

Returns:



120
121
122
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 120

def self.Node(*args)
  Node.new(*args)
end

.Resource(*args) ⇒ RDF::Resource

Alias for RDF::Resource.new.

Returns:



111
112
113
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 111

def self.Resource(*args)
  Resource.new(*args)
end

.respond_to?(method, include_all = false) ⇒ Boolean

respond to module or RDFV

Returns:

  • (Boolean)


259
260
261
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 259

def self.respond_to?(method, include_all = false)
  super || RDF::RDFV.respond_to?(method, include_all)
end

.StatementRDF::URI .Statement(**options) ⇒ RDF::Statement .Statement(subject, predicate, object, **options) ⇒ RDF::Statement

Overloads:



210
211
212
213
214
215
216
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 210

def self.Statement(*args, **options)
  if args.empty? && options.empty?
    RDF[:Statement]
  else
    Statement.new(*args, **options)
  end
end

.StrictVocabulary(uri) ⇒ Class

Alias for RDF::StrictVocabulary.create.

Parameters:

Returns:

  • (Class)


232
233
234
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 232

def self.StrictVocabulary(uri)
  StrictVocabulary.create(uri)
end

.URI(*args) ⇒ RDF::URI

Cast to a URI. If already a URI, return the passed argument.

Returns:



129
130
131
132
133
134
135
136
137
138
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 129

def self.URI(*args)
  if args.first.respond_to?(:to_uri)
    args.first.to_uri
  elsif args.first.is_a?(Hash)
    URI.new(**args.first)
  else
    opts = args.last.is_a?(Hash) ? args.pop : {}
    URI.new(*args, **opts)
  end
end

.Vocabulary(uri) ⇒ Class

Alias for RDF::Vocabulary.create.

Parameters:

Returns:

  • (Class)


223
224
225
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-8de7b80ab60e/lib/rdf.rb', line 223

def self.Vocabulary(uri)
  Vocabulary.create(uri)
end