diff options
author | Christoph Helma <helma@in-silico.de> | 2009-10-06 10:26:01 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2009-10-06 10:26:01 +0200 |
commit | 352124655e3a5abd1bea607179f520ed2e2db772 (patch) | |
tree | c5f943da16932fb908558df2fea16b6d91489073 /lib/task.rb | |
parent | abd0e1ae7b933cbd1c1907dd9e7f1ce1782cf743 (diff) |
Version bump to 0.0.0
Diffstat (limited to 'lib/task.rb')
-rw-r--r-- | lib/task.rb | 55 |
1 files changed, 55 insertions, 0 deletions
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 |