Skip to content

Commit

Permalink
Merge pull request #20 from mrcaseb/transition-to-curl-package
Browse files Browse the repository at this point in the history
Drop RCurl dependency and use curl instead
  • Loading branch information
clauswilke authored Jul 28, 2021
2 parents 0baa935 + 73c41fc commit 8c8fb73
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ License: MIT + file LICENSE
Depends:
R (>= 3.5)
Imports:
curl,
grid,
grDevices,
markdown,
rlang,
Rcpp,
RCurl,
png,
jpeg,
stringr,
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gridtext 0.1.4.9000

No changes yet.
- Transition to curl package and drop RCurl dependency

# gridtext 0.1.4

Expand Down
2 changes: 1 addition & 1 deletion R/read-image.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ read_image <- function(path) {

get_file <- function(path) {
if (is_url(path)) {
RCurl::getBinaryURL(path)
curl::curl_fetch_memory(path)$content
} else {
path
}
Expand Down
5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// bl_make_null_box
BoxPtr<GridRenderer> bl_make_null_box(double width_pt, double height_pt);
RcppExport SEXP _gridtext_bl_make_null_box(SEXP width_ptSEXP, SEXP height_ptSEXP) {
Expand Down
Binary file added tests/figs/test_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/testthat/test-get_file.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("get_file works", {
# skip test on cran because the url could be broken in the future
skip_on_cran()
# get_file returns raw data if it's an url and a character path if it's
# a local path. That's why we test it with the function read_image that calls it
expect_identical(
read_image("https://upload.wikimedia.org/wikipedia/commons/6/62/Biedronka.drs.png"),
read_image("../figs/test_image.png")
)
})

0 comments on commit 8c8fb73

Please sign in to comment.