Skip to content

Commit

Permalink
Merge pull request #3 from kiwiroy/subscript-oob-error
Browse files Browse the repository at this point in the history
Subscript out of bounds error
  • Loading branch information
kiwiroy committed Jul 5, 2019
2 parents 688cfe1 + fff9771 commit 70aef73
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -30,9 +30,9 @@ after_success:
- test $TRAVIS_R_VERSION_STRING = "release" && Rscript -e 'Sys.setenv("R_COVR_SRCDIR"=here::here()); covr::coveralls()'

before_deploy:
# - which perlbrew
# - which cpanm
# - perlbrew list
- which perlbrew
- which cpanm
- perlbrew list
- Rscript -e 'withr::with_temp_libpaths(action = "prefix", code = { devtools::install(pkg = ".", reload = FALSE); pkgdown::build_site(pkg = "."); })'
- touch gh-pages/.nojekyll

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: perlbrewr
Title: Integrates Perlbrew With R, Specifically (knitr & rmarkdown)
Version: 0.0.0.9000
Version: 0.0.1.9000
Authors@R: c(
person("Roy", "Storey", email = "kiwiroy@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1375-7136")))
Description: The goal of perlbrewr is to assist the loading of a perlbrew
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# perlbrewr 0.0.1.9000

* Resolved subscript out of bound error (#3)

# perlbrewr 0.0.0.9000

* Added a `NEWS.md` file to track changes to the package.
Expand Down
4 changes: 3 additions & 1 deletion R/knitr-shellwords.R
Expand Up @@ -80,7 +80,9 @@ shellwords <- function(x) {
)
)"
xo <- str_match_all(string = x, pattern = shellwords_re)

if (length(xo) == 0) {
return(character(0))
}
for (i in seq_along(xo[[1]][,1])) {
xo[[1]][i,7] <- NA
if(!is.na(xo[[1]][i,6]) && xo[[1]][i,6] != "") {
Expand Down
8 changes: 5 additions & 3 deletions README.Rmd
Expand Up @@ -106,9 +106,11 @@ cpanm -n -q --installdeps .
Since `perlbrewr::perlbrew` sets the `PERL5LIB` environment variable perl code
relying on the dependencies is now sucessful.
```{r perl-code-2, engine = "perl"}
use Mojo::Base -strict;
use Mojo::File;
say Mojo::File->new('inst/cpanfile')->slurp;
# use Mojo::Base -strict;
# use Mojo::File;
# say Mojo::File->new('inst/cpanfile')->slurp;
print "$^X\n";
print $ENV{PERL5LIB}, "\n";
```

### listing and creating libraries
Expand Down
15 changes: 9 additions & 6 deletions README.md
Expand Up @@ -76,25 +76,28 @@ Perlbrew supports [`local::lib`](https://metacpan.org/pod/local::lib) libraries
perlbrew(version = "5.24.0", lib = "example")
#> [1] TRUE
Sys.getenv("PERL5LIB")
#> [1] "/tmp/Rtmp9zMkiF/.perlbrew/libs/perl-5.24.0@example/lib/perl5"
#> [1] "/tmp/Rtmp1SMnAB/.perlbrew/libs/perl-5.24.0@example/lib/perl5"
```

Within this `local::lib` modules may be installed with [`cpanm`](https://metacpan.org/pod/App::cpanminus).

``` bash
cd inst
cpanm -n -q --installdeps .
#> Successfully installed Mojolicious-8.13
#> Successfully installed Mojolicious-8.18
#> 1 distribution installed
```

Since `perlbrewr::perlbrew` sets the `PERL5LIB` environment variable perl code relying on the dependencies is now sucessful.

``` perl
use Mojo::Base -strict;
use Mojo::File;
say Mojo::File->new('inst/cpanfile')->slurp;
#> requires "Mojolicious" => '8.0';
# use Mojo::Base -strict;
# use Mojo::File;
# say Mojo::File->new('inst/cpanfile')->slurp;
print "$^X\n";
print $ENV{PERL5LIB}, "\n";
#> /software/programming/perlbrew-0.76/perls/perl-5.24.0/bin/perl
#> /tmp/Rtmp1SMnAB/.perlbrew/libs/perl-5.24.0@example/lib/perl5
```

### listing and creating libraries
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-90-regression.R
@@ -0,0 +1,6 @@
context("regression tests")

test_that("regression - handle NULL from knitr::opts_chunk$get('engine.opts')$perl ", {
words <- perlbrewr:::shellwords(x = NULL)
expect_equal(words, character(0))
})

0 comments on commit 70aef73

Please sign in to comment.