R/materialize_scss_build.R

#' Materialize sass worflow and R-API
#'
#'
#' \code{materialize.get_repo}
#'
#' @references \href{https://github.com/dogfalo/materialize/}{Github repo}
#' @references \href{http://materializecss.com/bin/materialize-src-v0.97.8.zip}{SCSS build}
#' @references \href{http://materializecss.com/bin/materialize-v0.97.8.zip}{CSS build}
#' @references \href{https://cdnjs.com/libraries/materialize}{cdnjs repo}
#' @references \href{https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic}{Roboto Font}
#'
#'

rt_zips <- list(
  scss = "http://materializecss.com/bin/materialize-src-v0.97.8.zip",
  css = "http://materializecss.com/bin/materialize-v0.97.8.zip"
)

rt_temp_dir <- temp_dir('rt_temp_dir')
rt_temp_zip <- normalizePath(tempfile(tmpdir = rt_temp_dir), winslash = "/")
curl_download(rt_zips$scss, destfile = rt_temp_zip)
unzip(rt_temp_zip, exdir = rt_temp_dir)

all_files <- list.files(rt_temp_dir,
                        full.names = TRUE,
                        recursive = TRUE,
                        pattern = "\\.(.*?)$")

sub_base_pattern <- sprintf("%s/", rt_temp_dir)

new_dirs <- gsub(sub_base_pattern,"",
                 list.dirs(rt_temp_dir, recursive = TRUE,
                           full.names = T) %>% .[2:length(.)])

new_file_paths_abs <- gsub(sub_base_pattern, "", all_files)

local_dir <- "inst/www/lib/%s"
sapply(sprintf(local_dir, new_dirs),dir.create)


rt_scss_files <- list.files(recursive = T,
                            pattern = "\\_(\\w+)\\.scss$",
                            full.names = T)
CarlBoneri/rtspecs documentation built on June 1, 2017, 11:02 p.m.