1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::{config::Config, template::Template};
use anyhow::Result;
pub fn namespacified(input: &str) -> String {
input.to_lowercase().replace(" ", "_")
}
pub fn get_template_with_config(config: &Config) -> Result<Vec<Template>> {
let templates = vec![
include_str!("../template/datapack.template"),
include_str!("../template/namespace.template"),
include_str!("../template/pack.template"),
include_str!("../template/root.template"),
];
templates
.iter()
.map(|content| Template::from_str(content, config))
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn convert_to_namespace() {
assert_eq!(
namespacified("Boomber:Something Here"),
"boomber:something_here"
);
assert_eq!(namespacified("Hello@World"), "hello@world");
assert_eq!(namespacified("test ()"), "test_()");
}
}