module TaskwarriorWeb::CommandBuilder::Base

Constants

TASK_COMMANDS

Public Instance Methods

build() click to toggle source
# File lib/taskwarrior-web/services/builder/base.rb, line 18
def build
  unless @command_string
    task_command
    substitute_parts if @command_string =~ /:id/
  end
  parse_params
  @built = "#{@command_string}#{@params}"
end
parse_params() click to toggle source
# File lib/taskwarrior-web/services/builder/base.rb, line 44
def parse_params
  string = ''
  string << %( #{@params.delete(:description).shellescape}) if @params.has_key?(:description)

  if tags = @params.delete(:tags)
    tag_indicator = TaskwarriorWeb::Config.property('tag.indicator') || '+'
    tags.each { |tag| string << %( #{tag_indicator}#{tag.to_s.shellescape}) }
  end

  if tags = @params.delete(:remove_tags)
    tags.each { |tag| string << %( -#{tag.to_s.shellescape}) } 
  end

  @params.each do |attr, value|
    if @command != :update or attr != :uuid
      if value.respond_to? :each
        value.each { |val| string << %( #{attr.to_s}:\\"#{val.to_s.shellescape}\\") }
      else
        string << %( #{attr.to_s}:\\"#{value.to_s.shellescape}\\")
      end
    end
  end

  @params = string
  return self
end
substitute_parts() click to toggle source
# File lib/taskwarrior-web/services/builder/base.rb, line 36
def substitute_parts
  if @id
    @command_string.gsub!(':id', "uuid:#{@id.to_s}")
    return self
  end
  raise TaskwarriorWeb::CommandBuilder::MissingTaskIDError
end
task_command() click to toggle source
# File lib/taskwarrior-web/services/builder/base.rb, line 27
def task_command
  if TASK_COMMANDS[@command.to_sym]
    @command_string = TASK_COMMANDS[@command.to_sym].clone
    return self
  else
    raise TaskwarriorWeb::CommandBuilder::InvalidCommandError
  end
end