diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-03-07 17:13:48 +0000 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-03-07 17:13:48 +0000 |
commit | 2f6d5c75fc1fece5fc10cc7c45ad59cf6b820d64 (patch) | |
tree | f3fdad09917e6ba537d049215221545709d721fd /lib/opentox.rb | |
parent | 8fc11578aadcf1e7d152764c926e12e553bd8d65 (diff) |
error and dataset tests added, wait_for_task moved to URI.to_object
Diffstat (limited to 'lib/opentox.rb')
-rw-r--r-- | lib/opentox.rb | 20 |
1 files changed, 11 insertions, 9 deletions
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 |