datawookie / emayili

Compare 83e15d2 ... +9 ... a763589

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -22,6 +22,9 @@
Loading
22 22
#' @param encoding How content is transformed to ASCII. Options are
23 23
#'   \code{"7bit"}, \code{"quoted-printable"} and \code{"base64"}. Use \code{NA}
24 24
#'   or \code{NULL} for no (or "identity") encoding.
25 +
#' @param language Langauge of content. If \code{FALSE} then will not include
26 +
#'   language field. If \code{TRUE} then will attempt to auto-detect language.
27 +
#'   Otherwise will use the specified language.
25 28
#' @param boundary Boundary string.
26 29
#' @param type The MIME type of the content.
27 30
#' @param children List of child MIME objects.
@@ -69,6 +72,7 @@
Loading
69 72
  disposition = NA,
70 73
  charset = NA,
71 74
  encoding = NA,
75 +
  language = NA,
72 76
  format = NA,
73 77
  boundary = emayili:::hexkey(),
74 78
  type = NA,
@@ -87,6 +91,7 @@
Loading
87 91
      disposition = disposition,
88 92
      charset = charset,
89 93
      encoding = encoding,
94 +
      language = language,
90 95
      format = format,
91 96
      boundary = boundary,
92 97
      children = children,
@@ -318,6 +323,7 @@
Loading
318 323
    content_type(type, x$charset, x$boundary, x$format),
319 324
    content_disposition(x$disposition),
320 325
    content_transfer_encoding(x$encoding),
326 +
    content_language(x$language, x$content),
321 327
    x_attachment_id(x$cid),
322 328
    content_id(x$cid)
323 329
  )

@@ -218,3 +218,54 @@
Loading
218 218
    subject(paste0(subject_prefix, subject(msg)))
219 219
  if (get_option_invisible()) invisible(msg) else msg # nocov
220 220
}
221 +
222 +
#' Add or query comments of message.
223 +
#'
224 +
#' @param msg A message object.
225 +
#' @param comments Comments for the message.
226 +
#'
227 +
#' @return A message object or the comments of the message object (if \code{comments} is \code{NULL}).
228 +
#' @seealso \code{\link{subject}}
229 +
#' @export
230 +
#' @examples
231 +
#' # Create a message and set the comments.
232 +
#' msg <- envelope() %>% comments("This is a comment")
233 +
#'
234 +
#' # Retrieve the comments for a message.
235 +
#' comments(msg)
236 +
comments <- function(msg, comments = NULL) {
237 +
  if (is.null(comments)) {
238 +
    header_get(msg, "Comments")
239 +
  } else {
240 +
    msg <- header_set(msg, "Comments", comments, append = FALSE)
241 +
    if (get_option_invisible()) invisible(msg) else msg # nocov
242 +
  }
243 +
}
244 +
245 +
#' Add or query keywords of message.
246 +
#'
247 +
#' @param msg A message object.
248 +
#' @param ... Keywords.
249 +
#' @param append Whether to append or replace keywords.
250 +
#'
251 +
#' @return A message object or the comments of the message object (if \code{comments} is \code{NULL}).
252 +
#' @seealso \code{\link{to}}, \code{\link{from}}, \code{\link{cc}}, \code{\link{bcc}} and \code{\link{reply}}
253 +
#' @export
254 +
#' @examples
255 +
#' # Create a message and set the keywords.
256 +
#' envelope() %>% keywords("newsletter, marketing")
257 +
#' envelope() %>% keywords("newsletter", "marketing")
258 +
#' envelope() %>% keywords(c("newsletter", "marketing"))
259 +
#'
260 +
#' # Retrieve the keywords for a message.
261 +
#' msg <- envelope() %>% keywords("newsletter, marketing")
262 +
#' keywords(msg)
263 +
keywords <- function(msg, ..., append = FALSE) {
264 +
   arguments <- c(...)
265 +
  if (is.null(arguments)) {
266 +
    header_get(msg, "Keywords")
267 +
  } else {
268 +
    msg <- header_set(msg, "Keywords", arguments, append = append, sep = ", ")
269 +
    if (get_option_invisible()) invisible(msg) else msg # nocov
270 +
  }
271 +
}

@@ -3,7 +3,8 @@
Loading
3 3
  params = NULL,
4 4
  squish = TRUE,
5 5
  css,
6 -
  include_css
6 +
  include_css,
7 +
  language
7 8
) {
8 9
  stopifnot(is.null(params) || is.list(params))
9 10
@@ -154,7 +155,7 @@
Loading
154 155
    # Remove <meta> tag (a "Content-Type" <meta> inserted by {xml2}).
155 156
    str_replace("<meta[^>]*>", "")
156 157
157 -
  output <- text_html(output, squish = squish, css = css)
158 +
  output <- text_html(output, squish = squish, css = css, language = language)
158 159
159 160
  if (plain) {
160 161
    output
@@ -254,6 +255,7 @@
Loading
254 255
  squish = TRUE,
255 256
  css_files = c(),
256 257
  include_css = c("rmd", "bootstrap", "highlight"),
258 +
  language = FALSE,
257 259
  interpolate = TRUE,
258 260
  .open = "{{",
259 261
  .close = "}}",
@@ -311,7 +313,8 @@
Loading
311 313
    params,
312 314
    squish,
313 315
    list(extra = read_text(css_files)),
314 -
    include_css
316 +
    include_css,
317 +
    language
315 318
  )
316 319
317 320
  msg <- append(msg, body)

@@ -41,6 +41,7 @@
Loading
41 41
  disposition = "inline",
42 42
  charset = "utf-8",
43 43
  encoding = "7bit",
44 +
  language = FALSE,
44 45
  interpolate = TRUE,
45 46
  .open = "{{",
46 47
  .close = "}}",
@@ -53,7 +54,7 @@
Loading
53 54
54 55
  if (interpolate) content <- glue(content, .open = .open, .close = .close, .envir = .envir)
55 56
56 -
  body <- text_plain(content, disposition, charset, encoding)
57 +
  body <- text_plain(content, disposition, charset, encoding, language)
57 58
58 59
  msg <- append(msg, body)
59 60
@@ -84,6 +85,7 @@
Loading
84 85
  charset = "utf-8",
85 86
  encoding = "quoted-printable",
86 87
  css_files = c(),
88 +
  language = FALSE,
87 89
  interpolate = TRUE,
88 90
  .open = "{{",
89 91
  .close = "}}",
@@ -104,7 +106,8 @@
Loading
104 106
105 107
  body <- text_html(
106 108
    content, disposition, charset, encoding,
107 -
    css = read_text(css_files)
109 +
    css = read_text(css_files),
110 +
    language = language
108 111
  )
109 112
110 113
  msg <- append(msg, body)

@@ -189,7 +189,6 @@
Loading
189 189
  x
190 190
}
191 191
192 -
193 192
#' Test if list is nested or flat
194 193
#'
195 194
#' @noRd

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 1 files with coverage changes found.

New file R/header-language.R
New
Loading file...
Files Coverage
R -1.56% 98.28%
Project Totals (18 files) 98.28%
Loading