shunsock / timezone_translator

simple command-line utility that converts a given time from one timezone to another.
MIT License
23 stars 1 forks source link

Refactor/validator #30

Closed shunsock closed 3 months ago

shunsock commented 3 months ago

Issue

For details, see the related issue on GitHub: https://github.com/shunsock/timezone_translator/issues/29

About

This pull request involves a re-architecture of the validator and factory modules. Although a significant number of files have been modified, these changes do not impact the overall behavior of the commands.

Structure After Changed

The module structure following this pull request is illustrated below:

crate timezone_translator
├── mod command: pub(crate)
│   ├── mod arguments: pub(self)
│   │   ├── mod ambiguous_time_strategy: pub(crate)
│   │   │   └── fn ambiguous_time_strategy: pub(crate)
│   │   ├── mod from: pub(crate)
│   │   │   └── fn from: pub(crate)
│   │   ├── mod time: pub(crate)
│   │   │   └── fn time: pub(crate)
│   │   └── mod to: pub(crate)
│   │       └── fn to: pub(crate)
│   ├── mod command_definition: pub(self)
│   │   └── fn command_provider: pub(crate)
│   ├── mod helper: pub(self)
│   │   └── mod local_timezone_string_provider: pub(super)
│   │       └── fn provide_local_timezone_string: pub(crate)
│   ├── mod receiver: pub(crate)
│   │   └── fn receive_user_input: pub(crate)
│   └── mod validated_options: pub(crate)
│       ├── mod ambiguous_time_strategy: pub(crate)
│       │   └── enum AmbiguousTimeStrategy: pub(crate)
│       └── mod validated_user_inputs: pub(crate)
│           └── struct ValidatedCommandOptions: pub(crate)
│               ├── fn ambiguous_time_strategy: pub(crate)
│               ├── fn from_tz: pub(crate)
│               ├── fn new: pub(crate)
│               ├── fn time: pub(crate)
│               └── fn to_tz: pub(crate)
├── fn main: pub(crate)
├── mod translator: pub(crate)
│   ├── mod translation_error: pub(crate)
│   │   └── enum TranslationError: pub(crate)
│   └── mod translator: pub(crate)
│       ├── struct TimezoneTranslator: pub(crate)
│       │   ├── fn convert: pub(crate)
│       │   └── fn new: pub(crate)
│       └── fn select_time_with_ambiguous_time_strategy: pub(self)
└── mod validator: pub(crate)
    ├── mod ambiguous_time_strategy_validator: pub(crate)
    │   └── fn validate_string_for_ambiguous_time_strategy: pub(super)
    ├── mod command_options_validator: pub(crate)
    │   └── fn validate_command_options: pub(crate)
    ├── mod native_datetime_validator: pub(self)
    │   └── fn validate_string_for_native_datetime: pub(super)
    ├── mod regex_matcher: pub(self)
    │   ├── mod ymd_hms_matcher: pub(super)
    │   │   └── fn ymd_hms_matcher: pub(crate)
    │   ├── mod ymd_matcher: pub(super)
    │   │   └── fn ymd_matcher: pub(crate)
    │   └── mod ymd_t_hms_matcher: pub(super)
    │       └── fn ymd_t_hms_matcher: pub(crate)
    ├── mod timezone_validator: pub(self)
    │   └── fn validate_string_for_timezone: pub(super)
    └── mod validation_error: pub(self)
        └── enum ValidationError: pub(crate)

If you have any questions or need further clarification, please feel free to ask!

CI also added

above structure is output of cargo modules structure. Seeing in CI, I added cargo modules to ci.