Module: RDF

Included in:
LinkedData, SPARQL::Algebra
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/extensions.rb,
lib/rdf/distiller.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/json-ld-f1de87658826/lib/json/ld/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/cli.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/format.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/nquads.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/reader.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/writer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/version.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/ntriples.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/changeset.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/uri.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/file.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/uuid.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocab/owl.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocab/xsd.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/list.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/node.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/term.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/repository.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/cache.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocab/rdfs.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocab/rdfv.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocabulary.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/graph.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/value.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/transaction.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/logger.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/vocab/writer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/durable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/mutable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/dataset.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/pattern.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/aliasing.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/readable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/writable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/resource.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/util/coercions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/countable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/indexable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/queryable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/statement.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/solutions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/enumerable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/type_check.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/mixin/transactable.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/date.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/time.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/token.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/double.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/boolean.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/decimal.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/integer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/numeric.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/datetime.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/model/literal/temporal.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-aggregate-repo-cb93fb3485bc/lib/rdf/aggregate_repo.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-aggregate-repo-cb93fb3485bc/lib/rdf/aggregate_repo/merge_graph.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-hamster-repo-e3a57a812406/lib/rdf/hamster_repo.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-isomorphic-6add041cd0be/lib/rdf/isomorphic.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-json-7d579de01769/lib/rdf/json/version.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-microdata-73e8bfd8e661/lib/rdf/microdata.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-microdata-73e8bfd8e661/lib/rdf/microdata/vocab.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-ordered-repo-fad0f6c1f768/lib/rdf/ordered_repo.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/vocab.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/lib/rdf/rdfxml.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-reasoner-e77a80426b61/lib/rdf/reasoner.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-reasoner-e77a80426b61/lib/rdf/reasoner/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-spec-4f36efa2dbbc/lib/rdf/spec.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-spec-4f36efa2dbbc/lib/rdf/spec/version.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-spec-4f36efa2dbbc/lib/rdf/spec/matchers.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-trig-ccb51eff7022/lib/rdf/trig.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-trix-4b113f65db0e/lib/rdf/trix.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-turtle-6506e92ccd8e/lib/rdf/turtle.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-vocab-27503bb35c2b/lib/rdf/vocab.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-vocab-27503bb35c2b/lib/rdf/vocab/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/xml.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/date.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/binary.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/double.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/any_uri.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/integer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/duration.rb

Overview

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

Defined Under Namespace

Modules: Canonicalize, 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, HamsterRepo, 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"))

Class Method Summary collapse

Class Method Details

.[](property) ⇒ #to_s, URI

Returns:

  • (#to_s)

    property

  • (URI)


235
236
237
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 235

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


98
99
100
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 98

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


243
244
245
246
247
248
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 243

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:



153
154
155
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 153

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:



172
173
174
175
176
177
178
179
180
181
182
183
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 172

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)
  • direction (Symbol)

    (nil) Initial text direction.

  • 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:



141
142
143
144
145
146
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 141

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



263
264
265
266
267
268
269
270
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 263

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:



116
117
118
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 116

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

.Resource(*args) ⇒ RDF::Resource

Alias for RDF::Resource.new.

Returns:



107
108
109
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 107

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

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

respond to module or RDFV

Returns:

  • (Boolean)


255
256
257
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 255

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:



206
207
208
209
210
211
212
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 206

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)


228
229
230
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 228

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:



125
126
127
128
129
130
131
132
133
134
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 125

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)


219
220
221
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf.rb', line 219

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