Last year I have written a BaseX client in R (https://github.com/BaseXdb/basex/tree/master/basex-api/src/main/r) and now I am trying to build a package for this driver.
The driver is built, using the R6 system. I added these directives to RbaseXClient.R
:
#' @title RbaseX
#' @docType package
#' @name RbaseX
#' @description BaseX is a robust, high-performance XML database engine and a highly compliant XQuery 3.1 processor with full support of the W3C Update and Full Text extensions.
#'
#' @importFrom magrittr %>%
#' @import dplyr
#' @import utils
#' @import R6
#' @import stringr
#' @import openssl
#' @export
The driver is initialized with this code:
initialize = function(host, port, username, password) {
private$sock <- socketConnection(host = "localhost", port = 1984L,
open = "w+b", server = FALSE, blocking = TRUE, encoding = "utf-8")
private$response <- self$str_receive()
splitted <-strsplit(private$response, "\\:")
ifelse(length(splitted[[1]]) > 1,
{ code <- paste(username, splitted[[1]][1],password, sep=":")
nonce <- splitted[[1]][2]},
{ code <- password
nonce <- splitted[[1]][1]
}
)
code <- md5(paste(md5(code), nonce, sep = ""))
class(code) <- "character"
private$void_send(username)
private$void_send(code)
if (!self$bool_test_sock()) stop("Access denied")}
In line 4 self$str_receive
uses the magrittr pipe-operator %>%
. str_receive
is defined as a public method.
The same pipe-operator is used in the private void_send
(line 15) method but there I get this error:
Error in c(streamOut, c(0)) %>% as.raw() : could not find function "%>%"
How can I make the pipe-operator (and all the other imports) available to the private methods?
Ben