The crunchdev package offers a number of convenience functions and RStudio addins to make developing crunch packages quicker and faster.
Highlights of CrunchDev include:
addins for quickly and easily specifying host, test type (unit vs integration), and file filters These make it quick and easy to run tests on specific files which speeds up how quickly you can see if those test pass or fail, and can get back into the code. It handles all of the logic for setting up hosts and authentication for integration tests so you don't have to change any configurations or options to run them. Test are run in a terminal within RStudio so they won't block any other processes or coding you might want to do.
easily change backends interactively with setupCrunch()
There are a number of backends that are useful to use in the process of developing Crunch packages. This function lets you change which backend you are configured to connect to (eg changes the crunch.email
, crunch.pw
, and crunch.api
options). No more fumbling with changing options or reloading R.
The pre-release version of the package can be pulled from GitHub using the devtools package:
# install.packages("devtools")
devtools::install_github("Crunch-io/crunchdev")
Before using crunchdev
there are a few options that should be added to your ~/.Rprofile
:
user.hosts
and test.hosts
the first uses user authentication, and the second uses test user authentication. Each list can have any number of hostnames and urls.crunchdev.user.hosts=c("stableapp" = "https://stableapp.crunch.io/api/"),
crunchdev.test.hosts=c(
"local" = "http://local.crunch.io/api/",
"testing server" = "https://testing.crunch.io/api/")
user.auth
and test.auth
the first is used for all hosts in crunchdev.user.hosts
, and the second is used for all hosts in crunchdev.test.hosts
. Each one should only contain one email and password.crunchdev.user.auth=c("email" = "magic.user@crunch.io",
"pw" = "t0pSecretP@ssw0rD"),
crunchdev.test.auth=c("email" = "magic.testuser@crunch.io",
"pw" = "t0pSecretP@ssw0rD")
.Rprofile
options(
crunchdev.user.auth=c("email" = "developer@crunch.io",
"pw" = "super_secre7_passw0rd"),
crunchdev.test.auth=c("email" = "tester@crunch.io",
"pw" = "passw0rd_wh1ch_1s_super_secre7"),
crunchdev.user.hosts=c("aleph" = "https://aleph.crunch.io/api/"),
crunchdev.test.hosts=c(
"bet" = "https://bet.crunch.io/api/",
"gimmel" = "https://gimmel.crunch.io/api/")
)
RStudio allows keyboard shortcuts to be bound to addins. The addins provided by crunchdev are designed to make iteration and test running quick and easy. Note: currently launching a terminal from RStudio requires installing rstudioapi from feature/terminal and requires RStudio version >= 1.1.331.
shift+alt+u
test-dataset-reference.R
active will prefill dataset-reference
in the filter box) Suggest key binding: shift+cmd+u
shift+cmd+i
logout()
before running devtools::load_all()
this cleans up interactive iteration and reloading of Crunch packages, Since the logout()
is run within try()
this addin should be safe to remap shift+cmd+l
globally.The repository includes a Makefile to facilitate some common tasks.
$ make test
. Requires the testthat package. You can also specify a specific test file or files to run by adding a "file=" argument, like $ make test file=logging
. test_package
will do a regular-expression pattern match within the file names. See its documentation in the testthat
package.
$ make doc
. Requires the roxygen2 package.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.