Skip to content

Commit ae2d160

Browse files
committed
using stringparser constructor
1 parent 78ba63f commit ae2d160

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Roxygen: list(markdown = TRUE)
1313
RoxygenNote: 7.3.2
1414
Imports:
1515
dplyr,
16-
parcr,
16+
parcr (>= 0.5.3),
1717
stats,
1818
stringr
1919
Suggests:

R/parse_datasheet.R

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,15 @@ Header <- function() {
104104
#' @param line A character string representing a line from the datasheet.
105105
#' @return A parsed comment as a string or an empty list if parsing fails.
106106
#' @noRd
107-
parse_comment <- function(line) {
108-
m <- stringr::str_match(line, comment_pattern)
109-
if (is.na(m[1])) {
110-
return(list()) # signal failure
111-
} else {
112-
return(m[2])
113-
}
114-
}
107+
parse_comment <- stringparser(comment_pattern)
115108

116109
#' Parse a Header Line
117110
#'
118111
#' Parses a header line based on the `header_pattern`.
119112
#' @param line A character string representing a line from the datasheet.
120113
#' @return A parsed header as a string or an empty list if parsing fails.
121114
#' @noRd
122-
parse_header <- function(line) {
123-
m <- stringr::str_match(line, header_pattern)
124-
if (is.na(m[1])) {
125-
return(list()) # signal failure
126-
} else {
127-
return(stringr::str_trim(m[2], side = "both"))
128-
}
129-
}
115+
parse_header <- stringparser(header_pattern, function(x) {stringr::str_trim(x[1], side = "both")})
130116

131117
#' Parse a Tab-Separated Line
132118
#'

0 commit comments

Comments
 (0)