aboutsummaryrefslogtreecommitdiff
path: root/src/file_handler/file_strategies/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_handler/file_strategies/layout.rs')
-rw-r--r--src/file_handler/file_strategies/layout.rs29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/file_handler/file_strategies/layout.rs b/src/file_handler/file_strategies/layout.rs
index 41acde1..8d9689c 100644
--- a/src/file_handler/file_strategies/layout.rs
+++ b/src/file_handler/file_strategies/layout.rs
@@ -1,12 +1,12 @@
pub struct Strategy {}
-use std::path::PathBuf;
+use std::path::Path;
-use crate::file_handler::{File, FileType, FileHandlerStrategy};
+use crate::file_handler::{File, FileHandlerStrategy, FileType};
impl FileHandlerStrategy for Strategy {
- fn is(&self, path: &PathBuf) -> bool {
- return !path.is_dir() && path.ends_with("_layout.html");
+ fn is(&self, path: &Path) -> bool {
+ !path.is_dir() && path.ends_with("_layout.html")
}
fn identify(&self) -> FileType {
@@ -14,21 +14,19 @@ impl FileHandlerStrategy for Strategy {
}
fn can_handle(&self, file_type: &FileType) -> bool {
- match file_type {
- FileType::Layout => true,
- _ => false,
- }
+ matches!(file_type, FileType::Layout)
}
// We don't implement handling for layout, as we assume there's only one
// and it got handled before.
- fn handle_html(&self, _s: &PathBuf, _d: &PathBuf, _f: &File, _l: &str) {}
- fn handle_gemini(&self, _s: &PathBuf, _d: &PathBuf, _f: &File) {}
+ fn handle_html(&self, _s: &Path, _d: &Path, _f: &File, _l: &str) {}
+ fn handle_gemini(&self, _s: &Path, _d: &Path, _f: &File) {}
}
#[cfg(test)]
mod tests {
use std::fs::create_dir_all;
+ use std::path::PathBuf;
use super::*;
@@ -70,8 +68,7 @@ mod tests {
fn rejects_directory_named_layout() {
let test_dir = setup_test_dir();
let layout_dir = test_dir.join("_layout");
- create_dir_all(&layout_dir)
- .expect("Could not create _layout test directory");
+ create_dir_all(&layout_dir).expect("Could not create _layout test directory");
let strategy = Strategy {};
assert!(!strategy.is(&layout_dir));
}
@@ -108,7 +105,7 @@ mod tests {
&PathBuf::from("source"),
&PathBuf::from("dest"),
&file,
- "layout content"
+ "layout content",
);
}
@@ -121,10 +118,6 @@ mod tests {
};
// Should not panic
- strategy.handle_gemini(
- &PathBuf::from("source"),
- &PathBuf::from("dest"),
- &file
- );
+ strategy.handle_gemini(&PathBuf::from("source"), &PathBuf::from("dest"), &file);
}
}