Module: Ace::Task::Atoms::TaskFilePattern
- Defined in:
- lib/ace/task/atoms/task_file_pattern.rb
Overview
Glob patterns and matching logic for task spec files. Tasks use ‘.s.md` extension but exclude `.idea.s.md` (ideas). Subtask files are distinguished from primary files by their ID suffix.
Constant Summary collapse
- SPEC_PATTERN =
Pattern matching all spec files
"*.s.md"- IDEA_PATTERN =
Pattern to exclude idea spec files
"*.idea.s.md"- SUBTASK_ID_REGEX =
Subtask ID pattern: parent ID + dot + single char (e.g., “8pp.t.q7w.a”)
/^([0-9a-z]{3}\.[a-z]\.[0-9a-z]{3})\.([a-z0-9])$/
Class Method Summary collapse
-
.extract_id_from_filename(filename) ⇒ String?
Extract the task ID from a spec filename.
-
.primary_file?(filename, folder_id) ⇒ Boolean
Check if a spec file is the primary file for its containing folder.
-
.subtask_file?(filename) ⇒ Boolean
Check if a spec file is a subtask file.
Class Method Details
.extract_id_from_filename(filename) ⇒ String?
Extract the task ID from a spec filename. “8pp.t.q7w-fix-login.s.md” → “8pp.t.q7w” “8pp.t.q7w.a-setup-db.s.md” → “8pp.t.q7w.a”
56 57 58 59 60 61 62 63 64 |
# File 'lib/ace/task/atoms/task_file_pattern.rb', line 56 def self.extract_id_from_filename(filename) # Remove .s.md extension base = filename.sub(/\.s\.md$/, "") return nil if base == filename # No .s.md extension # Match task ID at start: "8pp.t.q7w" or "8pp.t.q7w.a" match = base.match(/^([0-9a-z]{3}\.[a-z]\.[0-9a-z]{3}(?:\.[a-z0-9])?)/) match&.[](1) end |
.primary_file?(filename, folder_id) ⇒ Boolean
Check if a spec file is the primary file for its containing folder. The primary file’s ID prefix matches the folder’s ID prefix exactly. Subtask files have an additional ‘.char` suffix.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ace/task/atoms/task_file_pattern.rb', line 26 def self.primary_file?(filename, folder_id) return false if filename.end_with?(".idea.s.md") # Extract ID from filename: "8pp.t.q7w-fix-login.s.md" → "8pp.t.q7w" # or subtask: "8pp.t.q7w.a-setup-db.s.md" → "8pp.t.q7w.a" file_id = extract_id_from_filename(filename) return false unless file_id file_id == folder_id end |
.subtask_file?(filename) ⇒ Boolean
Check if a spec file is a subtask file.
41 42 43 44 45 46 47 48 |
# File 'lib/ace/task/atoms/task_file_pattern.rb', line 41 def self.subtask_file?(filename) return false if filename.end_with?(".idea.s.md") file_id = extract_id_from_filename(filename) return false unless file_id file_id.match?(SUBTASK_ID_REGEX) end |