From 011b60270f481bd21eaf982e730067f47aed0726 Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Sun, 21 May 2023 16:22:35 -0500 Subject: [PATCH] added: expansions can now directly call pattern files without definition --- Cargo.lock | 1 - files/test_site/source/unit_tests/expand/file.meta | 1 + src/metafile/dir.rs | 1 - src/metafile/file/patterns.rs | 7 +++++++ src/tests.rs | 6 ++++++ 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 files/test_site/source/unit_tests/expand/file.meta diff --git a/Cargo.lock b/Cargo.lock index a52e12c..00ed6e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -524,7 +524,6 @@ dependencies = [ "pandoc", "pest", "pest_derive", - "rayon", "thiserror", ] diff --git a/files/test_site/source/unit_tests/expand/file.meta b/files/test_site/source/unit_tests/expand/file.meta new file mode 100644 index 0000000..5c0b9fe --- /dev/null +++ b/files/test_site/source/unit_tests/expand/file.meta @@ -0,0 +1 @@ +&{test.good} diff --git a/src/metafile/dir.rs b/src/metafile/dir.rs index b12d8f1..c24654d 100644 --- a/src/metafile/dir.rs +++ b/src/metafile/dir.rs @@ -1,6 +1,5 @@ use crate::{MetaError, Options}; use eyre::Result; -use rayon::prelude::*; use std::{fs, path::PathBuf}; use super::*; diff --git a/src/metafile/file/patterns.rs b/src/metafile/file/patterns.rs index b3a2871..1df5844 100644 --- a/src/metafile/file/patterns.rs +++ b/src/metafile/file/patterns.rs @@ -16,6 +16,13 @@ impl<'a> MetaFile<'a> { Ok(name.to_string()) } else if let Some(name) = self.patterns.get(&Scope::into_global(key)) { Ok(name.to_string()) + } else if self + .opts + .pattern + .join(key.replace(".", "/") + ".meta") + .exists() + { + Ok(String::new()) } else if self.header.panic_default { Err(MetaError::UndefinedDefault { pattern: key.to_string(), diff --git a/src/tests.rs b/src/tests.rs index 6276cfb..7c5174f 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -81,6 +81,12 @@ unit_test!( unit_test!(header_blank, "header/blank", ""); +unit_test!( + pat_file, + "expand/file.meta", + "\n

GOOD

\n\n" +); + #[test] fn test_filetype_header() -> Result<()> { let dir = PathBuf::from("files/test_site").canonicalize()?; -- 2.45.2