lib/rdf/microdata/reader.rb in rdf-microdata-0.2.4 vs lib/rdf/microdata/reader.rb in rdf-microdata-0.2.5

- old
+ new

@@ -12,11 +12,11 @@ # An Microdata parser in Ruby # # Based on processing rules, amended with the following: # # @see https://dvcs.w3.org/hg/htmldata/raw-file/0d6b89f5befb/microdata-rdf/index.html - # @author [Gregg Kellogg](http://kellogg-assoc.com/) + # @author [Gregg Kellogg](http://greggkellogg.net/) class Reader < RDF::Reader format Format URL_PROPERTY_ELEMENTS = %w(a area audio embed iframe img link object source track video) DEFAULT_REGISTRY = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "etc", "registry.json")) @@ -79,11 +79,12 @@ @scheme = propertyURI.to_sym @multipleValues = multipleValues.to_sym @properties = properties if @scheme == :vocabulary @property_base = prefixURI.to_s - @property_base += '#' unless %w(/ #).include?(@property_base[-1,1]) # Append a '#' for fragment if necessary + # Append a '#' for fragment if necessary + @property_base += '#' unless %w(/ #).include?(@property_base[-1,1]) else @property_base = 'http://www.w3.org/ns/md?type=' end end @@ -281,12 +282,12 @@ "<#{base_uri}>#{node.respond_to?(:display_path) ? node.display_path : node}" end # Add debug event to debug array, if specified # - # @param [Nokogiri::XML::Node, #to_s] node:: XML Node or string for showing context - # @param [String] message:: + # @param [Nokogiri::XML::Node, #to_s] node XML Node or string for showing context + # @param [String] message # @yieldreturn [String] appended to message, to allow for lazy-evaulation of message def add_debug(node, message = "") return unless ::RDF::Microdata.debug? || @debug message = message + yield if block_given? puts "#{node_path(node)}: #{message}" if ::RDF::Microdata::debug? @@ -298,15 +299,15 @@ raise RDF::ReaderError, message if validate? end # add a statement, object can be literal or URI or bnode # - # @param [Nokogiri::XML::Node, any] node:: XML Node or string for showing context - # @param [URI, BNode] subject:: the subject of the statement - # @param [URI] predicate:: the predicate of the statement - # @param [URI, BNode, Literal] object:: the object of the statement - # @return [Statement]:: Added statement - # @raise [ReaderError]:: Checks parameter types and raises if they are incorrect if parsing mode is _validate_. + # @param [Nokogiri::XML::Node, any] node XML Node or string for showing context + # @param [URI, BNode] subject the subject of the statement + # @param [URI] predicate the predicate of the statement + # @param [URI, BNode, Literal] object the object of the statement + # @return [Statement] Added statement + # @raise [ReaderError] Checks parameter types and raises if they are incorrect if parsing mode is _validate_. def add_triple(node, subject, predicate, object) statement = RDF::Statement.new(subject, predicate, object) add_debug(node) {"statement: #{RDF::NTriples.serialize(statement)}"} @callback.call(statement) end \ No newline at end of file