~hrbrmstr/cloc

055402630318b72d86cf66b09ef194ceb3620c32 — boB Rudis 6 years ago bd8482f
removed dplyr dependency
5 files changed, 30 insertions(+), 12 deletions(-)

M NAMESPACE
M NEWS.md
M R/cloc-cran.r
M R/cloc-package.r
M R/cloc-recognized-languages.r
M NAMESPACE => NAMESPACE +0 -3
@@ 10,9 10,6 @@ export(cloc_os)
export(cloc_remove_comments)
export(cloc_reognized_languages)
export(cloc_version)
importFrom(dplyr,bind_rows)
importFrom(dplyr,data_frame)
importFrom(dplyr,progress_estimated)
importFrom(git2r,clone)
importFrom(processx,run)
importFrom(utils,contrib.url)

M NEWS.md => NEWS.md +1 -0
@@ 9,6 9,7 @@
  other languages used in Rmd code blocks.
- URLs as sources work in more funtions now
- cloc_git() can now clone repo when using git:// URLs
- removed dplyr dependency

# cloc 0.1.0


M R/cloc-cran.r => R/cloc-cran.r +19 -3
@@ 35,16 35,32 @@ cloc_cran <- function(pkgs,
  ) -> res_p

  # call "cloc" on each package archive, bind results into a single data frame
  if (.progress) pb <- dplyr::progress_estimated(length(res_p$V2))
  dplyr::bind_rows(
  if (.progress) {
    pb <- txtProgressBar(min = 0, max = length(res_p$V2), style = 3)
    on.exit(close(pb), add = TRUE)
  }

  i <- 1
  do.call(rbind.data.frame,

    lapply(res_p$V2, function(x) {
      if (.progress) pb$tick()$print()

      if (.progress) {
        setTxtProgressBar(pb, i)
        i <<- i + 1
      }

      ret <- cloc(x)
      if (nrow(ret) > 0) ret$pkg <- res_p[res_p$V2 == x, ]$V1

      ret

    })

  ) -> res

  class(res) <- c("tbl_df", "tbl", "data.frame")

  res

}

M R/cloc-package.r => R/cloc-package.r +1 -2
@@ 55,7 55,6 @@
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @importFrom git2r clone
#' @importFrom utils read.table contrib.url download.file download.packages tail
#' @importFrom dplyr bind_rows progress_estimated data_frame
#' @importFrom processx run
#' @importFrom utils read.table contrib.url download.file download.packages tail
NULL

M R/cloc-recognized-languages.r => R/cloc-recognized-languages.r +9 -4
@@ 45,19 45,24 @@ cloc_reognized_languages <- function() {

  dat <- system(cmd, intern = TRUE)

  dplyr::bind_rows(
  do.call(rbind.data.frame,
    lapply(
      strsplit(dat, "\\("),
      function(.x) {
        lang <- trimws(.x[1])
        extensions <- trimws(.x[2])
        extensions <- sub("\\)", "", extensions)
        dplyr::data_frame(
        data.frame(
          lang = lang,
          extensions = extensions
          extensions = extensions,
          stringsAsFactors = FALSE
        )
      }
    )
  )
  ) -> out

  class(out) <- c("tbl_df", "tbl", "data.frame")

  out

}