[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
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
Add a link
Reference in a new issue