ThinkR-open / fusen
Showing 2 of 5 files from the diff.

@@ -390,15 +390,8 @@
Loading
390 390
  # vignette_tbl[["label"]] <- make.unique(vignette_tbl[["label"]], sep = "-")
391 391
  # # Not re-used in as_document()
392 392
393 -
  # name <- "y  _ p n@ é ! 1"
394 -
  cleaned_name <- gsub("^-|-$", "",
395 -
                       gsub("-+", "-",
396 -
                            gsub("-_|_-", "-",
397 -
                                 gsub("[^([:alnum:]*_*-*)*]", "-", name))))
398 -
  # grepl("^[[:alpha:]][[:alnum:]_-]*$", cleaned_name)
399 -
  # asciify from {usethis} usethis:::asciify()
400 -
  cleaned_name <- gsub("[^a-zA-Z0-9_-]+", "-", cleaned_name)
401 -
393 +
  
394 +
  cleaned_name <- asciify_name(name)
402 395
  
403 396
  usethis::use_vignette(name = cleaned_name, title = name)
404 397
  vignette_file <- file.path("vignettes", paste0(cleaned_name, ".Rmd"))
@@ -423,3 +416,4 @@
Loading
423 416
    )
424 417
  }
425 418
}
419 +

@@ -33,6 +33,13 @@
Loading
33 33
add_dev_history <- function(pkg = ".", overwrite = FALSE,
34 34
                            open = TRUE, dev_dir = "dev", 
35 35
                            name = c("full", "minimal", "additional", "teaching")) {
36 +
  
37 +
  project_name <- basename(normalizePath(pkg))
38 +
  if (project_name != asciify_name(project_name, to_pkg = TRUE)) {
39 +
    stop("Please rename your project/directory with: ", asciify_name(project_name, to_pkg = TRUE),
40 +
         " as a package name should only contain letters, numbers and dots.")
41 +
  }
42 +
  
36 43
  old <- setwd(pkg)
37 44
  on.exit(setwd(old))
38 45
@@ -106,3 +113,25 @@
Loading
106 113
  
107 114
  dev_path
108 115
}
116 +
117 +
#' Clean names for vignettes and package
118 +
#' @param name Character to clean
119 +
#' @param to_pkg Transform all non authorized characters to dots for packages, instead of dash
120 +
#' @noRd
121 +
asciify_name <- function(name, to_pkg = FALSE) {
122 +
  # name <- "y  _ p n@ é ! 1"
123 +
  cleaned_name <- gsub("^-|-$", "",
124 +
                       gsub("-+", "-",
125 +
                            gsub("-_|_-", "-",
126 +
                                 gsub("[^([:alnum:]*_*-*)*]", "-", name))))
127 +
  # grepl("^[[:alpha:]][[:alnum:]_-]*$", cleaned_name)
128 +
129 +
  if (isTRUE(to_pkg)) {
130 +
    cleaned_name <- gsub("[^a-zA-Z0-9]+", ".", 
131 +
                         gsub("^[0-9]+", "", cleaned_name))
132 +
  } else {
133 +
    # asciify from {usethis} usethis:::asciify()
134 +
    cleaned_name <- gsub("[^a-zA-Z0-9_-]+", "-", cleaned_name) 
135 +
  }
136 +
  cleaned_name
137 +
}
Files Coverage
R 92.40%
Project Totals (3 files) 92.40%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading