Skip to content

Commit

Permalink
Add support for authors' degrees field (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgallou authored Aug 30, 2024
1 parent b8e7976 commit fa0656b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 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)

* `PlumeQuarto` now supports authors' `degrees` field (#53).

* `PlumeQuarto` now properly handles authors with no roles (#81).

* `PlumeQuarto` now supports `.yml` and `.yaml` files (#82).
Expand Down
2 changes: 1 addition & 1 deletion R/plume-handler.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ PlumeHandler <- R6Class(
},

get_vars = function() {
nestables <- private$pick("affiliation", "note")
nestables <- private$pick("affiliation", "note", "degree")
if (!private$crt) {
nestables <- c(nestables, private$pick("role"))
}
Expand Down
17 changes: 12 additions & 5 deletions R/plume-quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
number = "number",
dropping_particle = "dropping_particle",
acknowledgements = "acknowledgements"
),
nestables = list(
degree = "degree"
)
))

Expand Down Expand Up @@ -128,9 +131,10 @@ PlumeQuarto <- R6Class(
fax = private$pull("fax"),
orcid = private$author_orcids(),
note = private$author_notes(),
degrees = private$itemise("degree"),
acknowledgements = private$pull("acknowledgements"),
attributes = private$author_attributes(),
roles = private$author_roles(),
roles = private$itemise("role", to_lower = TRUE),
metadata = private$author_metadata(),
affiliations = private$author_affiliations()
)
Expand All @@ -152,8 +156,8 @@ PlumeQuarto <- R6Class(
out
},

author_roles = function() {
private$pull_nestable("role", as_role_list)
itemise = function(var, to_lower = FALSE) {
private$pull_nestable(var, \(x) itemise(x, to_lower))
},

author_notes = function() {
Expand Down Expand Up @@ -237,8 +241,11 @@ PlumeQuarto <- R6Class(
)
)

as_role_list <- function(x) {
list(tolower(vec_drop_na(x)))
itemise <- function(x, to_lower = FALSE) {
if (to_lower) {
x <- tolower(x)
}
list(vec_drop_na(x))
}

affiliation_keys <- c(
Expand Down

0 comments on commit fa0656b

Please sign in to comment.