| 153 | } |
| 154 | |
| 155 | fn lift_task(d: &Directive, human_key: &str, n: usize) -> Task { |
| 156 | let local = |
| 157 | d.id.clone() |
| 158 | .unwrap_or_else(|| format!("{}-{n}", slug(human_key))); |
| 159 | let mut touches: Vec<String> = Vec::new(); |
| 160 | if let Some(f) = d.attr("touchesFile") { |
| 161 | touches.push(f.to_string()); |
| 162 | } |
| 163 | for child in &d.children { |
| 164 | if child.name == "file-ref" { |
| 165 | if let Some(path) = child.attr("path") { |
| 166 | touches.push(path.to_string()); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | let satisfies = d |
| 171 | .attr("satisfies") |
| 172 | .or_else(|| d.attr("criteria")) |
| 173 | .map(|v| as_urn("ac", v)); |
| 174 | Task { |
| 175 | type_: NodeType::Task.as_str().to_string(), |
| 176 | id: as_urn("task", &local), |
| 177 | text: d.body.clone(), |
| 178 | task_status: d.attr("status").unwrap_or("open").to_string(), |
| 179 | touches_file: touches, |
| 180 | satisfies, |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /// Lift a `:::scope-in` / `:::scope-out` container into a `ScopeItem`. |
| 185 | /// `kind` is "scope-in" or "scope-out" and drives the generated id slug. |