Skip to content

Commit

Permalink
Deprecate everyone_but() (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgallou committed Nov 28, 2023
1 parent 495958a commit c94830d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# plume (development version)

* Deprecated `everyone_but()` as this function is not necessary since not more than a couple of authors should normally be given a particular status (#44).

* Removed stringb dependency in favour of stringr (#42).

* The `by` parameter in `$set_*()` methods is now deprecated in favour of `.by` (#41).
Expand Down
16 changes: 8 additions & 8 deletions R/context-selectors.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#' @title Select all authors or exclude some from a selection
#' @description Selection helpers to use in conjonction with `set_*()` methods:
#' @description Selection helpers to use in conjonction with status setter
#' methods (i.e. methods that assign a status to authors with either `TRUE`
#' or `FALSE`):
#' * [`everyone()`] select all authors.
#' * [`everyone_but()`] select all but specific authors.
#' * [`everyone_but()`] `r lifecycle::badge("deprecated")` this function was
#' deprecated as I believe it is not necessary since not more than a couple of
#' authors should normally be given a particular status.
#' @examples
#' aut <- Plume$new(encyclopedists)
#'
#' aut$set_corresponding_authors(everyone())
#' aut$get_plume() |> dplyr::select(1:3, corresponding)
#'
#' aut$set_corresponding_authors(
#' everyone_but(jean),
#' .by = "given_name"
#' )
#' aut$get_plume() |> dplyr::select(1:3, corresponding)
#' @export
everyone <- function() {
binder$pull()
}

#' @rdname everyone
#' @keywords internal
#' @param ... One or more unquoted expressions separated by commas. Expressions
#' matching values in the column defined by the `by` parameter of `set_*()`
#' methods are used to set a given status to authors. Matching of values is
#' case-insensitive.
#' @export
everyone_but <- function(...) {
lifecycle::deprecate_warn("0.2.0", "everyone_but()")
out <- binder$pull()
discard(out, enexprs(...))
}
15 changes: 7 additions & 8 deletions man/everyone.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/testthat/_snaps/set-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
! `everyone()` must be used within a *status setter* method.
Code
(expect_error(everyone_but()))
Condition
Warning:
`everyone_but()` was deprecated in plume 0.2.0.
Output
<error/rlang_error>
Error:
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-set-status.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_that("sets status to selected authors", {
}, rep(TRUE, 3))

expect_equal({
withr::local_options(lifecycle_verbosity = "quiet")
aut$set_corresponding_authors(everyone_but(ric), .by = "given_name")
aut$get_plume()$corresponding
}, c(TRUE, FALSE, TRUE))
Expand Down
7 changes: 0 additions & 7 deletions vignettes/plume.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,6 @@ aut$set_corresponding_authors(everyone())
aut
```

Or its variant `everyone_but()` to assign `TRUE` to all but specific authors:

```{r}
aut$set_corresponding_authors(everyone_but(jean), .by = "given_name")
aut
```

## Getting author information

`get_*()` methods format author information into character vectors. This is useful if you want to output author data in a document without using journal templates.
Expand Down

0 comments on commit c94830d

Please sign in to comment.