[cleanup] Deprecated settings.rs for config.rs
This commit is contained in:
parent
413b2b285e
commit
0f55850b6d
8 changed files with 34 additions and 25 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -411,6 +411,7 @@ dependencies = [
|
|||
"ics",
|
||||
"log",
|
||||
"minidom",
|
||||
"once_cell",
|
||||
"reqwest",
|
||||
"sanitize-filename",
|
||||
"serde",
|
||||
|
@ -549,9 +550,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.5.2"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
||||
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
|
|
|
@ -32,6 +32,7 @@ ical = { version = "0.6", features = ["serde-derive"] }
|
|||
ics = "0.5"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
csscolorparser = { version = "0.5", features = ["serde"] }
|
||||
once_cell = "1.8"
|
||||
|
||||
[patch.crates-io]
|
||||
ical = { git = "https://github.com/daladim/ical-rs.git", branch = "ical_serde" }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! This is an example of how kitchen-fridge can be used
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::{Utc};
|
||||
|
@ -12,16 +14,22 @@ use kitchen_fridge::cache::Cache;
|
|||
use kitchen_fridge::CalDavProvider;
|
||||
use kitchen_fridge::traits::BaseCalendar;
|
||||
use kitchen_fridge::traits::CompleteCalendar;
|
||||
use kitchen_fridge::settings::URL;
|
||||
use kitchen_fridge::settings::USERNAME;
|
||||
use kitchen_fridge::settings::PASSWORD;
|
||||
use kitchen_fridge::settings::EXAMPLE_CREATED_CALENDAR_URL;
|
||||
use kitchen_fridge::settings::EXAMPLE_EXISTING_CALENDAR_URL;
|
||||
use kitchen_fridge::utils::pause;
|
||||
|
||||
const CACHE_FOLDER: &str = "test_cache/provider_sync";
|
||||
|
||||
|
||||
// TODO: change these values with yours
|
||||
pub const URL: &str = "https://my.server.com/remote.php/dav/files/john";
|
||||
pub const USERNAME: &str = "username";
|
||||
pub const PASSWORD: &str = "secret_password";
|
||||
|
||||
pub const EXAMPLE_TASK_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/6121A0BE-C2E0-4F16-A3FA-658E54E7062A/74439558-CDFF-426C-92CD-ECDDACE971B0.ics";
|
||||
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
|
||||
pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
|
||||
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
|
11
src/config.rs
Normal file
11
src/config.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
//! Support for compile-time configuration options
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Part of the ProdID string that describes the organization (example of a ProdID string: `-//ABC Corporation//My Product//EN`)
|
||||
/// You can override it at compile-time with the `KITCHEN_FRIDGE_ICAL_ORG_NAME` environment variable, or keep the default value
|
||||
pub static ORG_NAME: Lazy<String> = Lazy::new(|| option_env!("KITCHEN_FRIDGE_ICAL_ORG_NAME").unwrap_or("My organization").to_string() );
|
||||
|
||||
/// Part of the ProdID string that describes the product name (example of a ProdID string: `-//ABC Corporation//My Product//EN`)
|
||||
/// You can override it at compile-time with the `KITCHEN_FRIDGE_ICAL_PRODUCT_NAME` environment variable, or keep the default value
|
||||
pub static PRODUCT_NAME: Lazy<String> = Lazy::new(|| option_env!("KITCHEN_FRIDGE_ICAL_PRODUCT_NAME").unwrap_or("KitchenFridge").to_string() );
|
|
@ -85,7 +85,7 @@ fn ical_to_ics_property(prop: IcalProperty) -> IcsProperty<'static> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::Task;
|
||||
use crate::settings::{ORG_NAME, PRODUCT_NAME};
|
||||
use crate::config::{ORG_NAME, PRODUCT_NAME};
|
||||
|
||||
#[test]
|
||||
fn test_ical_from_completed_task() {
|
||||
|
@ -104,7 +104,7 @@ mod tests {
|
|||
COMPLETED:{}\r\n\
|
||||
STATUS:COMPLETED\r\n\
|
||||
END:VTODO\r\n\
|
||||
END:VCALENDAR\r\n", ORG_NAME, PRODUCT_NAME, uid, s_now, s_now, s_now, s_now);
|
||||
END:VCALENDAR\r\n", *ORG_NAME, *PRODUCT_NAME, uid, s_now, s_now, s_now, s_now);
|
||||
|
||||
assert_eq!(ical, expected_ical);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ mod tests {
|
|||
SUMMARY:This is a task with ÜTF-8 characters\r\n\
|
||||
STATUS:NEEDS-ACTION\r\n\
|
||||
END:VTODO\r\n\
|
||||
END:VCALENDAR\r\n", ORG_NAME, PRODUCT_NAME, uid, s_now, s_now, s_now);
|
||||
END:VCALENDAR\r\n", *ORG_NAME, *PRODUCT_NAME, uid, s_now, s_now, s_now);
|
||||
|
||||
assert_eq!(ical, expected_ical);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ pub use parser::parse;
|
|||
mod builder;
|
||||
pub use builder::build_from;
|
||||
|
||||
use crate::settings::{ORG_NAME, PRODUCT_NAME};
|
||||
use crate::config::{ORG_NAME, PRODUCT_NAME};
|
||||
|
||||
pub fn default_prod_id() -> String {
|
||||
format!("-//{}//{}//EN", ORG_NAME, PRODUCT_NAME)
|
||||
format!("-//{}//{}//EN", *ORG_NAME, *PRODUCT_NAME)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ pub mod cache;
|
|||
pub use cache::Cache;
|
||||
pub mod ical;
|
||||
|
||||
pub mod settings;
|
||||
pub mod config;
|
||||
pub mod utils;
|
||||
pub mod resource;
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
// TODO: change these values with yours
|
||||
|
||||
pub const URL: &str = "https://my.server.com/remote.php/dav/files/john";
|
||||
pub const USERNAME: &str = "username";
|
||||
pub const PASSWORD: &str = "secret_password";
|
||||
|
||||
pub const EXAMPLE_TASK_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/6121A0BE-C2E0-4F16-A3FA-658E54E7062A/74439558-CDFF-426C-92CD-ECDDACE971B0.ics";
|
||||
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
|
||||
pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
|
||||
|
||||
pub const ORG_NAME: &str = "My organisation";
|
||||
pub const PRODUCT_NAME: &str = "My CalDAV client";
|
Loading…
Add table
Reference in a new issue