Module: TaskwarriorWeb::CommandBuilder::V1

Includes:
Base
Defined in:
lib/taskwarrior-web/services/builder/v1.rb

Constant Summary

Constants included from Base

Base::TASK_COMMANDS

Instance Method Summary collapse

Methods included from Base

#parse_params, #task_command

Instance Method Details

#assign_id_from_uuidObject



26
27
28
29
# File 'lib/taskwarrior-web/services/builder/v1.rb', line 26

def assign_id_from_uuid
  @all_tasks ||= TaskwarriorWeb::Task.query('status.not' => [:deleted, :completed])
  @id = @all_tasks.index { |task| task.uuid == @id } + 1
end

#buildObject



5
6
7
8
9
10
11
12
# File 'lib/taskwarrior-web/services/builder/v1.rb', line 5

def build
  unless @command_string
    task_command
    substitute_parts if @command_string =~ /:id/
  end
  parse_params
  @built = "#{self.command_string}#{params}"
end

#substitute_partsObject

Overridden from TaskwarriorWeb::CommandBuilder::Base

Substitute the task’s ID for its UUID.



17
18
19
20
21
22
23
24
# File 'lib/taskwarrior-web/services/builder/v1.rb', line 17

def substitute_parts
  if @id
    assign_id_from_uuid
    @command_string.gsub!(':id', @id.to_s)
    return self
  end
  raise TaskwarriorWeb::CommandBuilder::MissingTaskIDError
end