diff --git a/src/model/markers/found.rs b/src/model/markers/found.rs deleted file mode 100644 index 051c5ca..0000000 --- a/src/model/markers/found.rs +++ /dev/null @@ -1,22 +0,0 @@ -use super::Marker; - -// -#[derive(Debug, Default)] -pub struct FoundMarkers { - markers: Vec, -} -impl FoundMarkers { - pub fn add_marker(&mut self, marker: Marker) { - self.markers.push(marker); - } -} -impl std::fmt::Display for FoundMarkers { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - for marker in self.markers.iter() { - // if !matches!(marker, Marker::Unmarked) { - write!(f, "{marker}")?; - // } - } - Ok(()) - } -} diff --git a/src/model/markers/issue.rs b/src/model/markers/issue.rs deleted file mode 100644 index ce65558..0000000 --- a/src/model/markers/issue.rs +++ /dev/null @@ -1,15 +0,0 @@ -// -#![allow(dead_code)] - -use super::Marker; - -use bon::Builder; - -#[derive(Debug, Builder)] -pub struct IssueMarker { - /// The marker - marker: Marker, - - /// The issue number - issue: usize, -} diff --git a/src/model/markers/marker.rs b/src/model/markers/marker.rs deleted file mode 100644 index 7c04856..0000000 --- a/src/model/markers/marker.rs +++ /dev/null @@ -1,20 +0,0 @@ -// -#![allow(dead_code)] - -use crate::model::Line; - -#[derive(Debug)] -pub enum Marker { - Unmarked, - Invalid(Line), - Valid(Line, String), -} -impl std::fmt::Display for Marker { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Marker::Unmarked => Ok(()), - Marker::Invalid(line) => write!(f, "- Invalid: {line}"), - Marker::Valid(line, _) => write!(f, "- Valid : {line}"), - } - } -} diff --git a/src/model/markers/mod.rs b/src/model/markers/mod.rs index ad11a0a..afe1f2c 100644 --- a/src/model/markers/mod.rs +++ b/src/model/markers/mod.rs @@ -1,10 +1,41 @@ // -mod found; -mod issue; -mod marker; #[cfg(test)] mod tests; -pub use found::FoundMarkers; -pub use marker::Marker; +use crate::model::Line; + +#[derive(Debug)] +pub enum Marker { + Unmarked, + Invalid(Line), + #[allow(dead_code)] + Valid(Line, String), +} +impl std::fmt::Display for Marker { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Marker::Unmarked => Ok(()), + Marker::Invalid(line) => write!(f, "- Invalid: {line}"), + Marker::Valid(line, _) => write!(f, "- Valid : {line}"), + } + } +} + +#[derive(Debug, Default)] +pub struct Markers { + markers: Vec, +} +impl Markers { + pub fn add_marker(&mut self, marker: Marker) { + self.markers.push(marker); + } +} +impl std::fmt::Display for Markers { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + for marker in self.markers.iter() { + write!(f, "{marker}")?; + } + Ok(()) + } +} diff --git a/src/model/markers/tests/found.rs b/src/model/markers/tests.rs similarity index 94% rename from src/model/markers/tests/found.rs rename to src/model/markers/tests.rs index 49f5dc9..41268c8 100644 --- a/src/model/markers/tests/found.rs +++ b/src/model/markers/tests.rs @@ -1,7 +1,5 @@ -use crate::model::Line; - // -use super::*; +use crate::model::{markers::Markers, Line}; #[test] fn found_when_displayed() -> anyhow::Result<()> { @@ -10,7 +8,7 @@ fn found_when_displayed() -> anyhow::Result<()> { let file = fs.base().join("file-name"); let relative = file.strip_prefix(fs.base())?.to_path_buf(); - let mut found = FoundMarkers::default(); + let mut found = Markers::default(); let marker_unmarked = Line::builder() .file(file.clone()) diff --git a/src/model/markers/tests/issue.rs b/src/model/markers/tests/issue.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/model/markers/tests/marker.rs b/src/model/markers/tests/marker.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/model/markers/tests/mod.rs b/src/model/markers/tests/mod.rs deleted file mode 100644 index 998aef3..0000000 --- a/src/model/markers/tests/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -// -use super::*; - -mod found; -mod issue; -mod marker; diff --git a/src/model/mod.rs b/src/model/mod.rs index 20f0054..ec08470 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -8,5 +8,5 @@ mod tests; pub use config::Config; pub use line::Line; -pub use markers::FoundMarkers; pub use markers::Marker; +pub use markers::Markers; diff --git a/src/scanner.rs b/src/scanner.rs index 76acaf0..f9fbfb0 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -1,12 +1,12 @@ // use std::path::Path; -use crate::model::{Config, FoundMarkers, Line, Marker}; +use crate::model::{Config, Line, Marker, Markers}; use anyhow::Result; use ignore::Walk; -pub fn find_markers(config: &Config) -> Result { - let mut markers = FoundMarkers::default(); +pub fn find_markers(config: &Config) -> Result { + let mut markers = Markers::default(); for file in Walk::new(config.fs().base()).flatten() { let path = file.path(); if config.fs().path_is_file(path)? { @@ -16,7 +16,7 @@ pub fn find_markers(config: &Config) -> Result { Ok(markers) } -fn scan_file(file: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> { +fn scan_file(file: &Path, config: &Config, found_markers: &mut Markers) -> Result<()> { let relative_path = file.strip_prefix(config.fs().base())?.to_path_buf(); config .fs()