From 352124655e3a5abd1bea607179f520ed2e2db772 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 6 Oct 2009 10:26:01 +0200 Subject: Version bump to 0.0.0 --- lib/task.rb | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/task.rb (limited to 'lib/task.rb') diff --git a/lib/task.rb b/lib/task.rb new file mode 100644 index 0000000..74c3fb8 --- /dev/null +++ b/lib/task.rb @@ -0,0 +1,55 @@ +module OpenTox + + class Task < OpenTox + #private :new + + def initialize(uri) + super(uri) + end + + def self.create(params) + uri = RestClient.post @@config[:services]["opentox-task"], :resource_uri => params[:resource_uri] + Task.new uri + end + + def self.find(params) + Task.new(params[:uri]) + end + + def self.base_uri + @@config[:services]["opentox-task"] + end + + def start + RestClient.put @uri, :status => 'started' + end + + def stop + RestClient.put @uri, :status => 'stopped' + end + + def completed + RestClient.put @uri, :status => 'completed' + end + + def status + RestClient.get File.join(@uri, 'status') + end + + def completed? + self.status == 'completed' + end + + def resource + RestClient.get @uri + end + + def wait_for_completion + until self.completed? + sleep 1 + end + end + + end + +end -- cgit v1.2.3