diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-07-18 16:27:44 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-07-18 16:27:44 +0200 |
commit | 690f6f481f8da0ddce3785417d0b995c3c3c82e0 (patch) | |
tree | 52534dcbf143032e8f24efa13b6386cb894d62fd | |
parent | f4dcbc6822cd0bc7018a7ed55256cd2063978e72 (diff) |
dataset-large tests pass
-rw-r--r-- | lib/4store.rb | 18 | ||||
-rw-r--r-- | lib/opentox-server.rb | 2 | ||||
-rw-r--r-- | opentox-server.gemspec | 4 |
3 files changed, 13 insertions, 11 deletions
diff --git a/lib/4store.rb b/lib/4store.rb index 43e41c8..cbce7bb 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -29,14 +29,22 @@ module OpenTox bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type or mime_type == "multipart/form-data" bad_request_error "Reqest body empty." unless rdf mime_type = "application/x-turtle" if mime_type == "text/plain" # ntriples is turtle in 4store - RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf, :graph => uri, "mime-type" => mime_type + begin + RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf, :graph => uri, "mime-type" => mime_type + rescue + rest_call_error $!.message, File.join(four_store_uri,"data")+"/" + end end def self.put uri, rdf, mime_type bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type bad_request_error "Reqest body empty." unless rdf mime_type = "application/x-turtle" if mime_type == "text/plain" - RestClient.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type + begin + RestClient.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type + rescue + rest_call_error $!.message, File.join(four_store_uri,"data",uri) + end end def self.delete uri @@ -49,9 +57,6 @@ module OpenTox def self.query sparql, mime_type if sparql =~ /SELECT/i -# return RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => mime_type).body.gsub(/<|>/,'').split("\n") if mime_type == 'application/sparql-results+xml' -# list = RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => "text/plain").body.gsub(/<|>/,'').split("\n") -# list.shift # return list unless mime_type case mime_type when 'application/sparql-results+xml' @@ -75,6 +80,7 @@ module OpenTox end prefixes = {:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"} ['OT', 'DC', 'XSD', 'OLO'].each{|p| prefixes[p.downcase.to_sym] = eval("RDF::#{p}.to_s") } + # TODO: fails for large datasets?? multi_cell_call turtle = RDF::N3::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer| rdf.each{|statement| writer << statement} end @@ -85,6 +91,8 @@ module OpenTox # TODO: check if this prevents SPARQL injections bad_request_error "Only SELECT and CONSTRUCT are accepted SPARQL statements." end + rescue + rest_call_error $!.message, sparql_uri end def self.klass diff --git a/lib/opentox-server.rb b/lib/opentox-server.rb index 3f04acc..afcce4b 100644 --- a/lib/opentox-server.rb +++ b/lib/opentox-server.rb @@ -2,8 +2,6 @@ require 'opentox-client' require 'rack' require 'rack/contrib' require 'sinatra' -require 'roo' -#require File.join(File.dirname(__FILE__),"environment.rb") require File.join(File.dirname(__FILE__),"4store.rb") require File.join(File.dirname(__FILE__),"opentox.rb") require File.join(File.dirname(__FILE__),"authorization-helper.rb") diff --git a/opentox-server.gemspec b/opentox-server.gemspec index 8628c5e..cc9d160 100644 --- a/opentox-server.gemspec +++ b/opentox-server.gemspec @@ -14,8 +14,6 @@ Gem::Specification.new do |s| s.rubyforge_project = "opentox-server" s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] # specify any dependencies here; for example: @@ -24,7 +22,5 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rack-contrib' s.add_runtime_dependency 'sinatra' s.add_runtime_dependency 'sinatra-contrib' - s.add_runtime_dependency 'roo' - s.add_runtime_dependency 'spreadsheet', "= 0.6.8" # cannot load 0.7.0 s.add_runtime_dependency 'unicorn' end |