From 2f6d5c75fc1fece5fc10cc7c45ad59cf6b820d64 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 7 Mar 2012 17:13:48 +0000 Subject: error and dataset tests added, wait_for_task moved to URI.to_object --- lib/opentox.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/opentox.rb') diff --git a/lib/opentox.rb b/lib/opentox.rb index 566c458..9ba64bd 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -70,8 +70,7 @@ module OpenTox def delete headers={} headers[:subjectid] ||= @subjectid - headers[:accept] ||= 'application/rdf+xml' - @response = RestClientWrapper.delete(@uri.to_s,:subjectid => @subjectid) + @response = RestClientWrapper.delete(@uri.to_s,nil,nil,headers) end # class methods @@ -82,23 +81,26 @@ module OpenTox subjectid ? eval("#{self}.new(\"#{uri}\", #{subjectid})") : eval("#{self}.new(\"#{uri}\")") end - def from_file service_uri, file, subjectid=nil - RestClientWrapper.post(service_uri, :file => File.new(file), :subjectid => subjectid).chomp.to_object + def from_file service_uri, filename, subjectid=nil + file = File.new filename + uri = RestClientWrapper.post(service_uri, {:file => file}, {:subjectid => subjectid, :content_type => file.mime_type, :accept => "text/uri-list"}) + puts uri end def all service_uri, subjectid=nil - uris = RestClientWrapper.get(service_uri, nil, {:accept => 'text/uri-list'}).split("\n").compact + uris = RestClientWrapper.get(service_uri, {}, :accept => 'text/uri-list').split("\n").compact uris.collect{|uri| subjectid ? eval("#{self}.new(\"#{uri}\", #{subjectid})") : eval("#{self}.new(\"#{uri}\")")} end end - # create default classes - SERVICES.each do |s| - eval "class #{s} + # create default OpenTox classes + SERVICES.each do |klass| + c = Class.new do include OpenTox extend OpenTox::ClassMethods - end" + end + OpenTox.const_set klass,c end end -- cgit v1.2.3