From 8ec3748ee1f877cb285162ba5a8a19c0b03e4b1b Mon Sep 17 00:00:00 2001 From: Brancen Gregory Date: Sat, 4 Feb 2023 16:46:09 -0500 Subject: [PATCH 1/2] WIP --- .Rprofile | 1 + NAMESPACE | 1 + R/ojo_create_project.R | 29 ++++++++++++ man/ojo_arrests.Rd | 6 ++- man/ojo_create_project.Rd | 14 ++++++ renv.lock | 60 ++++++++++++++++++++++-- tests/testthat/test-ojo_create_project.R | 7 +++ 7 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 .Rprofile create mode 100644 R/ojo_create_project.R create mode 100644 man/ojo_create_project.Rd create mode 100644 tests/testthat/test-ojo_create_project.R diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..81b960f --- /dev/null +++ b/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/NAMESPACE b/NAMESPACE index 1ec07d9..1ab897c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(ojo_civ_cases) export(ojo_color) export(ojo_connect) export(ojo_county_population) +export(ojo_create_project) export(ojo_crim_cases) export(ojo_fill) export(ojo_fiscal_year) diff --git a/R/ojo_create_project.R b/R/ojo_create_project.R new file mode 100644 index 0000000..d5f6443 --- /dev/null +++ b/R/ojo_create_project.R @@ -0,0 +1,29 @@ +#' @title Create Project +#' @description Create a new project +#' +#' @param name Name of the project +#' +#' @export +#' @returns +#' +ojo_create_project <- function(name, ..., .private = TRUE) { + # fs::dir_create("./test/") + # fs::file_create("./test/test.txt") + + + project_dir <- fs::dir_create(name) + + usethis::create_project(project_dir, rstudio = TRUE, open = FALSE) + + setwd(project_dir) + + usethis::use_readme_rmd() + usethis::use_gpl3_license() + renv::init(bare = TRUE) + + usethis::use_git(message = "Initial commit") + usethis::use_github( + organisation = "openjusticeok", + private = .private + ) +} \ No newline at end of file diff --git a/man/ojo_arrests.Rd b/man/ojo_arrests.Rd index 1d57926..e8b1f26 100644 --- a/man/ojo_arrests.Rd +++ b/man/ojo_arrests.Rd @@ -19,8 +19,10 @@ Query the Open Justice Oklahoma database for jail records from Tulsa County. \examples{ \dontrun{ ojo_arrests() -ojo_arrests(years = 2019:2022, - include_charges = TRUE) +ojo_arrests( + years = 2019:2022, + include_charges = TRUE +) } } diff --git a/man/ojo_create_project.Rd b/man/ojo_create_project.Rd new file mode 100644 index 0000000..82d31c9 --- /dev/null +++ b/man/ojo_create_project.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ojo_create_project.R +\name{ojo_create_project} +\alias{ojo_create_project} +\title{Create Project} +\usage{ +ojo_create_project(name) +} +\arguments{ +\item{name}{Name of the project} +} +\description{ +Create a new project +} diff --git a/renv.lock b/renv.lock index 1de02db..58cecb8 100644 --- a/renv.lock +++ b/renv.lock @@ -4,7 +4,7 @@ "Repositories": [ { "Name": "CRAN", - "URL": "https://cran.rstudio.com" + "URL": "https://cloud.r-project.org" } ] }, @@ -632,6 +632,34 @@ "Hash": "7c89603d81793f0d5486d91ab1fc6f1d", "Requirements": [] }, + "furrr": { + "Package": "furrr", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "da7a4c32196cb2262a41dd5a25d486ff", + "Requirements": [ + "future", + "globals", + "lifecycle", + "purrr", + "rlang", + "vctrs" + ] + }, + "future": { + "Package": "future", + "Version": "1.31.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f3f0fbe5ce9b77c002f8c5170790538a", + "Requirements": [ + "digest", + "globals", + "listenv", + "parallelly" + ] + }, "generics": { "Package": "generics", "Version": "0.1.3", @@ -698,6 +726,16 @@ "Hash": "ab08ac61f3e1be454ae21911eb8bc2fe", "Requirements": [] }, + "globals": { + "Package": "globals", + "Version": "0.16.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "baa9585ab4ce47a9f4618e671778cc6f", + "Requirements": [ + "codetools" + ] + }, "glue": { "Package": "glue", "Version": "1.6.2", @@ -926,6 +964,14 @@ "xmlparsedata" ] }, + "listenv": { + "Package": "listenv", + "Version": "0.9.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4fbd3679ec8ee169ba28d4b1ea7d0e8f", + "Requirements": [] + }, "lubridate": { "Package": "lubridate", "Version": "1.9.0", @@ -1031,6 +1077,14 @@ "askpass" ] }, + "parallelly": { + "Package": "parallelly", + "Version": "1.34.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2a795ec0ddbfe465ca0d6471039631bf", + "Requirements": [] + }, "pillar": { "Package": "pillar", "Version": "1.8.1", @@ -1304,9 +1358,9 @@ "renv": { "Package": "renv", "Version": "0.16.0", - "OS_type": NA, - "Repository": "CRAN", "Source": "Repository", + "Repository": "CRAN", + "Hash": "c9e8442ab69bc21c9697ecf856c1e6c7", "Requirements": [] }, "rex": { diff --git a/tests/testthat/test-ojo_create_project.R b/tests/testthat/test-ojo_create_project.R new file mode 100644 index 0000000..bf8a902 --- /dev/null +++ b/tests/testthat/test-ojo_create_project.R @@ -0,0 +1,7 @@ +test_that("creating a project works", { + withr::with_tempdir({ + expect_no_error(ojo_create_project("test_project")) + # expect_true(fs::dir_exists("./test/")) + # expect_true(fs::file_exists("./test/test.txt")) + }) +}) From 0a2529de2835c6b05590a2d543e0932c2b486a8b Mon Sep 17 00:00:00 2001 From: Brancen Gregory Date: Thu, 2 Mar 2023 21:34:55 -0500 Subject: [PATCH 2/2] Cleanup feature branch --- man/ojo_arrests.Rd | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 man/ojo_arrests.Rd diff --git a/man/ojo_arrests.Rd b/man/ojo_arrests.Rd deleted file mode 100644 index e8b1f26..0000000 --- a/man/ojo_arrests.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ojo_arrests.R -\name{ojo_arrests} -\alias{ojo_arrests} -\title{Query arrests from ojodb jail data tables} -\usage{ -ojo_arrests( - county = "TULSA", - years = 2018:lubridate::year(Sys.Date()), - include_charges = FALSE -) -} -\value{ -data, a lazy tibble containing the resulting jail data -} -\description{ -Query the Open Justice Oklahoma database for jail records from Tulsa County. -} -\examples{ -\dontrun{ -ojo_arrests() -ojo_arrests( - years = 2019:2022, - include_charges = TRUE -) -} - -}