Class: Ace::Task::Molecules::TaskLoader
- Inherits:
-
Object
- Object
- Ace::Task::Molecules::TaskLoader
- Defined in:
- lib/ace/task/molecules/task_loader.rb
Overview
Loads a single task from its directory. Parses the spec file frontmatter and content into a Task model. Detects subtasks from folder co-location.
Instance Method Summary collapse
-
#load(dir_path, id:, special_folder: nil, load_subtasks: true) ⇒ Models::Task
Load a task from a directory.
Instance Method Details
#load(dir_path, id:, special_folder: nil, load_subtasks: true) ⇒ Models::Task
Load a task from a directory
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ace/task/molecules/task_loader.rb', line 21 def load(dir_path, id:, special_folder: nil, load_subtasks: true) spec_files = Dir.glob(File.join(dir_path, "*.s.md")) return nil if spec_files.empty? # Find primary spec file matching the folder ID spec_file = find_primary_spec(spec_files, id) || spec_files.first content = File.read(spec_file) # Parse frontmatter frontmatter, body = Ace::Support::Items::Atoms::FrontmatterParser.parse(content) # Extract title from body title = Ace::Support::Items::Atoms::TitleExtractor.extract(body) || frontmatter["title"] || File.basename(dir_path) # Decode creation time from raw b36ts created_at = decode_created_at(id) # Detect parent_id from frontmatter parent_id = frontmatter["parent"] # Load subtasks from co-located directories subtasks = if load_subtasks && !parent_id load_subtask_dirs(dir_path, id, special_folder) else [] end Models::Task.new( id: id, status: frontmatter["status"] || "pending", title: title, priority: frontmatter["priority"] || "medium", estimate: frontmatter["estimate"], dependencies: Array(frontmatter["dependencies"]), tags: Array(frontmatter["tags"]), content: body, path: dir_path, file_path: spec_file, special_folder: special_folder, created_at: created_at, subtasks: subtasks, parent_id: parent_id, metadata: frontmatter ) end |