From ab93b3c9b40b060f632ce8015eb4630184cd4fe6 Mon Sep 17 00:00:00 2001 From: adamjreilly Date: Wed, 20 Aug 2014 10:03:13 -0400 Subject: [PATCH] Task retrieval Adds support for pulling tasks back, either directly from the client via --- lib/ruby-box.rb | 1 + lib/ruby-box/client.rb | 5 +++++ lib/ruby-box/comment.rb | 2 +- lib/ruby-box/file.rb | 1 + lib/ruby-box/task.rb | 21 +++++++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/ruby-box/task.rb diff --git a/lib/ruby-box.rb b/lib/ruby-box.rb index 22cd556..b629b46 100644 --- a/lib/ruby-box.rb +++ b/lib/ruby-box.rb @@ -6,6 +6,7 @@ require 'ruby-box/folder' require 'ruby-box/user' require 'ruby-box/comment' +require 'ruby-box/task' require 'ruby-box/collaboration' require 'ruby-box/discussion' require 'ruby-box/exceptions' diff --git a/lib/ruby-box/client.rb b/lib/ruby-box/client.rb index 22a66e8..88f1891 100644 --- a/lib/ruby-box/client.rb +++ b/lib/ruby-box/client.rb @@ -31,6 +31,11 @@ def file_by_id(id) file.reload_meta end + def task_by_id(id) + task = Task.new(@session, {'id' => id}) + task.reload_meta + end + def file(path) path = split_path( path.sub(/^\.\//, '') ) file_name = path.pop diff --git a/lib/ruby-box/comment.rb b/lib/ruby-box/comment.rb index ce6e594..c4edc1c 100644 --- a/lib/ruby-box/comment.rb +++ b/lib/ruby-box/comment.rb @@ -11,4 +11,4 @@ def has_mini_format? true end end -end \ No newline at end of file +end diff --git a/lib/ruby-box/file.rb b/lib/ruby-box/file.rb index 9344f96..3ef9f9b 100644 --- a/lib/ruby-box/file.rb +++ b/lib/ruby-box/file.rb @@ -2,6 +2,7 @@ module RubyBox class File < Item has_many :comments + has_many :tasks def download resp = stream.read diff --git a/lib/ruby-box/task.rb b/lib/ruby-box/task.rb new file mode 100644 index 0000000..b1f4758 --- /dev/null +++ b/lib/ruby-box/task.rb @@ -0,0 +1,21 @@ +module RubyBox + class Task < Item + has_many :task_assignments + + def initialize(session, entry) + super(session, entry) + reload_meta + self + end + + private + + def resource_name + 'tasks' + end + + def has_mini_format? + true + end + end +end