1use regex::Regex;
2
3pub struct RPatterns {
4 external_patterns: Vec<Regex>,
5 cache_patterns: Vec<Regex>,
6 extensions: Vec<String>,
7}
8
9impl RPatterns {
10 pub fn new() -> Self {
11 let external_patterns = vec![
12 Regex::new(r"\.Rcheck/").unwrap(),
14 Regex::new(r"\.Rhistory").unwrap(),
15 Regex::new(r"\.RData").unwrap(),
16 Regex::new(r"\.Ruserdata").unwrap(),
17
18 Regex::new(r"\.Rproj\.user/").unwrap(),
20 Regex::new(r"\.Rapp\.history").unwrap(),
21
22 Regex::new(r"\.tar\.gz$").unwrap(),
24 Regex::new(r"\.tgz$").unwrap(),
25
26 Regex::new(r"renv/").unwrap(),
28 Regex::new(r"renv\.lock").unwrap(),
29
30 Regex::new(r"packrat/").unwrap(),
32
33 Regex::new(r"\.Rd2pdf").unwrap(),
35
36 Regex::new(r"\.cache/").unwrap(),
38 Regex::new(r"cache/").unwrap(),
39
40 Regex::new(r"_cache/").unwrap(),
42 Regex::new(r"[^/]*_cache/").unwrap(),
43
44 Regex::new(r"\.out$").unwrap(),
46 Regex::new(r"\.log$").unwrap(),
47
48 Regex::new(r"rsconnect/").unwrap(),
50
51 Regex::new(r"Rplots\.pdf").unwrap(),
53
54 Regex::new(r"\.tmp/").unwrap(),
56 Regex::new(r"tmp/").unwrap(),
57 Regex::new(r"\.swp$").unwrap(),
58 Regex::new(r"\.swo$").unwrap(),
59 Regex::new(r"~$").unwrap(),
60
61 Regex::new(r"\.bak$").unwrap(),
63 Regex::new(r"\.orig$").unwrap(),
64
65 Regex::new(r"\.Rproj$").unwrap(),
67
68 Regex::new(r"src/\*\.o$").unwrap(),
70 Regex::new(r"src/\*\.so$").unwrap(),
71 Regex::new(r"src/\*\.dll$").unwrap(),
72 ];
73
74 let cache_patterns = vec![
75 Regex::new(r"\.Rcheck/").unwrap(),
77
78 Regex::new(r"\.Rproj\.user/").unwrap(),
80
81 Regex::new(r"renv/").unwrap(),
83
84 Regex::new(r"_cache/").unwrap(),
86
87 Regex::new(r"\.cache/").unwrap(),
89 ];
90
91 let extensions = vec![
92 "r".to_string(),
94 "R".to_string(),
95
96 "rmd".to_string(),
98 "Rmd".to_string(),
99
100 "rnw".to_string(),
102 "Rnw".to_string(),
103
104 "rtex".to_string(),
106 "Rtex".to_string(),
107
108 "rd".to_string(),
110 "Rd".to_string(),
111
112 "rda".to_string(),
114 "RData".to_string(),
115 "rds".to_string(),
116
117 "yml".to_string(),
119 "yaml".to_string(),
120 "json".to_string(),
121 "toml".to_string(),
122
123 "md".to_string(),
125 "rst".to_string(),
126 "txt".to_string(),
127
128 "html".to_string(),
130 "css".to_string(),
131 "js".to_string(),
132
133 "csv".to_string(),
135 "tsv".to_string(),
136 "xlsx".to_string(),
137 "json".to_string(),
138 "xml".to_string(),
139
140 "sql".to_string(),
142
143 "sh".to_string(),
145 "bash".to_string(),
146
147 "c".to_string(),
149 "cpp".to_string(),
150 "h".to_string(),
151 "hpp".to_string(),
152
153 "f".to_string(),
155 "f90".to_string(),
156 "f95".to_string(),
157 ];
158
159 Self {
160 external_patterns,
161 cache_patterns,
162 extensions,
163 }
164 }
165
166 pub fn get_external_patterns(&self) -> &[Regex] {
167 &self.external_patterns
168 }
169
170 pub fn get_cache_patterns(&self) -> &[Regex] {
171 &self.cache_patterns
172 }
173
174 pub fn get_extensions(&self) -> &[String] {
175 &self.extensions
176 }
177
178 pub fn get_script_names() -> Vec<&'static str> {
179 vec![
180 "DESCRIPTION", "NAMESPACE", "NEWS", "NEWS.md",
182 "README", "README.md", "README.Rmd",
183 "LICENSE", "LICENCE", "COPYING",
184
185 ".Rprofile", ".Renviron", ".Rproj",
187
188 "renv.lock", ".Rprofile",
190
191 "packrat.lock", ".Rprofile",
193
194 "configure", "configure.ac", "configure.in",
196 "Makefile", "Makefile.in", "Makefile.win",
197 "cleanup", "cleanup.win",
198
199 ".github/workflows/r.yml",
201 ".github/workflows/R-CMD-check.yaml",
202 ".travis.yml", "appveyor.yml",
203
204 "Dockerfile", "docker-compose.yml",
206
207 ".editorconfig", ".gitignore",
209 ".Rbuildignore", ".Rinstignore",
210
211 "run.sh", "build.sh", "deploy.sh",
213 "install.sh", "test.sh",
214
215 "app.R", "ui.R", "server.R",
217 "global.R", "www/",
218
219 "index.Rmd", "_site.yml", "_bookdown.yml",
221
222 "_pkgdown.yml", "pkgdown.yml",
224 ]
225 }
226
227 pub fn get_common_directories() -> Vec<&'static str> {
228 vec![
229 "R/", "man/", "vignettes/", "inst/",
231 "data/", "data-raw/", "exec/",
232
233 "tests/", "testthat/",
235
236 "doc/", "docs/", "vignettes/",
238
239 ".Rcheck/", "src/",
241
242 "renv/", "packrat/",
244
245 "www/", "R/", "data/",
247
248 "_site/", "_book/", "_bookdown_files/",
250
251 "config/", "conf/",
253
254 "logs/", "log/",
256
257 "output/", "results/", "figures/",
259
260 "tools/", "scripts/",
262
263 "resources/", "assets/",
265 ]
266 }
267}