Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gk-master
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Sep 4, 2012
2 parents 26352d5 + 8135790 commit 7060471
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 18 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
@@ -0,0 +1,13 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- ree
- 1.8.7
- 1.9.3
- jruby-18mode # JRuby in 1.8 mode
- jruby-19mode # JRuby in 1.9 mode
- rbx-18mode
- rbx-19mode
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -2,6 +2,6 @@ source "http://rubygems.org"

gemspec :name => ""

group :development do
group :debug do
gem "wirble"
end
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rdf-microdata (0.2.4)
rdf-microdata (0.2.5)
htmlentities (>= 4.3.0)
json (>= 1.6.1)
rdf (>= 0.3.4)
Expand Down
9 changes: 9 additions & 0 deletions History.md
@@ -1,3 +1,12 @@
### 0.2.5
* If RDFa is loaded, don't assert text/html and :html content-type/extension, as RDFa will call out based on presence of @itemscope

### 0.2.4
* Update contextual case based on LC spec change to use current_name instead of current_type when creating a predicate URI in contextual.
* Add hCard and hCalendar vocabulary definitions.
* Make sure registry_uri is processed for each invocation, allowing it to be passed as a parameter.
* Add --registry argument to script/parse to allow it to be specified.

### 0.2.3
* Update to latest processing rules, including the use of a registry.
* Updated microdata namespace.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -28,7 +28,9 @@ The parser uses a build-in version of the [Microdata RDF][] registry.

## Note
This spec is based on the W3C HTML Data Task Force specification and does not support
GRDDL-type triple generation, such as for html>head>title and <a>
GRDDL-type triple generation, such as for html>head>title anchor tags.

If the `RDFa` parser is available, {RDF::Microdata::Format} will not assert content type `text/html` or file extension `.html`, as this is also asserted by RDFa. Instead, the RDFa reader will invoke the microdata reader if an `@itemscope` attribute is detected.

## Dependencies
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.4)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.2.4
0.2.5
6 changes: 5 additions & 1 deletion lib/rdf/microdata/format.rb
Expand Up @@ -15,7 +15,11 @@ module RDF::Microdata
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
class Format < RDF::Format
content_encoding 'utf-8'
content_type 'text/html', :extension => :html

# Only define content type if RDFa is not available.
# The Microdata processor will be launched from there
# otherwise.
content_type 'text/html', :extension => :html unless RDF::Format.for(:rdfa)
reader { RDF::Microdata::Reader }

##
Expand Down
19 changes: 10 additions & 9 deletions lib/rdf/microdata/reader.rb
Expand Up @@ -81,7 +81,8 @@ def initialize(prefixURI, propertyURI = :vocabulary, multipleValues = :unordered
@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
Expand Down Expand Up @@ -283,8 +284,8 @@ def node_path(node)

# 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
Expand All @@ -300,12 +301,12 @@ def add_error(node, message)

# 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)}"}
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/microdata/reader/nokogiri.rb
Expand Up @@ -141,15 +141,15 @@ def shift

##
# Add NodeSetProxys
# @param [NodeSetProxy, Nokogiri::XML::Node]
# @param [NodeSetProxy, Nokogiri::XML::Node] other
# @return [NodeSetProxy]
def +(other)
NodeSetProxy.new(self.node_set + other.node_set, parent)
end

##
# Add a NodeProxy
# @param [NodeProxy, Nokogiri::XML::Node]
# @param [NodeProxy, Nokogiri::XML::Node] elem
# @return [NodeSetProxy]
def <<(elem)
node_set << (elem.is_a?(NodeProxy) ? elem.node : elem)
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/microdata/reader/rexml.rb
Expand Up @@ -179,7 +179,7 @@ def shift

##
# Add NodeSetProxys
# @param [NodeSetProxy, Nokogiri::XML::Node]
# @param [NodeSetProxy, Nokogiri::XML::Node] other
# @return [NodeSetProxy]
def +(other)
new_ns = node_set.clone
Expand All @@ -189,7 +189,7 @@ def +(other)

##
# Add a NodeProxy
# @param [NodeProxy, Nokogiri::XML::Node]
# @param [NodeProxy, Nokogiri::XML::Node] elem
# @return [NodeSetProxy]
def <<(elem)
node_set << (elem.is_a?(NodeProxy) ? elem.node : elem)
Expand Down
1 change: 1 addition & 0 deletions spec/test-suite

0 comments on commit 7060471

Please sign in to comment.