Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update suite test formats.

  • Loading branch information...
commit 379c17ecbf4ec0ac7f38acda72d6c8084d193395 1 parent 8757e7e
Gregg Kellogg gkellogg authored
2  Gemfile.lock
View
@@ -35,7 +35,7 @@ GEM
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
- rspec-expectations (2.11.2)
+ rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)
spira (0.0.12)
11 etc/registry.json
View
@@ -3,21 +3,32 @@
"propertyURI": "vocabulary",
"multipleValues": "unordered",
"properties": {
+ "additionalType": {"subPropertyOf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},
+ "blogPosts": {"multipleValues": "list"},
"blogPosts": {"multipleValues": "list"},
"breadcrumb": {"multipleValues": "list"},
"byArtist": {"multipleValues": "list"},
"creator": {"multipleValues": "list"},
+ "episode": {"multipleValues": "list"},
"episodes": {"multipleValues": "list"},
+ "event": {"multipleValues": "list"},
"events": {"multipleValues": "list"},
+ "founder": {"multipleValues": "list"},
"founders": {"multipleValues": "list"},
"itemListElement": {"multipleValues": "list"},
"musicGroupMember": {"multipleValues": "list"},
"performerIn": {"multipleValues": "list"},
+ "actor": {"multipleValues": "list"},
+ "actors": {"multipleValues": "list"},
+ "performer": {"multipleValues": "list"},
"performers": {"multipleValues": "list"},
"producer": {"multipleValues": "list"},
"recipeInstructions": {"multipleValues": "list"},
+ "season": {"multipleValues": "list"},
"seasons": {"multipleValues": "list"},
+ "subEvent": {"multipleValues": "list"},
"subEvents": {"multipleValues": "list"},
+ "track": {"multipleValues": "list"},
"tracks": {"multipleValues": "list"}
}
},
4 lib/rdf/microdata/reader.rb
View
@@ -50,7 +50,7 @@ def self.load_registry(registry_uri)
return if @registry_uri == registry_uri
json = RDF::Util::File.open_file(registry_uri) { |f| JSON.load(f) }
-
+
@prefixes = {}
json.each do |prefix, elements|
next unless elements.is_a?(Hash)
@@ -227,6 +227,7 @@ def initialize(input = $stdin, options = {}, &block)
# Load registry
begin
registry_uri = options[:registry_uri] || DEFAULT_REGISTRY
+ add_debug(@doc, "registry = #{registry_uri}")
Registry.load_registry(registry_uri)
rescue JSON::ParserError => e
raise RDF::ReaderError, "Failed to parse registry: #{e.message}"
@@ -458,6 +459,7 @@ def generatePropertyValues(element, subject, predicate, values)
# If the registry contains a URI prefix that is a character for character match of predicate up to the length
# of the URI prefix, set vocab as that URI prefix. Otherwise set vocab to null
registry = Registry.find(predicate)
+ add_debug("generatePropertyValues") { "list(#{predicate})? #{registry.as_list(predicate).inspect}"} if registry
if registry && registry.as_list(predicate)
value = generateRDFCollection(element, values)
add_triple(element, subject, predicate, value)
40 spec/suite_helper.rb
View
@@ -21,10 +21,12 @@ module File
# @yield [IO] File stream
def self.open_file(filename_or_url, options = {}, &block)
#puts "open #{filename_or_url}"
- case filename_or_url.to_s
+ f = case filename_or_url.to_s
when /^file:/
path = filename_or_url[5..-1]
Kernel.open(path.to_s, &block)
+ when 'http://www.w3.org/ns/md'
+ Kernel.open(RDF::Microdata::Reader::DEFAULT_REGISTRY)
when /^#{REMOTE_PATH}/
begin
#puts "attempt to open #{filename_or_url} locally"
@@ -44,21 +46,23 @@ def response.content_type; 'unknown'; end
end
#puts "use #{filename_or_url} locally as #{response.content_type}"
- if block_given?
- begin
- yield response
- ensure
- response.close
- end
- else
- response
- end
+ response
rescue Errno::ENOENT
# Not there, don't run tests
Kernel.open(path.to_s, &block)
end
else
end
+
+ if block_given?
+ begin
+ yield f
+ ensure
+ f.close
+ end
+ else
+ f
+ end
end
end
end
@@ -99,7 +103,7 @@ def method_missing(method, *args)
def inspect
"<Resource" +
- attributes.dup.keep_if {|k, v| %(@id @type comment).include?(k)}.map do |k, v|
+ attributes.map do |k, v|
"\n #{k}: #{v.inspect}"
end.join(" ") +
">"
@@ -137,18 +141,14 @@ class Entry < JSON::LD::Resource
def data
self.action['data']
end
-
- def query
- self.action['query']
- end
-
+
def registry
- self.action.fetch('registry',
- "http://www.w3.org/TR/microdata-rdf/tests/test-registry.json")
+ property('registry') ||
+ "http://www.w3.org/TR/microdata-rdf/tests/test-registry.json"
end
- def result
- property('result') == 'true'
+ def positiveTest
+ property('positiveTest') == 'true'
end
def trace; @debug.join("\n"); end
4 spec/suite_spec.rb
View
@@ -24,9 +24,9 @@
graph = RDF::Graph.new << reader
#puts "parse #{t.query} as #{RDF::Reader.for(t.query)}"
- output_graph = RDF::Graph.load(t.query, :base_uri => t.data)
+ output_graph = RDF::Graph.load(t.result, :base_uri => t.data)
puts "result: #{CGI.escapeHTML(graph.dump(:ttl))}" if ::RDF::Microdata::debug?
- if t.result
+ if t.positiveTest
graph.should be_equivalent_graph(output_graph, t)
else
graph.should_not be_equivalent_graph(output_graph, t)
23 spec/test-files/test-registry.json
View
@@ -36,28 +36,5 @@
"list": {"multipleValues": "list"},
"typed": {"datatype": "http://typed"}
}
- },
- "http://schema.org/": {
- "propertyURI": "vocabulary",
- "multipleValues": "unordered",
- "properties": {
- "additionalType": {"subPropertyOf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},
- "blogPosts": {"multipleValues": "list"},
- "breadcrumb": {"multipleValues": "list"},
- "byArtist": {"multipleValues": "list"},
- "creator": {"multipleValues": "list"},
- "episodes": {"multipleValues": "list"},
- "events": {"multipleValues": "list"},
- "founders": {"multipleValues": "list"},
- "itemListElement": {"multipleValues": "list"},
- "musicGroupMember": {"multipleValues": "list"},
- "performerIn": {"multipleValues": "list"},
- "performers": {"multipleValues": "list"},
- "producer": {"multipleValues": "list"},
- "recipeInstructions": {"multipleValues": "list"},
- "seasons": {"multipleValues": "list"},
- "subEvents": {"multipleValues": "list"},
- "tracks": {"multipleValues": "list"}
- }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.