1use regex::Regex;
2
3pub struct PerlPatterns {
4 external_patterns: Vec<Regex>,
5 cache_patterns: Vec<Regex>,
6 extensions: Vec<String>,
7}
8
9impl PerlPatterns {
10 pub fn new() -> Self {
11 let external_patterns = vec![
12 Regex::new(r"blib/").unwrap(),
14 Regex::new(r"_build/").unwrap(),
15 Regex::new(r"Build$").unwrap(),
16 Regex::new(r"\.build/").unwrap(),
17
18 Regex::new(r"MYMETA\.yml").unwrap(),
20 Regex::new(r"MYMETA\.json").unwrap(),
21 Regex::new(r"META\.yml").unwrap(),
22 Regex::new(r"META\.json").unwrap(),
23
24 Regex::new(r"Makefile$").unwrap(),
26 Regex::new(r"Makefile\.old").unwrap(),
27 Regex::new(r"pm_to_blib").unwrap(),
28
29 Regex::new(r"\.par$").unwrap(),
31 Regex::new(r"\.pp$").unwrap(),
32
33 Regex::new(r"\.phar$").unwrap(),
35
36 Regex::new(r"cover_db/").unwrap(),
38 Regex::new(r"\.gcov$").unwrap(),
39
40 Regex::new(r"\.tmp/").unwrap(),
42 Regex::new(r"tmp/").unwrap(),
43 Regex::new(r"\.swp$").unwrap(),
44 Regex::new(r"\.swo$").unwrap(),
45 Regex::new(r"~$").unwrap(),
46
47 Regex::new(r"\.bak$").unwrap(),
49 Regex::new(r"\.orig$").unwrap(),
50
51 Regex::new(r"local/").unwrap(),
53 Regex::new(r"\.carton/").unwrap(),
54
55 Regex::new(r"\.perlbrew/").unwrap(),
57
58 Regex::new(r"\.build/").unwrap(),
60
61 Regex::new(r"\.minilla/").unwrap(),
63
64 Regex::new(r"\.log$").unwrap(),
66 Regex::new(r"logs/").unwrap(),
67 ];
68
69 let cache_patterns = vec![
70 Regex::new(r"blib/").unwrap(),
72 Regex::new(r"_build/").unwrap(),
73
74 Regex::new(r"cover_db/").unwrap(),
76
77 Regex::new(r"local/").unwrap(),
79
80 Regex::new(r"\.build/").unwrap(),
82 ];
83
84 let extensions = vec![
85 "pl".to_string(),
87 "pm".to_string(),
88 "pod".to_string(),
89 "t".to_string(),
90
91 "perl".to_string(),
93 "cgi".to_string(),
94
95 "p6".to_string(),
97 "pl6".to_string(),
98 "pm6".to_string(),
99 "raku".to_string(),
100 "rakumod".to_string(),
101
102 "yml".to_string(),
104 "yaml".to_string(),
105 "json".to_string(),
106 "ini".to_string(),
107 "conf".to_string(),
108
109 "md".to_string(),
111 "rst".to_string(),
112 "txt".to_string(),
113
114 "html".to_string(),
116 "css".to_string(),
117 "js".to_string(),
118
119 "sh".to_string(),
121 "bash".to_string(),
122
123 "sql".to_string(),
125
126 "xml".to_string(),
128 ];
129
130 Self {
131 external_patterns,
132 cache_patterns,
133 extensions,
134 }
135 }
136
137 pub fn get_external_patterns(&self) -> &[Regex] {
138 &self.external_patterns
139 }
140
141 pub fn get_cache_patterns(&self) -> &[Regex] {
142 &self.cache_patterns
143 }
144
145 pub fn get_extensions(&self) -> &[String] {
146 &self.extensions
147 }
148
149 pub fn get_script_names() -> Vec<&'static str> {
150 vec![
151 "Makefile.PL", "Build.PL", "META.yml", "META.json",
153 "MYMETA.yml", "MYMETA.json", "MANIFEST", "MANIFEST.SKIP",
154
155 "cpanfile", "cpanfile.snapshot",
157
158 "dist.ini", "weaver.ini",
160
161 "minil.toml",
163
164 "cpm.yml",
166
167 ".perl-version", ".perlbrew",
169
170 "Makefile", "GNUmakefile", "makefile",
172
173 ".github/workflows/perl.yml",
175 ".travis.yml", "appveyor.yml",
176
177 "Dockerfile", "docker-compose.yml",
179
180 ".editorconfig", ".gitignore",
182 ".perltidyrc", ".perlcriticrc",
183
184 "run.sh", "build.sh", "deploy.sh",
186 "install.sh", "test.sh",
187
188 ".htaccess", "httpd.conf",
190
191 "perllocal.pod", "perldoc.pod",
193 ]
194 }
195
196 pub fn get_common_directories() -> Vec<&'static str> {
197 vec![
198 "lib/", "bin/", "script/", "scripts/",
200
201 "t/", "test/", "tests/", "xt/",
203
204 "doc/", "docs/", "eg/", "examples/",
206
207 "blib/", "_build/", ".build/",
209
210 "local/", "extlib/", "fatlib/",
212
213 "public/", "static/", "htdocs/", "www/",
215 "templates/", "views/",
216
217 "config/", "conf/", "etc/",
219
220 "logs/", "log/",
222
223 "data/", "share/",
225
226 "tools/", "util/", "utils/",
228
229 "res/", "resources/",
231 ]
232 }
233}