Skip to content

Commit

Permalink
refactor: move all Lore specific modules to new lore lib module
Browse files Browse the repository at this point in the history
[What]

Create a module named `lore` in the library crate to house all
domain-specific modules. This considerably cleans the `src/` directory,
with the only con of adding another nesting level to the library crate
and having to collaterally update a handful of imports.

[Why/Context]

Currently, the `src/` directory of the project is a mess as it is
crowded with the modules defined in the library crate and the binary
crate as well. Specifically, the modules from the lib crate (defined in
`lib.rs`) are domain-specific, i.e., they represent implementations that
are significantly or entirely coupled with the Lore objects and API.

In this sense, we could extract every module from the library crate (at
the moment, they all live directly in `src/`) to a directory `lib/`.
This would result in a good clean-up, as all directories of these
modules, like `lore_api_client/`, `lore_session/`, etc., would be
encapsulated inside `lib/`, but the modules themselves
(`lore_api_client.rs`, `lore_session.rs`), would still need to be
directly under `src/`.

Signed-off-by: David Tadokoro <davidbtadokoro@usp.br>
  • Loading branch information
davidbtadokoro committed Oct 30, 2024
1 parent 55d2416 commit 324d0df
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::log_on_error;
use color_eyre::eyre::bail;
use config::Config;
use logging::Logger;
use patch_hub::{lore_api_client::BlockingLoreAPIClient, lore_session, patch::Patch};
use patch_hub::lore::{lore_api_client::BlockingLoreAPIClient, lore_session, patch::Patch};
use patch_renderer::PatchRenderer;
use screens::{
bookmarked::BookmarkedPatchsetsState,
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/bookmarked.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use patch_hub::patch::Patch;
use patch_hub::lore::patch::Patch;

pub struct BookmarkedPatchsetsState {
pub bookmarked_patchsets: Vec<Patch>,
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/details_actions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::CurrentScreen;
use ::patch_hub::{lore_api_client::BlockingLoreAPIClient, lore_session, patch::Patch};
use ::patch_hub::lore::{lore_api_client::BlockingLoreAPIClient, lore_session, patch::Patch};
use color_eyre::eyre::bail;
use std::{collections::HashMap, path::Path, process::Command};

Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/latest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use color_eyre::eyre::bail;
use derive_getters::Getters;
use patch_hub::{
use patch_hub::lore::{
lore_api_client::{BlockingLoreAPIClient, ClientError},
lore_session::{LoreSession, LoreSessionError},
patch::Patch,
Expand Down
4 changes: 3 additions & 1 deletion src/app/screens/mail_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use color_eyre::eyre::bail;
use patch_hub::{lore_api_client::BlockingLoreAPIClient, lore_session, mailing_list::MailingList};
use patch_hub::lore::{
lore_api_client::BlockingLoreAPIClient, lore_session, mailing_list::MailingList,
};

pub struct MailingListSelectionState {
pub mailing_lists: Vec<MailingList>,
Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
pub mod lore_api_client;
pub mod lore_session;
pub mod mailing_list;
pub mod patch;
pub mod lore;
4 changes: 4 additions & 0 deletions src/lore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod lore_api_client;
pub mod lore_session;
pub mod mailing_list;
pub mod patch;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::patch::PatchFeed;
use crate::lore::patch::PatchFeed;

#[test]
#[ignore = "network-io"]
Expand Down
6 changes: 3 additions & 3 deletions src/lore_session.rs → src/lore/lore_session.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::lore_api_client::{
use crate::lore::lore_api_client::{
AvailableListsRequest, ClientError, PatchFeedRequest, PatchHTMLRequest,
};
use crate::mailing_list::MailingList;
use crate::patch::{Patch, PatchFeed, PatchRegex};
use crate::lore::mailing_list::MailingList;
use crate::lore::patch::{Patch, PatchFeed, PatchRegex};
use derive_getters::Getters;
use regex::Regex;
use serde_xml_rs::from_str;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use io::Read;

use super::*;
use crate::patch::Author;
use crate::lore::patch::Author;

use mockall::mock;
use std::fs;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ui/latest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::app::App;
use patch_hub::patch::Patch;
use patch_hub::lore::patch::Patch;
use ratatui::{
layout::Rect,
style::{Color, Modifier, Style},
Expand Down

0 comments on commit 324d0df

Please sign in to comment.