lib/rdf/microdata/reader.rb in rdf-microdata-0.1.0 vs lib/rdf/microdata/reader.rb in rdf-microdata-0.1.1

- old
+ new

@@ -15,10 +15,16 @@ class CrawlFailure < StandardError #:nodoc: end ## + # Returns the base URI determined by this reader. + # + # @attr [RDF::URI] + attr_reader :base_uri + + ## # Initializes the Microdata reader instance. # # @param [Nokogiri::HTML::Document, Nokogiri::XML::Document, IO, File, String] input # the input stream to read # @param [Hash{Symbol => Object}] options @@ -145,11 +151,11 @@ base = base_el.attribute('href').to_s.split('#').first if base_el if (base) # Strip any fragment from base base = base.to_s.split('#').first - base = @options[:base_uri] = uri(base) + base = @base_uri = uri(base) add_debug(base_el, "parse_whole_doc: base='#{base}'") else base = RDF::URI("") end @@ -296,11 +302,11 @@ # 5.2. If type does not contain a U+0023 NUMBER SIGN character (#), then append a # to type. type += '#' unless type.to_s.include?('#') # 5.3. If type does not have a : after its #, append a : to type. type += ':' unless type.to_s.match(/\#:/) # 5.4. If the last character of type is not a :, %20 to type. - type += '%20' unless type.to_s[-1] == ':' + type += '%20' unless type.to_s[-1,1] == ':' # 5.5. Append the fragment-escaped value of fallback name to type. type += fallback_name.to_s.gsub('#', '%23') end add_debug(item, "gentrips(6): type=#{type.inspect}") @@ -329,10 +335,10 @@ predicate = if name_uri.absolute? name_uri elsif !name.include?(':') s = type.to_s - s += '%20' unless s[-1] == ':' + s += '%20' unless s[-1,1] == ':' s += name RDF::MD[s.gsub('#', '%23')] end add_debug(element, "gentrips(6.1.5): predicate=#{predicate}") \ No newline at end of file