use std::path::PathBuf;
use once_cell::sync::Lazy;
pub const READSTOR_DEV: &str = "READSTOR_DEV";
pub const READSTOR_LOG: &str = "READSTOR_LOG";
pub static OUTPUT_DIRECTORY: Lazy<PathBuf> = Lazy::new(|| lib::defaults::HOME.join(".readstor"));
pub static TEMP_OUTPUT_DIRECTORY: Lazy<PathBuf> =
Lazy::new(|| std::env::temp_dir().join("readstor"));
pub static TEMPLATE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/templates/basic/basic.jinja2"
));
pub static TEST_DATABASES: Lazy<PathBuf> = Lazy::new(|| {
let mut path = lib::defaults::CRATE_ROOT.to_owned();
path.extend(["data", "databases"].iter());
path
});
#[cfg(test)]
pub mod testing {
use super::*;
#[derive(Debug, Clone, Copy)]
pub enum MockDatabases {
Empty,
BooksNew,
BooksAnnotated,
}
impl std::fmt::Display for MockDatabases {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Empty => write!(f, "empty"),
Self::BooksNew => write!(f, "books-new"),
Self::BooksAnnotated => write!(f, "books-annotated"),
}
}
}
impl From<MockDatabases> for PathBuf {
fn from(databases: MockDatabases) -> Self {
TEST_DATABASES.join(databases.to_string())
}
}
pub static MOCK_PLISTS: Lazy<PathBuf> = Lazy::new(|| {
let mut path = lib::defaults::CRATE_ROOT.to_owned();
path.extend(["data", "plists"].iter());
path
});
#[derive(Debug, Clone, Copy)]
pub enum MockPlists {
Empty,
BooksNew,
BooksAnnotated,
}
impl std::fmt::Display for MockPlists {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Empty => write!(f, "empty"),
Self::BooksNew => write!(f, "books-new"),
Self::BooksAnnotated => write!(f, "books-annotated"),
}
}
}
impl From<MockPlists> for PathBuf {
fn from(databases: MockPlists) -> Self {
MOCK_PLISTS.join(databases.to_string())
}
}
}