Class: RDF::RDFa::Context
- Includes:
- Util::Logger
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/xml.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/html.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/xhtml.rb
Overview
This file is automatically generated by ./script/intern_context RDFa context for http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
Constant Summary
Constants included from Util::Logger
Instance Attribute Summary collapse
-
#prefixes ⇒ Hash{Symbol => RDF::URI}
readonly
Prefix mappings defined in this context.
-
#terms ⇒ Hash{Symbol => RDF::URI}
readonly
Term mappings defined in this context.
-
#uri ⇒ RDF::URI
readonly
URI defining this context.
-
#vocabulary ⇒ RDF::URI
readonly
Default URI defined for this vocabulary.
Class Method Summary collapse
- .find_with_html_rdfa_1_1(uri) ⇒ Object
- .find_with_rdfa_1_1(uri) ⇒ Object
- .find_with_xhtml_rdfa_1_1(uri) ⇒ Object (also: find)
-
.load(uri) ⇒ Object
Load context into repository.
-
.repository ⇒ RDF::Repository
Repository used for saving contexts.
-
.repository=(repo) ⇒ RDF::Repository
Set repository used for saving contexts.
Instance Method Summary collapse
-
#initialize(uri, **options) {|context| ... } ⇒ RDF::RDFa::Context
constructor
Initialize a new context from the given URI.
-
#parse(enumerable)
Extract vocabulary, prefix mappings and terms from a enumerable object into an instance.
-
#prefix(name, uri = nil) ⇒ RDF::URI
Defines the given named URI prefix for this context.
- #repository ⇒ RDF::Repository
-
#term(name, uri = nil) ⇒ RDF::URI
Defines the given named URI term for this context.
Methods included from Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
#initialize(uri, **options) {|context| ... } ⇒ RDF::RDFa::Context
Initialize a new context from the given URI.
Parses the context and places it in the repository and cache
43 44 45 46 47 48 49 50 51 52 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 43 def initialize(uri, **, &block) @uri = RDF::URI.intern(uri) @prefixes = .fetch(:prefixes, {}) @terms = .fetch(:terms, {}) @vocabulary = [:vocabulary] @options = .dup yield(self) if block_given? self end |
Instance Attribute Details
#prefixes ⇒ Hash{Symbol => RDF::URI} (readonly)
Prefix mappings defined in this context
16 17 18 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 16 def prefixes @prefixes end |
#terms ⇒ Hash{Symbol => RDF::URI} (readonly)
Term mappings defined in this context
21 22 23 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 21 def terms @terms end |
#uri ⇒ RDF::URI (readonly)
URI defining this context
31 32 33 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 31 def uri @uri end |
#vocabulary ⇒ RDF::URI (readonly)
Default URI defined for this vocabulary
26 27 28 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 26 def vocabulary @vocabulary end |
Class Method Details
.find_with_html_rdfa_1_1(uri) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/html.rb', line 5 def self.find_with_html_rdfa_1_1(uri) if uri.to_s == "http://www.w3.org/2011/rdfa-context/html-rdfa-1.1" @_html_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/html-rdfa-1.1"), ) else find_without_html_rdfa_1_1(uri) end end |
.find_with_rdfa_1_1(uri) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/xml.rb', line 5 def self.find_with_rdfa_1_1(uri) if uri.to_s == "http://www.w3.org/2011/rdfa-context/rdfa-1.1" @_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/rdfa-1.1"), prefixes: { as: "https://www.w3.org/ns/activitystreams#", cc: "http://creativecommons.org/ns#", csvw: "http://www.w3.org/ns/csvw#", ctag: "http://commontag.org/ns#", dc: "http://purl.org/dc/terms/", dc11: "http://purl.org/dc/elements/1.1/", dcat: "http://www.w3.org/ns/dcat#", dcterms: "http://purl.org/dc/terms/", dqv: "http://www.w3.org/ns/dqv#", duv: "https://www.w3.org/ns/duv#", foaf: "http://xmlns.com/foaf/0.1/", gr: "http://purl.org/goodrelations/v1#", grddl: "http://www.w3.org/2003/g/data-view#", ical: "http://www.w3.org/2002/12/cal/icaltzd#", jsonld: "http://www.w3.org/ns/json-ld#", ldp: "http://www.w3.org/ns/ldp#", ma: "http://www.w3.org/ns/ma-ont#", oa: "http://www.w3.org/ns/oa#", odrl: "http://www.w3.org/ns/odrl/2/", og: "http://ogp.me/ns#", org: "http://www.w3.org/ns/org#", owl: "http://www.w3.org/2002/07/owl#", prov: "http://www.w3.org/ns/prov#", qb: "http://purl.org/linked-data/cube#", rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", rdfa: "http://www.w3.org/ns/rdfa#", rdfs: "http://www.w3.org/2000/01/rdf-schema#", rev: "http://purl.org/stuff/rev#", rif: "http://www.w3.org/2007/rif#", rr: "http://www.w3.org/ns/r2rml#", schema: "http://schema.org/", sd: "http://www.w3.org/ns/sparql-service-description#", sioc: "http://rdfs.org/sioc/ns#", skos: "http://www.w3.org/2004/02/skos/core#", skosxl: "http://www.w3.org/2008/05/skos-xl#", sosa: "http://www.w3.org/ns/sosa/", ssn: "http://www.w3.org/ns/ssn/", time: "http://www.w3.org/2006/time#", v: "http://rdf.data-vocabulary.org/#", vcard: "http://www.w3.org/2006/vcard/ns#", void: "http://rdfs.org/ns/void#", wdr: "http://www.w3.org/2007/05/powder#", wdrs: "http://www.w3.org/2007/05/powder-s#", xhv: "http://www.w3.org/1999/xhtml/vocab#", xml: "http://www.w3.org/XML/1998/namespace", xsd: "http://www.w3.org/2001/XMLSchema#", }, terms: { describedby: "http://www.w3.org/2007/05/powder-s#describedby", license: "http://www.w3.org/1999/xhtml/vocab#license", role: "http://www.w3.org/1999/xhtml/vocab#role", }, ) else find_without_rdfa_1_1(uri) end end |
.find_with_xhtml_rdfa_1_1(uri) ⇒ Object Also known as: find
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context/xhtml.rb', line 5 def self.find_with_xhtml_rdfa_1_1(uri) if uri.to_s == "http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1" @_xhtml_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1"), terms: { alternate: "http://www.w3.org/1999/xhtml/vocab#alternate", appendix: "http://www.w3.org/1999/xhtml/vocab#appendix", bookmark: "http://www.w3.org/1999/xhtml/vocab#bookmark", chapter: "http://www.w3.org/1999/xhtml/vocab#chapter", cite: "http://www.w3.org/1999/xhtml/vocab#cite", contents: "http://www.w3.org/1999/xhtml/vocab#contents", copyright: "http://www.w3.org/1999/xhtml/vocab#copyright", first: "http://www.w3.org/1999/xhtml/vocab#first", glossary: "http://www.w3.org/1999/xhtml/vocab#glossary", help: "http://www.w3.org/1999/xhtml/vocab#help", icon: "http://www.w3.org/1999/xhtml/vocab#icon", index: "http://www.w3.org/1999/xhtml/vocab#index", last: "http://www.w3.org/1999/xhtml/vocab#last", license: "http://www.w3.org/1999/xhtml/vocab#license", meta: "http://www.w3.org/1999/xhtml/vocab#meta", next: "http://www.w3.org/1999/xhtml/vocab#next", p3pv1: "http://www.w3.org/1999/xhtml/vocab#p3pv1", prev: "http://www.w3.org/1999/xhtml/vocab#prev", previous: "http://www.w3.org/1999/xhtml/vocab#previous", section: "http://www.w3.org/1999/xhtml/vocab#section", start: "http://www.w3.org/1999/xhtml/vocab#start", stylesheet: "http://www.w3.org/1999/xhtml/vocab#stylesheet", subsection: "http://www.w3.org/1999/xhtml/vocab#subsection", top: "http://www.w3.org/1999/xhtml/vocab#top", up: "http://www.w3.org/1999/xhtml/vocab#up", }, ) else find_without_xhtml_rdfa_1_1(uri) end end |
.load(uri) ⇒ Object
Load context into repository
111 112 113 114 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 111 def self.load(uri) uri = RDF::URI.intern(uri) repository.load(uri.to_s, base_uri: uri, graph_name: uri) unless repository.has_graph?(uri) end |
.repository ⇒ RDF::Repository
Repository used for saving contexts
67 68 69 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 67 def self.repository @repository ||= RDF::Repository.new(title: "RDFa Contexts") end |
.repository=(repo) ⇒ RDF::Repository
Set repository used for saving contexts
75 76 77 78 79 80 81 82 83 84 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 75 def self.repository=(repo) unless repo.supports?(:graph_name) if respond_to?(:log_fatal) log_fatal("Context Repository must support graph_name", exception: ContextError) else abort("Context Repository must support graph_name") end end @repository = repo end |
Instance Method Details
#parse(enumerable)
This method returns an undefined value.
Extract vocabulary, prefix mappings and terms from a enumerable object into an instance
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 160 def parse(enumerable) log_debug("process_context: parse context <#{uri}>") if respond_to?(:log_debug) resource_info = {} enumerable.each do |statement| res = resource_info[statement.subject] ||= {} next unless statement.object.is_a?(RDF::Literal) log_debug("process_context: statement=#{statement.inspect}") if respond_to?(:log_debug) %w(uri term prefix vocabulary).each do |term| res[term] ||= statement.object.value if statement.predicate == RDF::RDFA[term] end end resource_info.values.each do |res| # If one of the objects is not a Literal or if there are additional rdfa:uri or rdfa:term # predicates sharing the same subject, no mapping is created. uri = res["uri"] term = res["term"] prefix = res["prefix"] vocab = res["vocabulary"] log_debug("process_context: uri=#{uri.inspect}, term=#{term.inspect}, prefix=#{prefix.inspect}, vocabulary=#{vocab.inspect}") if respond_to?(:log_debug) @vocabulary = vocab if vocab # For every extracted triple that is the common subject of an rdfa:prefix and an rdfa:uri # predicate, create a mapping from the object literal of the rdfa:prefix predicate to the # object literal of the rdfa:uri predicate. Add or update this mapping in the local list of # URI mappings after transforming the 'prefix' component to lower-case. # For every extracted prefix(prefix.downcase, uri) if uri && prefix && prefix != "_" # triple that is the common subject of an rdfa:term and an rdfa:uri predicate, create a # mapping from the object literal of the rdfa:term predicate to the object literal of the # rdfa:uri predicate. Add or update this mapping in the local term mappings. term(term, uri) if term && uri end end |
#prefix(name, uri = nil) ⇒ RDF::URI
Defines the given named URI prefix for this context.
133 134 135 136 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 133 def prefix(name, uri = nil) name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym) uri.nil? ? prefixes[name] : prefixes[name] = uri end |
#repository ⇒ RDF::Repository
117 118 119 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 117 def repository Context.repository end |
#term(name, uri = nil) ⇒ RDF::URI
Defines the given named URI term for this context.
150 151 152 153 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/context.rb', line 150 def term(name, uri = nil) name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym) uri.nil? ? terms[name] : terms[name] = uri end |