Class: Checkoff::Tasks
- Inherits:
-
Object
- Object
- Checkoff::Tasks
- Defined in:
- lib/checkoff/tasks.rb
Overview
Pull things from ‘my tasks’ in Asana
Constant Summary collapse
- MINUTE =
60- HOUR =
MINUTE * 60
- DAY =
24 * HOUR
- REALLY_LONG_CACHE_TIME =
HOUR- LONG_CACHE_TIME =
MINUTE * 15
- SHORT_CACHE_TIME =
MINUTE * 5
Instance Method Summary collapse
- #add_task(name, workspace_id: default_workspace_id, assignee_id: default_assignee_id) ⇒ Object
- #client ⇒ Object
- #default_assignee_id ⇒ Object
-
#initialize(config: Checkoff::ConfigLoader.load(:asana), sections: Checkoff::Sections.new, asana_task: Asana::Resources::Task) ⇒ Tasks
constructor
A new instance of Tasks.
- #projects ⇒ Object
- #task(workspace_name, project_name, task_name, only_uncompleted: true) ⇒ Object
- #tasks_minus_sections(tasks) ⇒ Object
Constructor Details
#initialize(config: Checkoff::ConfigLoader.load(:asana), sections: Checkoff::Sections.new, asana_task: Asana::Resources::Task) ⇒ Tasks
Returns a new instance of Tasks.
17 18 19 20 21 22 23 |
# File 'lib/checkoff/tasks.rb', line 17 def initialize(config: Checkoff::ConfigLoader.load(:asana), sections: Checkoff::Sections.new, asana_task: Asana::Resources::Task) @config = config @sections = sections @asana_task = asana_task end |
Instance Method Details
#add_task(name, workspace_id: default_workspace_id, assignee_id: default_assignee_id) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/checkoff/tasks.rb', line 44 def add_task(name, workspace_id: default_workspace_id, assignee_id: default_assignee_id) @asana_task.create(client, assignee: assignee_id, workspace: workspace_id, name: name) end |
#client ⇒ Object
25 26 27 |
# File 'lib/checkoff/tasks.rb', line 25 def client @sections.client end |
#default_assignee_id ⇒ Object
52 53 54 |
# File 'lib/checkoff/tasks.rb', line 52 def default_assignee_id @config[:default_assignee_id] end |
#projects ⇒ Object
29 30 31 |
# File 'lib/checkoff/tasks.rb', line 29 def projects @projects ||= @sections.projects end |
#task(workspace_name, project_name, task_name, only_uncompleted: true) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/checkoff/tasks.rb', line 33 def task(workspace_name, project_name, task_name, only_uncompleted: true) project = projects.project(workspace_name, project_name) tasks = projects.tasks_from_project(project, only_uncompleted: only_uncompleted) tasks.find { |task| task.name == task_name } end |
#tasks_minus_sections(tasks) ⇒ Object
40 41 42 |
# File 'lib/checkoff/tasks.rb', line 40 def tasks_minus_sections(tasks) @sections.by_section(tasks).values.flatten end |