Skip to content

Commit

Permalink
Finish 2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jul 25, 2017
2 parents 8f5ace0 + 7808523 commit d4528b1
Show file tree
Hide file tree
Showing 21 changed files with 263 additions and 204 deletions.
4 changes: 2 additions & 2 deletions lib/rdf/rdfa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module RDFa
autoload :Reader, 'rdf/rdfa/reader'
autoload :Writer, 'rdf/rdfa/writer'
autoload :VERSION, 'rdf/rdfa/version'

HTML_RDFA_CONTEXT = "http://www.w3.org/2011/rdfa-context/html-rdfa-1.1"
XHTML_RDFA_CONTEXT = "http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1"
XML_RDFA_CONTEXT = "http://www.w3.org/2011/rdfa-context/rdfa-1.1"
end
end
end
26 changes: 13 additions & 13 deletions lib/rdf/rdfa/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Context
# @!attribute [r] terms
# @return [Hash{Symbol => RDF::URI}]
attr_reader :terms

# Default URI defined for this vocabulary
# @!attribute [r] vocabulary
# @return [RDF::URI]
Expand All @@ -29,7 +29,7 @@ class Context
# @!attribute [r] uri
# @return [RDF::URI]
attr_reader :uri

##
# Initialize a new context from the given URI.
#
Expand All @@ -46,11 +46,11 @@ def initialize(uri, options = {}, &block)
@terms = options.fetch(:terms, {})
@vocabulary = options[:vocabulary]
@options = options.dup

yield(self) if block_given?
self
end

##
# @return [RDF::Util::Cache]
# @private
Expand All @@ -67,7 +67,7 @@ def self.cache
def self.repository
@repository ||= RDF::Repository.new(title: "RDFa Contexts")
end

##
# Set repository used for saving contexts
# @param [RDF::Repository] repo
Expand All @@ -82,14 +82,14 @@ def self.repository=(repo)
end
@repository = repo
end

# Return a context faulting through the cache
# @return [RDF::RDFa::Context]
def self.find(uri)
uri = RDF::URI.intern(uri)

return cache[uri] unless cache[uri].nil?

# Two part creation to prevent re-entrancy problems if p1 => p2 and p2 => p1
# Return something to make the caller happy if we're re-entered
cache[uri] = Struct.new(:prefixes, :terms, :vocabulary).new({}, {}, nil)
Expand All @@ -112,12 +112,12 @@ 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

# @return [RDF::Repository]
def repository
Context.repository
end

##
# Defines the given named URI prefix for this context.
#
Expand Down Expand Up @@ -151,7 +151,7 @@ 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

##
# Extract vocabulary, prefix mappings and terms from a enumerable object into an instance
#
Expand Down Expand Up @@ -179,14 +179,14 @@ def parse(enumerable)
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.
Expand Down
6 changes: 3 additions & 3 deletions lib/rdf/rdfa/expansion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def antecedent(subject, prediate, object)
def consequent(subject, prediate, object)
consequents << RDF::Query::Pattern.new(subject, prediate, object)
end

##
# Execute the rule against queryable, yielding each consequent with bindings
#
Expand Down Expand Up @@ -227,7 +227,7 @@ def entailment(repository, vocabs)
to_add << statement
end
end

repository.insert(*to_add)
end
end
Expand All @@ -250,7 +250,7 @@ def fold(repository)
to_add << statement
end
end

repository.insert(*to_add)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/rdfa/patches/string_hacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def align_left
ws = str.match(/^(\s*)\S/m) ? $1 : ''
str.gsub(/^#{ws}/m, '')
end
end
end

0 comments on commit d4528b1

Please sign in to comment.