Skip to content

Commit

Permalink
correct some typos and improved status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Nov 2, 2023
1 parent 1984544 commit e933273
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: paperboy
Title: Comprehensive Collection of News Media Scrapers
Version: 0.0.5.9000
Date: 2023-10-26
Date: 2023-11-02
Authors@R:
person(given = "Johannes B.",
family = "Gruber",
Expand Down
2 changes: 1 addition & 1 deletion R/deliver.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pb_deliver.data.frame <- function(x, try_default = TRUE, verbose = NULL, ...) {
ws <- mget(ls(inform_now_env), envir = inform_now_env)
if (length(ws) > 0) {
names(ws) <- rep("i", length(ws))
cli::cli_warn(ws)
cli::cli_alert_warning(ws)
rm(list = ls(inform_now_env), envir = inform_now_env)
}

Expand Down
2 changes: 1 addition & 1 deletion R/deliver_ad_nl.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pb_deliver_paper.ad_nl <- function(x, verbose = NULL, pb, ...) {
)

} else {
warn_once(x$domain)

if (is.null(inform_now_env$block)) {
cli::cli_alert_warning("Some articles are not present as they were blocked by a privacy gate")
}
Expand Down
2 changes: 1 addition & 1 deletion R/rss.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' }
pb_collect_rss <- function(x, ...) {
if (!methods::is(x, "html_content")) {
df <- pb_collect(x, pb_collect_rss = FALSE, ...)
df <- pb_collect(x, collect_rss = FALSE, ...)
x <- unlist(df[df$status < 400L, "content_raw"])
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pb_tick <- function(x, verbose, pb) {
#' @noRd
warn_once <- function(id) {
if (is.null(inform_env[[id]])) {
inform_now_env[[id]] <- cli::format_warning("No parser for domain {.strong {id}} yet, attempting generic approach.")
inform_now_env[[id]] <- cli::format_message("No parser for domain {.strong {id}} yet, attempting generic approach.")
inform_env[[id]] <- TRUE
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/utils_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ use_new_parser <- function(x,
cli::cli_progress_step(
"Checking parser {r_file} for consistency",
msg_done = "{r_file} passed tests!",
msg_failed = "{r_file} did not passe tests."
msg_failed = "{r_file} did not pass tests."
)

if (is.null(test_data) && is.na(rss)) {
Expand Down Expand Up @@ -194,7 +194,7 @@ pb_new <- function(np, author = "", issue = "") {
readLines() %>%
gsub("{{newspaper}}", np_, x = ., fixed = TRUE)

p <- ifelse(is_pb(), "./R", "")
p <- ifelse(is_pb(), "./R", ".")
f <- file.path(p, paste0("deliver_", np_, ".R"))
if (!file.exists(f)) writeLines(template, f)

Expand Down
11 changes: 11 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ Guide’s
Lifecycle
Nutzungsbedingungen
POSIXct
ac
aktualne
anotherangryvoice
bbc
blesk
blogspot
boston
bostonglobe
Expand All @@ -15,13 +18,15 @@ buzzfeed
cbsileads
cbslnk
cbsnews
ceskatelevize
cnet
cnn
com
csv
cz
dailymail
datetime
denikn
doctype
eu
evolvepolitics
Expand All @@ -32,11 +37,14 @@ foxbusiness
foxnews
ftw
geenstijl
hn
huffingtonpost
huffpost
idnes
irozhlas
itemscope
latimes
lidovky
lnk
marketwatch
mediacloud
Expand All @@ -46,12 +54,15 @@ msnbc
newsweek
nl
nos
novinky
nrc
nypost
nytimes
org
pagesix
parlamentnilisty
pb
seznamzpravy
sfgate
skwawkbox
stri
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-deliver.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
test_that("Test infrascture", {
expect_warning(
expect_message(
pb_deliver("google.com", verbose = TRUE),
"No parser for domain"
)
# only warn first time
expect_no_warning(
expect_no_message(
pb_deliver("google.com", verbose = TRUE)
)
# still warn with new site
expect_warning(
expect_message(
pb_deliver("duckduckgo.com/", verbose = TRUE),
"No parser for domain"
)
Expand Down

0 comments on commit e933273

Please sign in to comment.