Module: RDF

Defined in:
lib/rdf.rb,
lib/rdf/cli.rb,
lib/rdf/util.rb,
lib/rdf/query.rb,
lib/rdf/format.rb,
lib/rdf/nquads.rb,
lib/rdf/reader.rb,
lib/rdf/writer.rb,
lib/rdf/version.rb,
lib/rdf/ntriples.rb,
lib/rdf/changeset.rb,
lib/rdf/model/uri.rb,
lib/rdf/util/file.rb,
lib/rdf/util/uuid.rb,
lib/rdf/vocab/owl.rb,
lib/rdf/vocab/xsd.rb,
lib/rdf/model/list.rb,
lib/rdf/model/node.rb,
lib/rdf/model/term.rb,
lib/rdf/repository.rb,
lib/rdf/util/cache.rb,
lib/rdf/vocab/rdfs.rb,
lib/rdf/vocab/rdfv.rb,
lib/rdf/vocabulary.rb,
lib/rdf/model/graph.rb,
lib/rdf/model/value.rb,
lib/rdf/transaction.rb,
lib/rdf/util/logger.rb,
lib/rdf/vocab/writer.rb,
lib/rdf/mixin/durable.rb,
lib/rdf/mixin/mutable.rb,
lib/rdf/model/dataset.rb,
lib/rdf/model/literal.rb,
lib/rdf/query/pattern.rb,
lib/rdf/util/aliasing.rb,
lib/rdf/mixin/readable.rb,
lib/rdf/mixin/writable.rb,
lib/rdf/model/resource.rb,
lib/rdf/mixin/countable.rb,
lib/rdf/mixin/indexable.rb,
lib/rdf/mixin/queryable.rb,
lib/rdf/model/statement.rb,
lib/rdf/query/solutions.rb,
lib/rdf/mixin/enumerable.rb,
lib/rdf/mixin/enumerator.rb,
lib/rdf/mixin/type_check.rb,
lib/rdf/mixin/transactable.rb,
lib/rdf/model/literal/date.rb,
lib/rdf/model/literal/time.rb,
lib/rdf/model/literal/token.rb,
lib/rdf/model/literal/double.rb,
lib/rdf/model/literal/boolean.rb,
lib/rdf/model/literal/decimal.rb,
lib/rdf/model/literal/integer.rb,
lib/rdf/model/literal/numeric.rb,
lib/rdf/model/literal/datetime.rb,
lib/rdf/query/hash_pattern_normalizer.rb

Defined Under Namespace

Modules: Countable, Durable, Enumerable, Indexable, Mutable, NQuads, NTriples, Queryable, Readable, Resource, Term, Transactable, TypeCheck, Util, VERSION, Value, Writable Classes: CLI, Changeset, Dataset, Format, FormatError, Graph, List, Literal, Node, OWL, Query, RDFS, RDFV, Reader, ReaderError, Repository, Statement, StrictVocabulary, Transaction, URI, Vocabulary, Writer, WriterError, XSD

Constant Summary collapse

VOCABS =
Dir.glob(File.join(File.dirname(__FILE__), 'rdf', 'vocab', '*.rb')).map { |f| File.basename(f)[0...-(File.extname(f).size)].to_sym } rescue []
IRI =

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

URI

Class Method Summary collapse

Class Method Details

.[](property) ⇒ #to_s, URI

Returns:

  • (#to_s)

    property

  • (URI)


205
206
207
# File 'lib/rdf.rb', line 205

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

.const_missing(constant) ⇒ Object

Use const_missing instead of autoload to load most vocabularies so we can provide deprecation messages



61
62
63
64
65
66
67
68
# File 'lib/rdf.rb', line 61

def self.const_missing(constant)
  if VOCABS.include?(constant.to_s.downcase.to_sym)
    require "rdf/vocab/#{constant.to_s.downcase}"
    const_get(constant)
  else
    super
  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:



123
124
125
# File 'lib/rdf.rb', line 123

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:



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/rdf.rb', line 142

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(*args, &block) ⇒ RDF::Literal

Alias for ‘RDF::Literal.new`.

Parameters:

  • value (Object)
  • options (Hash)

    a customizable set of options

Returns:



111
112
113
114
115
116
# File 'lib/rdf.rb', line 111

def self.Literal(*args, &block)
  case literal = args.first
    when RDF::Literal then literal
    else Literal.new(*args, &block)
  end
end

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

Delegate other methods to RDF::RDFV



217
218
219
220
221
222
223
224
# File 'lib/rdf.rb', line 217

def self.method_missing(property, *args, &block)
  if args.empty?
    # Special-case rdf:_n for all integers
    property.to_s =~ %r{_\d+} ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV.send(property)
  else
    super
  end
end

.Node(*args, &block) ⇒ RDF::Node

Alias for ‘RDF::Node.new`.

Parameters:

  • id (#to_s)

Returns:



87
88
89
# File 'lib/rdf.rb', line 87

def self.Node(*args, &block)
  Node.new(*args, &block)
end

.Resource(*args, &block) ⇒ RDF::Resource

Alias for ‘RDF::Resource.new`.

Returns:



78
79
80
# File 'lib/rdf.rb', line 78

def self.Resource(*args, &block)
  Resource.new(*args, &block)
end

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

respond to module or RDFV

Returns:

  • (Boolean)


211
212
213
# File 'lib/rdf.rb', line 211

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:



176
177
178
179
180
181
182
# File 'lib/rdf.rb', line 176

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

.StrictVocabulary(prefix) ⇒ Class

Alias for ‘RDF::StrictVocabulary.create`.

Parameters:

Returns:

  • (Class)


198
199
200
# File 'lib/rdf.rb', line 198

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

.URI(*args, &block) ⇒ RDF::URI

Alias for ‘RDF::URI.new`.

Returns:



96
97
98
99
100
101
102
103
104
# File 'lib/rdf.rb', line 96

def self.URI(*args, &block)
  case uri = args.first
    when RDF::URI then uri
    else case
      when uri.respond_to?(:to_uri) then uri.to_uri
      else URI.new(*args, &block)
    end
  end
end

.Vocabulary(uri) ⇒ Class

Alias for ‘RDF::Vocabulary.create`.

Parameters:

Returns:

  • (Class)


189
190
191
# File 'lib/rdf.rb', line 189

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