20
20
21
21
if (! require(devtools )) install.packages(" devtools" )
22
22
devtools :: install_dev_deps()
23
- library(tidyverse )
23
+ library(stringr )
24
+ library(dplyr )
25
+ library(purrr )
24
26
library(lubridate )
25
27
library(glue )
26
28
library(assertr )
@@ -30,7 +32,7 @@ library(yaml)
30
32
31
33
session_details <-
32
34
yaml.load_file(here :: here(" _data" , " events.yml" )) %> %
33
- map_dfr(as.tibble ) %> %
35
+ map_dfr(as_tibble ) %> %
34
36
arrange(date ) %> %
35
37
# drop sessions that are not set (NA in date)
36
38
filter(! is.na(date )) %> %
@@ -41,7 +43,7 @@ session_details <-
41
43
location_url = na_if(location_url , " " ),
42
44
location_string = case_when(
43
45
# if both location and url are included!is.na(location) &
44
- ! is.na(location_url ) ~ glue :: glue (" [{location}]({location_url})" ),
46
+ ! is.na(location_url ) ~ glue(" [{location}]({location_url})" ),
45
47
# if only location is included!is.na(location) &
46
48
is.na(location_url ) ~ location ,
47
49
# if neither location nor url are included
@@ -50,7 +52,7 @@ session_details <-
50
52
51
53
coffee_code_details <-
52
54
yaml.load_file(here :: here(" _data" , " coffee-code.yml" )) %> %
53
- map_dfr(as.tibble ) %> %
55
+ map_dfr(as_tibble ) %> %
54
56
arrange(date ) %> %
55
57
# drop sessions that are not set (NA in date)
56
58
filter(! is.na(date )) %> %
@@ -87,6 +89,13 @@ new_coffee_code <- keep_only_new(coffee_code_details)
87
89
# Create files in _posts/ -------------------------------------------------
88
90
# Adds the new sessions/events to the _posts folder.
89
91
92
+ # Format as eg August 23
93
+ day_month <- function (.date , add_name = TRUE ) {
94
+ date_format <- " %B %e" # as August 23
95
+ if (add_name ) date_format <- " %A, %B %e" # as Monday, August 23
96
+ trimws(format(as.Date(.date ), format = date_format ))
97
+ }
98
+
90
99
create_new_posts_with_content <- function (.data ) {
91
100
new_post_filenames <-
92
101
glue_data(.data , " {here::here('_posts')}/{date}-{key}.md" )
@@ -124,17 +133,12 @@ create_new_posts_with_content <- function(.data) {
124
133
create_new_posts_with_content(new_sessions )
125
134
create_new_posts_with_content(new_coffee_code )
126
135
127
-
128
-
129
-
130
-
131
136
# Create a GitHub Issue of the session ------------------------------------
132
137
133
138
post_gh_issue <- function (title , body , labels ) {
134
139
# Will need to set up a GitHub PAT via (I think) the function
135
140
# devtools::github_pat() in the console.
136
- # devtools:::rule("Posting GitHub Issues")
137
- cat(" Posting `" , title , " `\n\n " )
141
+ cat(" \n\n Posting `" , title , " `\n\n " )
138
142
if (! devtools ::: yesno(" Are you sure you want to post this event as an Issue?" )) {
139
143
gh :: gh(
140
144
" POST /repos/:owner/:repo/issues" ,
@@ -152,13 +156,6 @@ post_gh_issue <- function(title, body, labels) {
152
156
}
153
157
}
154
158
155
- # Format as eg August 23
156
- day_month <- function (.date , add_name = TRUE ) {
157
- date_format <- " %B %e" # as August 23
158
- if (add_name ) date_format <- " %A, %B %e" # as Monday, August 23
159
- trimws(format(as.Date(.date ), format = date_format ))
160
- }
161
-
162
159
gh_issue_info_event <- function (.data ) {
163
160
content <- .data %> %
164
161
mutate(needs_packages = ifelse(
@@ -214,7 +211,6 @@ gh_issue_info_coffee_code <- function(.data) {
214
211
select(title , content , gh_labels )
215
212
}
216
213
217
-
218
214
create_gh_issues_coffee_code <- function (.data ) {
219
215
.data %> %
220
216
gh_issue_info_coffee_code() %> %
@@ -229,5 +225,3 @@ create_gh_issues_events <- function(.data) {
229
225
230
226
create_gh_issues_coffee_code(new_coffee_code )
231
227
create_gh_issues_events(new_sessions )
232
-
233
-
0 commit comments