Class: Checkoff::Subtasks
- Inherits:
-
Object
- Object
- Checkoff::Subtasks
- Extended by:
- CacheMethod::ClassMethods, Forwardable
- Defined in:
- lib/checkoff/subtasks.rb,
sig/checkoff.rbs
Overview
Query different subtasks of Asana tasks
Constant Summary collapse
Instance Attribute Summary collapse
-
#client ⇒ Asana::Client
readonly
sord warn - Asana::Client wasn't able to be resolved to a constant in this project.
- #projects ⇒ Checkoff::Projects readonly
Instance Method Summary collapse
-
#all_subtasks_completed?(task) ⇒ Boolean
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project True if all subtasks of the task are completed.
-
#by_section(tasks) ⇒ ::Hash[String?, ::Enumerable[Asana::Resources::Task]]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project pulls a Hash of subtasks broken out by section.
-
#file_task_by_section(current_section, by_section, task) ⇒ [String, ::Hash[untyped, untyped]]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project @param
current_section. -
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:)) ⇒ Subtasks
constructor
@param
config. -
#raw_subtasks(task) ⇒ ::Enumerable[Asana::Resources::Task]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project Returns all subtasks, including section headers.
-
#subtask_section?(subtask) ⇒ Boolean
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project True if the subtask passed in represents a section in the subtasks.
-
#subtasks_by_gid(task_gid, extra_fields: [], only_uncompleted: true) ⇒ ::Enumerable[Asana::Resources::Task]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project Pull a specific task by GID.
Constructor Details
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:)) ⇒ Subtasks
@param config
@param projects
@param clients
23 24 25 26 27 28 |
# File 'lib/checkoff/subtasks.rb', line 23 def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:)) @projects = projects @client = clients.client end |
Instance Attribute Details
#client ⇒ Asana::Client (readonly)
sord warn - Asana::Client wasn't able to be resolved to a constant in this project
103 104 105 |
# File 'lib/checkoff/subtasks.rb', line 103 def client @client end |
#projects ⇒ Checkoff::Projects (readonly)
100 101 102 |
# File 'lib/checkoff/subtasks.rb', line 100 def projects @projects end |
Instance Method Details
#all_subtasks_completed?(task) ⇒ Boolean
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project True if all subtasks of the task are completed
@param task
33 34 35 36 37 38 |
# File 'lib/checkoff/subtasks.rb', line 33 def all_subtasks_completed?(task) rs = raw_subtasks(task) active_subtasks = @projects.active_tasks(rs) # anything left should be a section active_subtasks.all? { |subtask| subtask_section?(subtask) } end |
#by_section(tasks) ⇒ ::Hash[String?, ::Enumerable[Asana::Resources::Task]]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project pulls a Hash of subtasks broken out by section
@param tasks
45 46 47 48 49 50 51 52 53 |
# File 'lib/checkoff/subtasks.rb', line 45 def by_section(tasks) current_section = nil by_section = { nil => [] } tasks.each do |task| current_section, by_section = file_task_by_section(current_section, by_section, task) end by_section end |
#file_task_by_section(current_section, by_section, task) ⇒ [String, ::Hash[untyped, untyped]]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project
@param current_section
@param by_section
@param task
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/checkoff/subtasks.rb', line 110 def file_task_by_section(current_section, by_section, task) if subtask_section?(task) current_section = task.name raise "More than one section named #{task.name}" if by_section.key? task.name by_section[current_section] = [] else by_section[current_section] << task end [current_section, by_section] end |
#raw_subtasks(task) ⇒ ::Enumerable[Asana::Resources::Task]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project Returns all subtasks, including section headers
@param task
60 61 62 |
# File 'lib/checkoff/subtasks.rb', line 60 def raw_subtasks(task) subtasks_by_gid(task.gid) end |
#subtask_section?(subtask) ⇒ Boolean
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project True if the subtask passed in represents a section in the subtasks
Note: expect this to be removed in a future version, as Asana is expected to move to the new-style way of representing sections as memberships with a separate API within a task.
@sg-ignore
@param subtask
93 94 95 |
# File 'lib/checkoff/subtasks.rb', line 93 def subtask_section?(subtask) subtask.is_rendered_as_separator end |
#subtasks_by_gid(task_gid, extra_fields: [], only_uncompleted: true) ⇒ ::Enumerable[Asana::Resources::Task]
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project Pull a specific task by GID
@param task_gid
@param extra_fields
@param only_uncompleted
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/checkoff/subtasks.rb', line 72 def subtasks_by_gid(task_gid, extra_fields: [], only_uncompleted: true) # @type [Hash] = projects.(extra_fields: extra_fields + %w[is_rendered_as_separator], only_uncompleted:) = .fetch(:options, {}) client.tasks.get_subtasks_for_task(task_gid:, # per_page: 100, # stub doesn't have this arg available options:) end |