assemble_std/specs/
dupe_spec.rs1use assemble_core::file_collection::FileSet;
4use assemble_core::project::VisitProject;
5use assemble_core::utilities::{Spec, Work};
6use assemble_core::Project;
7use std::path::{Path, PathBuf};
8
9pub struct DupeSpec {
12 from: Option<FileSet>,
14 into: Option<PathBuf>,
16 include: Box<dyn Spec<Path>>,
18 exclude: Box<dyn Spec<Path>>,
22 parent: Option<Box<DupeSpec>>,
23}
24
25impl DupeSpec {
26 fn get_from(&self) -> Option<&FileSet> {
27 self.from
28 .as_ref()
29 .or_else(|| self.parent.as_ref().and_then(|p| p.get_from()))
30 }
31
32 fn get_into(&self) -> Option<&Path> {
33 self.into
34 .as_deref()
35 .or_else(|| self.parent.as_ref().and_then(|p| p.get_into()))
36 }
37
38 fn is_included(&self, path: &Path) -> bool {
39 if let Some(parent) = &self.parent {
40 if !parent.is_included(path) {
41 return false;
42 }
43 }
44 self.include.accept(path) && !self.exclude.accept(path)
45 }
46
47 }
51
52impl VisitProject<Work> for DupeSpec {
53 fn visit(&mut self, _project: &Project) -> Work {
54 todo!()
55 }
56}