Skip to content

Commit

Permalink
refactor(config): Clarify config is not file-specific
Browse files Browse the repository at this point in the history
This is prep for the config being reused in other contexts, like commit
messages.
  • Loading branch information
Ed Page committed Mar 30, 2021
1 parent 4bbc59f commit f402d3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) struct FileArgs {
pub(crate) locale: Option<config::Locale>,
}

impl config::FileSource for FileArgs {
impl config::EngineSource for FileArgs {
fn binary(&self) -> Option<bool> {
match (self.binary, self.no_binary) {
(true, false) => Some(true),
Expand Down
20 changes: 10 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub trait ConfigSource {
None
}

fn default(&self) -> Option<&dyn FileSource> {
fn default(&self) -> Option<&dyn EngineSource> {
None
}
}
Expand Down Expand Up @@ -42,7 +42,7 @@ pub trait WalkSource {
}
}

pub trait FileSource {
pub trait EngineSource {
/// Check binary files.
fn binary(&self) -> Option<bool> {
None
Expand Down Expand Up @@ -113,7 +113,7 @@ pub trait DictSource {
#[serde(rename_all = "kebab-case")]
pub struct Config {
pub files: Walk,
pub default: FileConfig,
pub default: EngineConfig,
}

impl Config {
Expand All @@ -130,7 +130,7 @@ impl Config {
pub fn from_defaults() -> Self {
Self {
files: Walk::from_defaults(),
default: FileConfig::from_defaults(),
default: EngineConfig::from_defaults(),
}
}

Expand All @@ -157,7 +157,7 @@ impl ConfigSource for Config {
Some(&self.files)
}

fn default(&self) -> Option<&dyn FileSource> {
fn default(&self) -> Option<&dyn EngineSource> {
Some(&self.default)
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@ impl WalkSource for Walk {
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields, default)]
#[serde(rename_all = "kebab-case")]
pub struct FileConfig {
pub struct EngineConfig {
pub binary: Option<bool>,
pub check_filename: Option<bool>,
pub check_file: Option<bool>,
Expand All @@ -276,10 +276,10 @@ pub struct FileConfig {
pub dict: Option<DictConfig>,
}

impl FileConfig {
impl EngineConfig {
pub fn from_defaults() -> Self {
let empty = Self::default();
FileConfig {
EngineConfig {
binary: Some(empty.binary()),
check_filename: Some(empty.check_filename()),
check_file: Some(empty.check_file()),
Expand All @@ -292,7 +292,7 @@ impl FileConfig {
}
}

pub fn update(&mut self, source: &dyn FileSource) {
pub fn update(&mut self, source: &dyn EngineSource) {
if let Some(source) = source.binary() {
self.binary = Some(source);
}
Expand Down Expand Up @@ -333,7 +333,7 @@ impl FileConfig {
}
}

impl FileSource for FileConfig {
impl EngineSource for EngineConfig {
fn binary(&self) -> Option<bool> {
self.binary
}
Expand Down

0 comments on commit f402d3e

Please sign in to comment.