shtola

ssg in rust
git clone https://tilde.team/~marisa/repo/shtola.git
Log | Files | Refs | LICENSE

commit d5b3aa12f550cd7447d3c2a5cdad353546e9a1c7
parent fa3993a989ed97827085072435d3ba1bc95bbc09
Author: marisa <mokou@posteo.de>
Date:   Thu,  7 Nov 2019 16:16:46 +0100

Rename use and add test

Diffstat:
Mshtola/src/lib.rs | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/shtola/src/lib.rs b/shtola/src/lib.rs @@ -37,7 +37,7 @@ impl Shtola { self.ir.config.frontmatter = b; } - pub fn r#use(&mut self, func: Box<dyn Fn(IR) -> IR>) { + pub fn register(&mut self, func: Box<dyn Fn(IR) -> IR>) { self.ware.wrap(func); } @@ -46,7 +46,6 @@ impl Shtola { // read files let result_ir = self.ware.run(self.ir.clone()); // write files - // return ir result_ir } } @@ -73,3 +72,18 @@ pub struct ShFile { frontmatter: HashMap<String, String>, content: Vec<u8>, } + +#[test] +fn it_works() { + let mut s = Shtola::new("./"); + s.source("./"); + s.destination("./dest"); + s.register(Box::new(|mut ir| { + ir.files.insert(PathBuf::from("cool.md"), ShFile { frontmatter: HashMap::new(), content: Vec::new() }); + ir + })); + let r = s.build(); + assert_eq!(r.files.len(), 1); + let keys: Vec<&PathBuf> = r.files.keys().collect(); + assert_eq!(keys[0].to_str().unwrap(), "cool.md"); +}