From b0f7ff98c7cfa635651a42ab51faad900a8bc5cd Mon Sep 17 00:00:00 2001 From: Tomer Date: Wed, 25 Jan 2023 11:12:46 +0100 Subject: [PATCH] change: tests --- .Rbuildignore | 2 ++ .Rprofile | 0 R/google_translate.R | 9 ++++++--- build_package.R | 8 +++++--- man/google_translate.Rd | 9 ++++++--- renv/.gitignore | 6 ++++++ tests/testthat/test-google_translate.R | 4 ++-- tests/testthat/test-mymemory_translate.R | 4 ++-- 8 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 .Rprofile create mode 100644 renv/.gitignore diff --git a/.Rbuildignore b/.Rbuildignore index 21dfc13..064d6ef 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ +^renv$ +^renv\.lock$ ^LICENSE\.md$ ^.*\.Rproj$ ^\.Rproj\.user$ diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..e69de29 diff --git a/R/google_translate.R b/R/google_translate.R index f1c7ab8..a373b95 100644 --- a/R/google_translate.R +++ b/R/google_translate.R @@ -1,8 +1,11 @@ #' Translate text using google translate #' -#' @param text Text to translate. -#' @param target_language Language to translate text to. -#' @param source_language Language to translate text from +#' @param text This is the text that you want to translate. +#' @param target_language This is the language that you want to translate the text into. +#' The default value for this argument is "en" for English. +#' @param source_language This is the language of the text that you want to translate. +#' The default value for this argument is "auto", +#' which means that the function will try to automatically detect the language of the text. #' #' @return Translated text. #' @export diff --git a/build_package.R b/build_package.R index 35cc851..7fe82a3 100644 --- a/build_package.R +++ b/build_package.R @@ -1,3 +1,4 @@ +options(repos = c(PkgMgr="https://packagemanager.rstudio.com/all/__linux__/focal/latest")) ## Set project name package_name <- basename(rstudioapi::getActiveProject()) ## =============================================== ============================== @@ -7,11 +8,13 @@ build_packages <- c("devtools", "renv", "qpdf") + ## install the packages that are not installed yet lapply(build_packages[which(!build_packages %in% installed.packages())], install.packages) + ## load the packages invisible(lapply(build_packages, library, @@ -25,14 +28,13 @@ invisible(lapply(build_packages, ## Check if the package is correct and can be built. devtools::document() devtools::check(manual = T) -devtools::build_manual(path = ".") - +devtools::build_manual(path = "~/Downloads/") ## Increment the version number and check in that change in Git usethis::use_version() ## Build the package, and release it to the correct folder -devtools::build(path = "../../../Downloads/") +devtools::build(path = "~/Downloads/") ## Make use of the development version again usethis::use_dev_version() diff --git a/man/google_translate.Rd b/man/google_translate.Rd index 150239b..663049a 100644 --- a/man/google_translate.Rd +++ b/man/google_translate.Rd @@ -7,11 +7,14 @@ google_translate(text, target_language = "en", source_language = "auto") } \arguments{ -\item{text}{Text to translate.} +\item{text}{This is the text that you want to translate.} -\item{target_language}{Language to translate text to.} +\item{target_language}{This is the language that you want to translate the text into. +The default value for this argument is "en" for English.} -\item{source_language}{Language to translate text from} +\item{source_language}{This is the language of the text that you want to translate. +The default value for this argument is "auto", +which means that the function will try to automatically detect the language of the text.} } \value{ Translated text. diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000..275e4ca --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,6 @@ +library/ +local/ +cellar/ +lock/ +python/ +staging/ diff --git a/tests/testthat/test-google_translate.R b/tests/testthat/test-google_translate.R index 55e7084..98d8841 100644 --- a/tests/testthat/test-google_translate.R +++ b/tests/testthat/test-google_translate.R @@ -1,5 +1,5 @@ test_that("translation works", { - expect_equal(google_translate("hello world", + expect_equal(google_translate("hello", target_language = "es"), - "Hola Mundo") + "Hola") }) diff --git a/tests/testthat/test-mymemory_translate.R b/tests/testthat/test-mymemory_translate.R index 49fedd6..3d3bed8 100644 --- a/tests/testthat/test-mymemory_translate.R +++ b/tests/testthat/test-mymemory_translate.R @@ -1,6 +1,6 @@ test_that("translation workds", { - expect_equal(mymemory_translate(text = "Hello World", + expect_equal(mymemory_translate(text = "Hello", target_language = "es", source_language = "en"), - "Hola Mundo") + "Hola") })