summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorShu Kutsuzawa <cappyzawa@gmail.com>2021-02-22 03:51:36 +0900
committerGitHub <noreply@github.com>2021-02-21 19:51:36 +0100
commit51f752f6b0ddb616a03923bf0de0adac2f565beb (patch)
treebfd2a9f3da53c3fc26c5917739b3a00ad6f03081 /src/modules
parente73581ddf00207fa0b17a07b43ac0f7785eb1811 (diff)
feat(perl): Configure when the module is shown (#2355)
This makes it possible to configure when the perl module is shown based on the contents of a directory. This should make it possible to be a lot more granular when configuring the module.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/perl.rs23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/modules/perl.rs b/src/modules/perl.rs
index a307e287c..735860fca 100644
--- a/src/modules/perl.rs
+++ b/src/modules/perl.rs
@@ -4,33 +4,20 @@ use crate::configs::perl::PerlConfig;
use crate::formatter::StringFormatter;
/// Creates a module with the current perl version
-///
-/// Will display the perl version if any of the following criteria are met:
-/// - Current directory contains a `.pl`, `.pm` or a `.pod` file
-/// - Current directory contains a "Makefile.PL", "Build.PL", "cpanfile", "cpanfile.snapshot",
-/// "META.json", "META.yml", or ".perl-version" file
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
+ let mut module = context.new_module("perl");
+ let config: PerlConfig = PerlConfig::try_load(module.config);
let is_perl_project = context
.try_begin_scan()?
- .set_files(&[
- "Makefile.PL",
- "Build.PL",
- "cpanfile",
- "cpanfile.snapshot",
- "META.json",
- "META.yml",
- ".perl-version",
- ])
- .set_extensions(&["pl", "pm", "pod"])
+ .set_extensions(&config.detect_extensions)
+ .set_files(&config.detect_files)
+ .set_folders(&config.detect_folders)
.is_match();
if !is_perl_project {
return None;
}
- let mut module = context.new_module("perl");
- let config: PerlConfig = PerlConfig::try_load(module.config);
-
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
formatter
.map_meta(|var, _| match var {