Remove "get" prefix from function names

This commit is contained in:
Joseph T Lyons 2022-09-28 17:07:11 -04:00
parent fbe5f9225c
commit f8da5ab2e7

View File

@ -14,7 +14,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
let settings = cx.global::<Settings>();
let journal_dir = match get_journal_dir(&settings.journal_overrides.journal_directory) {
let journal_dir = match journal_dir(&settings.journal_overrides.journal_directory) {
Some(journal_dir) => journal_dir,
None => {
log::error!("can't determine home directory");
@ -29,7 +29,7 @@ pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
let entry_path = month_dir.join(format!("{:02}.md", now.day()));
let now = now.time();
let hour_format = &settings.journal_overrides.hour_format;
let entry_heading = get_heading_entry(now, &hour_format);
let entry_heading = heading_entry(now, &hour_format);
let create_entry = cx.background().spawn(async move {
std::fs::create_dir_all(month_dir)?;
@ -76,7 +76,7 @@ pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
.detach();
}
fn get_journal_dir(a: &Option<JournalDirectory>) -> Option<PathBuf> {
fn journal_dir(a: &Option<JournalDirectory>) -> Option<PathBuf> {
let journal_default_dir = dirs::home_dir()?.join("journal");
let journal_dir = match a {
@ -89,7 +89,7 @@ fn get_journal_dir(a: &Option<JournalDirectory>) -> Option<PathBuf> {
Some(journal_dir)
}
fn get_heading_entry(now: NaiveTime, hour_format: &Option<HourFormat>) -> String {
fn heading_entry(now: NaiveTime, hour_format: &Option<HourFormat>) -> String {
match hour_format {
Some(HourFormat::Hour24) => {
let hour = now.hour();
@ -111,7 +111,7 @@ mod tests {
#[test]
fn test_heading_entry_defaults_to_hour_12() {
let naive_time = NaiveTime::from_hms_milli(15, 0, 0, 0);
let actual_heading_entry = get_heading_entry(naive_time, &None);
let actual_heading_entry = heading_entry(naive_time, &None);
let expected_heading_entry = "# 3:00 PM";
assert_eq!(actual_heading_entry, expected_heading_entry);
@ -120,7 +120,7 @@ mod tests {
#[test]
fn test_heading_entry_is_hour_12() {
let naive_time = NaiveTime::from_hms_milli(15, 0, 0, 0);
let actual_heading_entry = get_heading_entry(naive_time, &Some(HourFormat::Hour12));
let actual_heading_entry = heading_entry(naive_time, &Some(HourFormat::Hour12));
let expected_heading_entry = "# 3:00 PM";
assert_eq!(actual_heading_entry, expected_heading_entry);
@ -129,7 +129,7 @@ mod tests {
#[test]
fn test_heading_entry_is_hour_24() {
let naive_time = NaiveTime::from_hms_milli(15, 0, 0, 0);
let actual_heading_entry = get_heading_entry(naive_time, &Some(HourFormat::Hour24));
let actual_heading_entry = heading_entry(naive_time, &Some(HourFormat::Hour24));
let expected_heading_entry = "# 15:00";
assert_eq!(actual_heading_entry, expected_heading_entry);