Skip to content

Commit

Permalink
Switch to glue_collapse(). Closes #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed May 10, 2019
1 parent 99f8192 commit bc32487
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Depends:
R (>= 2.10)
Imports:
crayon (>= 1.3.4),
glue (>= 1.2.0),
glue (>= 1.3.1),
httr (>= 1.3.1),
jsonlite (>= 1.5),
tibble (>= 1.4.2),
Expand Down
16 changes: 8 additions & 8 deletions R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assert_x_is_length <- function(x, x_name, length) {
assert_x_inherits <- function(x, x_name, class) {
has_class <- inherits(x, class)
if(!has_class) {
classes <- glue::collapse(green(class(x)), ", ")
classes <- glue::glue_collapse(green(class(x)), ", ")
correct_class <- yellow(class)
glue_stop("{x_name} must be {correct_class}. You have passed in a: {classes}")
}
Expand All @@ -21,8 +21,8 @@ assert_x_inherits <- function(x, x_name, class) {
assert_x_inherits_one_of <- function(x, x_name, classes) {
has_one_of_classes <- any(class(x) %in% classes)
if(!has_one_of_classes) {
x_classes <- glue::collapse(green(class(x)), ", ")
correct_classes <- glue::collapse(yellow(classes), ", ", last = ", or ")
x_classes <- glue::glue_collapse(green(class(x)), ", ")
correct_classes <- glue::glue_collapse(yellow(classes), ", ", last = ", or ")
glue_stop("{x_name} must be {correct_classes}. You have passed in a: {x_classes}")
}
}
Expand Down Expand Up @@ -85,7 +85,7 @@ assert_resample_freq_is_granular <- function(resample_frequency) {
is_valid_freq <- resample_frequency %in% valid_freq
if(!is_valid_freq) {
user_freq <- green(resample_frequency)
correct_freq <- glue::collapse(yellow(valid_freq), ", ", last = ", or ")
correct_freq <- glue::glue_collapse(yellow(valid_freq), ", ", last = ", or ")
glue_stop("resample_frequency must be {correct_freq}. You have passed in: {user_freq}")
}
}
Expand All @@ -96,8 +96,8 @@ assert_resample_freq_is_fine <- function(resample_frequency) {

if(!has_valid_base) {
user_freq <- green(resample_frequency)
correct_base <- glue::collapse(yellow(valid_base), ", or ")
correct_freq <- glue::collapse(yellow(c("1min", "5min", "1hour")), ", ", last = ", or ")
correct_base <- glue::glue_collapse(yellow(valid_base), ", or ")
correct_freq <- glue::glue_collapse(yellow(c("1min", "5min", "1hour")), ", ", last = ", or ")
glue_stop("resample_frequency is only valid for {correct_base}, and must be formatted similar to {correct_freq}. ",
"You have passed in: {user_freq}.")
}
Expand All @@ -109,8 +109,8 @@ assert_resample_freq_is_crypto <- function(resample_frequency) {

if(!has_valid_base) {
user_freq <- green(resample_frequency)
correct_base <- glue::collapse(yellow(valid_base), ", or ")
correct_freq <- glue::collapse(yellow(c("1min", "5min", "1hour", "2day")), ", ", last = ", or ")
correct_base <- glue::glue_collapse(yellow(valid_base), ", or ")
correct_freq <- glue::glue_collapse(yellow(c("1min", "5min", "1hour", "2day")), ", ", last = ", or ")
glue_stop("resample_frequency is only valid for {correct_base}, and must be formatted similar to {correct_freq}. ",
"You have passed in: {user_freq}.")
}
Expand Down
6 changes: 3 additions & 3 deletions R/news.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# assert_x_inherits(offset, "offset", "numeric")
#
# # Collapse vector of characters to single character
# ticker <- glue::collapse(ticker, ",")
# if(length(tags) > 1L) tags <- glue::collapse(tags, ",")
# if(length(source) > 1L) source <- glue::collapse(source, ",")
# ticker <- glue::glue_collapse(ticker, ",")
# if(length(tags) > 1L) tags <- glue::glue_collapse(tags, ",")
# if(length(source) > 1L) source <- glue::glue_collapse(source, ",")
#
# # Construct url
# riingo_url <- construct_url(
Expand Down
2 changes: 1 addition & 1 deletion R/prices.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ riingo_crypto_prices <- function(ticker, start_date = NULL, end_date = NULL,
endpoint <- "prices"

# For crypto, tickers are passed as a comma separated parameter
ticker <- glue::collapse(ticker, ",")
ticker <- glue::glue_collapse(ticker, ",")

# URL construction
riingo_url <- construct_url(
Expand Down
2 changes: 1 addition & 1 deletion R/quote.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ riingo_crypto_quote <- function(ticker, exchanges = NULL, convert_currency = NUL
endpoint <- "quote"

# For crypto, tickers are passed as a comma separated parameter
ticker <- glue::collapse(ticker, ",")
ticker <- glue::glue_collapse(ticker, ",")

# URL construction
riingo_url <- construct_url(
Expand Down
2 changes: 1 addition & 1 deletion R/url_constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ as_http_parameter_string <- function(..., type) {
# Remove any params that were NULL and should use Tiingo defaults
http_params <- http_params[which(http_params != "")]

glue::collapse(http_params, sep = "&", last = "")
glue::glue_collapse(http_params, sep = "&", last = "")
}


Expand Down

0 comments on commit bc32487

Please sign in to comment.