Skip to content

Commit 5124dd8

Browse files
committed
fix: rewrite checkbox string extraction to be case insensitive
1 parent d4ae7eb commit 5124dd8

1 file changed

Lines changed: 32 additions & 28 deletions

File tree

R/create_listobject.R

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,64 @@
11
#' Reads in issues from GitHub and create rmds
2-
#'
2+
#'
33
#' Some of the GitHub issues in catalog are tagged as "submission".
44
#' These issues are filtered and parsed then used to build catalog rmds.
55
#' Each rmd will represent a catalog index
6-
#'
6+
#'
77
#' @param issuenum value. manually entered to select issue for parsing (Default = NULL, all issues will be parsed)
8-
#'
9-
#' @return
8+
#'
9+
#' @return
1010

1111
create_listobject <- function(parsedIssue) {
12-
1312
### Generate listobject using gh_parser
1413
listobject <- list()
1514
listobject$dataname <- parsedIssue$`### Data Name (This will be the displayed title in Catalog)`
1615
listobject$indicatorname <- parsedIssue$`### Indicator Name (as exists in ecodata)`
1716
listobject$description <- parsedIssue$`### Data Description`
18-
19-
## Parse checkboxes
17+
18+
## Parse checkboxes
2019
family <- parsedIssue$`### Family (Which group is this indicator associated with?)`
21-
members <- unlist(stringr::str_extract_all(family,"- \\[X\\]\\s+[a-zA-z ,]+"))
22-
members <- paste0(members,"\r\n",collapse="")
23-
20+
members <- unlist(stringr::str_extract_all(
21+
family,
22+
stringr::regex("- \\[X\\]\\s+[a-zA-z ,]+", ignore_case = T)
23+
))
24+
members <- paste0(members, "\r\n", collapse = "")
25+
2426
listobject$family <- members
2527
listobject$contributors <- parsedIssue$`### Data Contributors`
2628
listobject$affiliations <- parsedIssue$`### Affiliation`
2729
listobject$whatsthis <- parsedIssue$`### Introduction to Indicator (Please explain your indicator)`
2830
listobject$visualizations <- parsedIssue$`### Key Results and Visualization`
2931
listobject$indicatorStatsSpatial <- parsedIssue$`### Spatial Scale`
3032
listobject$indicatorStatsTemporal <- parsedIssue$`### Temporal Scale`
31-
32-
## Parse checkboxes
33-
synthesis <- parsedIssue$`### Synthesis Theme`
34-
members <- unlist(stringr::str_extract_all(synthesis,"- \\[X\\]\\s+[a-zA-z ,]+"))
35-
members <- paste0(members,"\r\n",collapse="")
36-
33+
34+
## Parse checkboxes
35+
synthesis <- parsedIssue$`### Synthesis Theme`
36+
members <- unlist(stringr::str_extract_all(
37+
synthesis,
38+
stringr::regex("- \\[X\\]\\s+[a-zA-z ,]+", ignore_case = T)
39+
))
40+
members <- paste0(members, "\r\n", collapse = "")
41+
3742
listobject$synthesisTheme <- members
3843
listobject$implications <- parsedIssue$`### Implications`
3944
listobject$poc <- parsedIssue$`### Point(s) of Contact`
4045
listobject$defineVariables <- parsedIssue$`### Define Variables`
41-
42-
43-
## Parse checkboxes
44-
indicator <- parsedIssue$`### Indicator Category`
45-
members <- unlist(stringr::str_extract_all(indicator,"- \\[X\\]\\s+[a-zA-z ,]+"))
46-
members <- paste0(members,"\r\n",collapse="")
47-
48-
46+
47+
## Parse checkboxes
48+
indicator <- parsedIssue$`### Indicator Category`
49+
members <- unlist(stringr::str_extract_all(
50+
indicator,
51+
stringr::regex("- \\[X\\]\\s+[a-zA-z ,]+", ignore_case = T)
52+
))
53+
members <- paste0(members, "\r\n", collapse = "")
54+
4955
listobject$indicatoryCategory <- members
5056
listobject$other <- parsedIssue$`### If other, please specify indicator category`
5157

5258
listobject$publicAvailability <- parsedIssue$`### Public Availability`
5359
listobject$accessibility <- parsedIssue$`### Accessibility and Constraints`
5460
listobject$primaryContact <- parsedIssue$`### Primary Contact`
5561
listobject$secondaryContact <- parsedIssue$`### Secondary Contact`
56-
57-
58-
return(listobject)
5962

60-
}
63+
return(listobject)
64+
}

0 commit comments

Comments
 (0)