Module: Ace::Task::Atoms::TaskFrontmatterDefaults

Defined in:
lib/ace/task/atoms/task_frontmatter_defaults.rb

Overview

Builds default frontmatter hash for new tasks matching the task schema.

Constant Summary collapse

VALID_STATUSES =
%w[pending in-progress done blocked draft skipped cancelled].freeze
VALID_PRIORITIES =
%w[critical high medium low].freeze

Class Method Summary collapse

Class Method Details

.build(id:, status: "pending", priority: nil, tags: [], dependencies: [], created_at: nil, parent: nil, estimate: nil, github_issue: nil) ⇒ Hash

Build a frontmatter hash with defaults for missing values.

Parameters:

  • id (String)

    Formatted task ID (required)

  • status (String) (defaults to: "pending")

    Task status (default: “pending”)

  • priority (String, nil) (defaults to: nil)

    Priority level

  • tags (Array<String>) (defaults to: [])

    Tags

  • dependencies (Array<String>) (defaults to: [])

    Dependency task IDs

  • created_at (Time, nil) (defaults to: nil)

    Creation time

  • parent (String, nil) (defaults to: nil)

    Parent task ID for subtasks

Returns:

  • (Hash)

    Frontmatter hash



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ace/task/atoms/task_frontmatter_defaults.rb', line 21

def self.build(
  id:,
  status: "pending",
  priority: nil,
  tags: [],
  dependencies: [],
  created_at: nil,
  parent: nil,
  estimate: nil,
  github_issue: nil
)
  fm = {
    "id" => id,
    "status" => status || "pending",
    "priority" => priority || "medium",
    "created_at" => format_time(created_at)
  }
  fm["estimate"] = estimate
  fm["dependencies"] = dependencies || []
  fm["tags"] = tags || []
  fm["parent"] = parent if parent
  fm["github_issue"] = github_issue if github_issue
  fm
end

.format_time(time) ⇒ String?

Format time for frontmatter

Parameters:

  • time (Time, nil)

Returns:

  • (String, nil)


49
50
51
52
53
# File 'lib/ace/task/atoms/task_frontmatter_defaults.rb', line 49

def self.format_time(time)
  return nil unless time

  time.strftime("%Y-%m-%d %H:%M:%S")
end