Skip to content
Browse files

Update for rdf-spec 0.3.11 because of respec changes.

Fix override of RDF::Util::File.open_file
  • Loading branch information...
1 parent 5ed6645 commit 3672718534d1d00fa4b5c4cfcf9270b592a5cd47 @gkellogg gkellogg committed Dec 1, 2012
Showing with 72 additions and 53 deletions.
  1. +3 −2 .gemspec
  2. +1 −0 Gemfile
  3. +30 −19 Gemfile.lock
  4. +1 −0 lib/rdf/microdata/reader.rb
  5. +1 −1 spec/format_spec.rb
  6. +1 −1 spec/reader_spec.rb
  7. +6 −1 spec/spec_helper.rb
  8. +29 −29 spec/suite_helper.rb
View
5 .gemspec
@@ -35,8 +35,9 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'rdf-xsd', '>= 0.3.4'
gem.add_runtime_dependency 'htmlentities', '>= 4.3.0'
- gem.add_development_dependency 'nokogiri' , '>= 1.5.0' #unless RUBY_ENGINE == "java"
- gem.add_development_dependency 'equivalent-xml' , '>= 0.2.8' #unless RUBY_ENGINE == "java"
+ gem.add_development_dependency 'nokogiri' , '>= 1.5.0'
+ gem.add_development_dependency 'equivalent-xml' , '>= 0.2.8'
+ gem.add_development_dependency 'open-uri-cached', '>= 0.0.5'
gem.add_development_dependency 'yard' , '>= 0.6.0'
gem.add_development_dependency 'spira', '>= 0.0.12'
gem.add_development_dependency 'rspec', '>= 2.8.0'
View
1 Gemfile
@@ -4,4 +4,5 @@ gemspec :name => ""
group :debug do
gem "wirble"
+ gem "debugger"
end
View
49 Gemfile.lock
@@ -11,53 +11,64 @@ GEM
remote: http://rubygems.org/
specs:
addressable (2.3.2)
+ columnize (0.3.6)
+ debugger (1.2.2)
+ columnize (>= 0.3.1)
+ debugger-linecache (~> 1.1.1)
+ debugger-ruby_core_source (~> 1.1.5)
+ debugger-linecache (1.1.2)
+ debugger-ruby_core_source (>= 1.1.1)
+ debugger-ruby_core_source (1.1.5)
diff-lcs (1.1.3)
- equivalent-xml (0.2.9)
+ equivalent-xml (0.3.0)
nokogiri (>= 1.4.3)
haml (3.1.7)
htmlentities (4.3.1)
json (1.7.5)
json (1.7.5-java)
nokogiri (1.5.5)
nokogiri (1.5.5-java)
+ open-uri-cached (0.0.5)
promise (0.3.0)
- rdf (0.3.8)
+ rdf (0.3.11)
addressable (>= 2.2.6)
rdf-isomorphic (0.3.4)
rdf (>= 0.2.3)
- rdf-rdfa (0.3.15)
- haml (>= 3.1.6)
- htmlentities (>= 4.3.0)
- rdf (>= 0.3.5)
- rdf-xsd (>= 0.3.7)
- rdf-spec (0.3.8)
- rspec (>= 2.8.0)
- rdf-turtle (0.1.2)
- rdf (>= 0.3.4)
+ rdf-rdfa (0.3.16)
+ haml (>= 3.1.7)
+ htmlentities (>= 4.3.1)
+ rdf (>= 0.3.11)
+ rdf-xsd (>= 0.3.8)
+ rdf-spec (0.3.11)
+ rspec (>= 2.12.0)
+ rdf-turtle (0.3.2)
+ rdf (>= 0.3.11)
rdf-xsd (0.3.8)
rdf (>= 0.3.4)
- rspec (2.11.0)
- rspec-core (~> 2.11.0)
- rspec-expectations (~> 2.11.0)
- rspec-mocks (~> 2.11.0)
- rspec-core (2.11.1)
- rspec-expectations (2.11.3)
+ rspec (2.12.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rspec-core (2.12.1)
+ rspec-expectations (2.12.0)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.2)
+ rspec-mocks (2.12.0)
spira (0.0.12)
promise (>= 0.3.0)
rdf (>= 0.2.3)
rdf-isomorphic (>= 0.3.0)
wirble (0.1.3)
- yard (0.8.2.1)
+ yard (0.8.3)
PLATFORMS
java
ruby
DEPENDENCIES
+ debugger
equivalent-xml (>= 0.2.8)
nokogiri (>= 1.5.0)
+ open-uri-cached (>= 0.0.5)
rdf-isomorphic (>= 0.3.4)
rdf-microdata!
rdf-rdfa (>= 0.3.15)
View
1 lib/rdf/microdata/reader.rb
@@ -439,6 +439,7 @@ def generate_triples(item, ec = {})
# 7) If the registry contains a URI prefix that is a character for character match of type up to the length of the URI prefix, set vocab as that URI prefix and generate the following triple (unless it has already been generated):
vocab = Registry.find(type)
+ add_debug(item) {"gentrips(7): vocab=#{vocab.inspect}"}
add_triple(item, base_uri, USES_VOCAB, RDF::URI(vocab.uri)) if vocab
# 8) Otherwise, if type is not empty, construct vocab by removing everything following the last
View
2 spec/format_spec.rb
@@ -8,7 +8,7 @@
@format_class = RDF::Microdata::Format
end
- it_should_behave_like RDF_Format
+ include RDF_Format
describe ".for" do
formats = [
View
2 spec/reader_spec.rb
@@ -8,7 +8,7 @@
@reader = RDF::Microdata::Reader.new(StringIO.new(""))
end
- it_should_behave_like RDF_Reader
+ include RDF_Reader
describe ".for" do
formats = [
View
7 spec/spec_helper.rb
@@ -6,9 +6,14 @@
require 'rdf/isomorphic'
require 'rdf/microdata'
require 'rdf/turtle'
-#require 'rdf/spec'
require 'rdf/spec/matchers'
require 'matchers'
+require 'open-uri/cached'
+
+# Create and maintain a cache of downloaded URIs
+URI_CACHE = File.expand_path(File.join(File.dirname(__FILE__), "uri-cache"))
+Dir.mkdir(URI_CACHE) unless File.directory?(URI_CACHE)
+OpenURI::Cache.class_eval { @cache_path = URI_CACHE }
::RSpec.configure do |c|
c.filter_run :focus => true
View
58 spec/suite_helper.rb
@@ -20,48 +20,48 @@ module File
# @return [IO] File stream
# @yield [IO] File stream
def self.open_file(filename_or_url, options = {}, &block)
- #puts "open #{filename_or_url}"
- f = case filename_or_url.to_s
+ 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)
+ Kernel.open(RDF::Microdata::Reader::DEFAULT_REGISTRY, &block)
when /^#{REMOTE_PATH}/
begin
#puts "attempt to open #{filename_or_url} locally"
- #puts " => #{filename_or_url.to_s.sub(REMOTE_PATH, LOCAL_PATH)}"
- response = ::File.open(filename_or_url.to_s.sub(REMOTE_PATH, LOCAL_PATH))
- case filename_or_url.to_s
- when /\.html$/
- def response.content_type; 'text/html'; end
- when /\.ttl$/
- def response.content_type; 'text/turtle'; end
- when /\.json$/
- def response.content_type; 'application/json'; end
- when /\.jsonld$/
- def response.content_type; 'application/ld+json'; end
+ if response = ::File.open(filename_or_url.to_s.sub(REMOTE_PATH, LOCAL_PATH))
+ #puts "use #{filename_or_url} locally"
+ case filename_or_url.to_s
+ when /\.html$/
+ def response.content_type; 'text/html'; end
+ when /\.ttl$/
+ def response.content_type; 'text/turtle'; end
+ when /\.json$/
+ def response.content_type; 'application/json'; end
+ when /\.jsonld$/
+ def response.content_type; 'application/ld+json'; end
+ else
+ def response.content_type; 'unknown'; end
+ end
+
+ if block_given?
+ begin
+ yield response
+ ensure
+ response.close
+ end
+ else
+ response
+ end
else
- def response.content_type; 'unknown'; end
+ Kernel.open(filename_or_url.to_s, &block)
end
- #puts "use #{filename_or_url} locally as #{response.content_type}"
-
- response
rescue Errno::ENOENT
# Not there, don't run tests
- Kernel.open(path.to_s, &block)
- end
- else
- end
-
- if f && block_given?
- begin
- yield f
- ensure
- f.close
+ StringIO.new("")
end
else
- f
+ Kernel.open(filename_or_url.to_s, &block)
end
end
end

0 comments on commit 3672718

Please sign in to comment.
Something went wrong with that request. Please try again.