Skip to content

Upkeep 2025 06 #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
^CRAN-RELEASE$
^\.github$
^LICENSE\.md$
^[\.]?air\.toml$
^\.vscode$
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
}
}
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ Suggests:
covr,
crayon,
pillar (>= 1.2.1),
testthat
testthat (>= 3.0.0)
Config/autostyle/scope: line_breaks
Config/autostyle/strict: false
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2.9000
7 changes: 7 additions & 0 deletions R/blob-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' @keywords internal
"_PACKAGE"

#' @import vctrs
#' @import rlang
#' @importFrom methods setOldClass
NULL
5 changes: 0 additions & 5 deletions R/blob.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#' @import vctrs
#' @import rlang
NULL

#' @importFrom methods setOldClass
setOldClass(c("blob", "vctrs_list_of", "vctrs_vctr"))

#' Construct a blob object
Expand Down
4 changes: 3 additions & 1 deletion R/cast.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ vec_cast.blob.vctrs_list_of <- function(x, to, ...) {
#' @method vec_cast.blob integer
#' @export
vec_cast.blob.integer <- function(x, to, ...) {
signal_soft_deprecated("Coercing an integer vector to a blob is deprecated, please coerce to a list first.")
signal_soft_deprecated(
"Coercing an integer vector to a blob is deprecated, please coerce to a list first."
)
blob(!!!lapply(x, as_single_raw))
}

Expand Down
4 changes: 3 additions & 1 deletion R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#' @method vec_ptype2 blob
#' @export
#' @export vec_ptype2.blob
vec_ptype2.blob <- function(x, y, ..., x_arg = "", y_arg = "") UseMethod("vec_ptype2.blob", y)
vec_ptype2.blob <- function(x, y, ..., x_arg = "", y_arg = "") {
UseMethod("vec_ptype2.blob", y)
}

#' @method vec_ptype2.blob default
#' @export
Expand Down
41 changes: 24 additions & 17 deletions R/compat-lifecycle.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#
# - Soft-namespaced private objects.


#' Signal deprecation
#'
#' @description
Expand Down Expand Up @@ -99,18 +98,23 @@ signal_soft_deprecated <- function(msg, id = msg, env = rlang::caller_env(2)) {
rlang::is_reference(topenv(env), rlang::global_env())
}

if (rlang::is_true(rlang::peek_option("lifecycle_verbose_soft_deprecation")) ||
env_inherits_global(env)) {
if (
rlang::is_true(rlang::peek_option("lifecycle_verbose_soft_deprecation")) ||
env_inherits_global(env)
) {
warn_deprecated(msg, id)
return(invisible(NULL))
}

# Test for environment names rather than reference/contents because
# testthat clones the namespace
tested_package <- Sys.getenv("TESTTHAT_PKG")
if (nzchar(tested_package) &&
identical(Sys.getenv("NOT_CRAN"), "true") &&
rlang::env_name(topenv(env)) == rlang::env_name(rlang::ns_env(tested_package))) {
if (
nzchar(tested_package) &&
identical(Sys.getenv("NOT_CRAN"), "true") &&
rlang::env_name(topenv(env)) ==
rlang::env_name(rlang::ns_env(tested_package))
) {
warn_deprecated(msg, id)
return(invisible(NULL))
}
Expand All @@ -126,12 +130,14 @@ warn_deprecated <- function(msg, id = msg) {
return(invisible(NULL))
}

if (!rlang::is_true(rlang::peek_option("lifecycle_repeat_warnings")) &&
rlang::env_has(.rlang_lifecycle_deprecation_env, id)) {
if (
!rlang::is_true(rlang::peek_option("lifecycle_repeat_warnings")) &&
rlang::env_has(.rlang_lifecycle_deprecation_env, id)
) {
return(invisible(NULL))
}

rlang::env_poke(.rlang_lifecycle_deprecation_env, id, TRUE);
rlang::env_poke(.rlang_lifecycle_deprecation_env, id, TRUE)

has_colour <- function() rlang::is_installed("crayon") && crayon::has_color()
silver <- function(x) if (has_colour()) crayon::silver(x) else x
Expand All @@ -143,7 +149,11 @@ warn_deprecated <- function(msg, id = msg) {
}

if (!rlang::is_true(rlang::peek_option("lifecycle_repeat_warnings"))) {
msg <- paste0(msg, "\n", silver("This warning is displayed once per session."))
msg <- paste0(
msg,
"\n",
silver("This warning is displayed once per session.")
)
}

.Signal(msg = msg)
Expand All @@ -163,17 +173,16 @@ stop_defunct <- function(msg) {
}

local_lifecycle_silence <- function(frame = rlang::caller_env()) {
rlang::local_options(.frame = frame,
lifecycle_disable_warnings = TRUE
)
rlang::local_options(.frame = frame, lifecycle_disable_warnings = TRUE)
}
with_lifecycle_silence <- function(expr) {
local_lifecycle_silence()
expr
}

local_lifecycle_warnings <- function(frame = rlang::caller_env()) {
rlang::local_options(.frame = frame,
rlang::local_options(
.frame = frame,
lifecycle_disable_warnings = FALSE,
lifecycle_verbose_soft_deprecation = TRUE,
lifecycle_repeat_warnings = TRUE
Expand All @@ -186,9 +195,7 @@ with_lifecycle_warnings <- function(expr) {

local_lifecycle_errors <- function(frame = rlang::caller_env()) {
local_lifecycle_warnings(frame = frame)
rlang::local_options(.frame = frame,
lifecycle_warnings_as_errors = TRUE
)
rlang::local_options(.frame = frame, lifecycle_warnings_as_errors = TRUE)
}
with_lifecycle_errors <- function(expr) {
local_lifecycle_errors()
Expand Down
12 changes: 9 additions & 3 deletions R/format.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#' @export
format.blob <- function(x, ...) {
if (length(x) == 0)
if (length(x) == 0) {
return(character())
}

ifelse(is.na(x), "<NA>", paste0("blob[", blob_size(x, ...), "]"))
}

#' @export
obj_print_data.blob <- function(x, ...) {
if (length(x) == 0)
if (length(x) == 0) {
return()
}

out <- stats::setNames(format(x), names(x))
print(out, quote = FALSE)
Expand Down Expand Up @@ -41,7 +43,11 @@ pillar_shaft.blob <- function(x, ...) {
out <- ifelse(
is.na(x),
NA_character_,
paste0(pillar::style_subtle("<raw "), blob_size(x, ...), pillar::style_subtle(">"))
paste0(
pillar::style_subtle("<raw "),
blob_size(x, ...),
pillar::style_subtle(">")
)
)

pillar::new_pillar_shaft_simple(out, align = "right")
Expand Down
6 changes: 4 additions & 2 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
is_raw_list <- function(x) {
if (!is.list(x))
if (!is.list(x)) {
return(FALSE)
}

raw <- vapply(x, is.raw, logical(1))
null <- vapply(x, is.null, logical(1))

if (!all(raw | null))
if (!all(raw | null)) {
return(FALSE)
}

TRUE
}
Expand Down
43 changes: 40 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
output: downlit::readme_document
output:
github_document:
html_preview: false
---

<!-- badges: start -->
Expand All @@ -19,6 +21,41 @@ knitr::opts_chunk$set(
comment = "#>",
fig.path = "README-"
)

clean_output <- function(x, options) {
x <- gsub("0x[0-9a-f]+", "0xdeadbeef", x)
x <- gsub("dataframe_[0-9]*_[0-9]*", " dataframe_42_42 ", x)
x <- gsub("[0-9]*\\.___row_number ASC", "42.___row_number ASC", x)

index <- x
index <- gsub("─", "-", index)
index <- strsplit(paste(index, collapse = "\n"), "\n---\n")[[1]][[2]]
writeLines(index, "index.md")

x <- gsub(
'(`vignette[(]"([^"]+)"[)]`)',
"[\\1](https://blob.tidyverse.org/articles/\\2.html)",
x
)
x <- fansi::strip_sgr(x)
x
}

options(
cli.num_colors = 256,
cli.width = 71,
width = 71,
pillar.bold = TRUE,
pillar.max_title_chars = 5,
pillar.min_title_chars = 5,
pillar.max_footer_lines = 12,
conflicts.policy = list(warn = FALSE)
)

local({
hook_source <- knitr::knit_hooks$get("document")
knitr::knit_hooks$set(document = clean_output)
})
```

# blob
Expand All @@ -39,8 +76,8 @@ install.packages("tidyverse")
install.packages("blob")

# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/blob")
# install.packages("pak")
pak::pak("tidyverse/blob")
```

## Example
Expand Down
76 changes: 45 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<!-- badges: start -->

[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![rcc](https://github.com/tidyverse/blob/workflows/rcc/badge.svg)](https://github.com/tidyverse/blob/actions) [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/blob)](https://cran.r-project.org/package=blob) [![Coverage Status](https://codecov.io/gh/tidyverse/blob/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/blob)
<!-- badges: start -->

[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![rcc](https://github.com/tidyverse/blob/workflows/rcc/badge.svg)](https://github.com/tidyverse/blob/actions)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/blob)](https://cran.r-project.org/package=blob)
[![Coverage
Status](https://codecov.io/gh/tidyverse/blob/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/blob)
<!-- badges: end -->

<!-- README.md is generated from README.Rmd. Please edit that file -->
Expand All @@ -10,44 +15,53 @@

## Overview

The goal of blob is to provide a simple S3 class to represent a vector of binary objects, aka blobs. The `blob` class is a lightweight wrapper around a list of raw vectors, suitable for inclusion in a data frame.
The goal of blob is to provide a simple S3 class to represent a vector
of binary objects, aka blobs. The `blob` class is a lightweight wrapper
around a list of raw vectors, suitable for inclusion in a data frame.

In most cases you will not need to use this package explicitly: it will be used transparently by packages that need to load BLOB columns from databases or binary file formats.
In most cases you will not need to use this package explicitly: it will
be used transparently by packages that need to load BLOB columns from
databases or binary file formats.

## Installation

<pre class='chroma'>
<span><span class='c'># The easiest way to get blob is to install the whole tidyverse:</span></span>
<span><span class='nf'><a href='https://rdrr.io/r/utils/install.packages.html'>install.packages</a></span><span class='o'>(</span><span class='s'>"tidyverse"</span><span class='o'>)</span></span>
<span></span>
<span><span class='c'># Alternatively, install just blob:</span></span>
<span><span class='nf'><a href='https://rdrr.io/r/utils/install.packages.html'>install.packages</a></span><span class='o'>(</span><span class='s'>"blob"</span><span class='o'>)</span></span>
<span></span>
<span><span class='c'># Or the the development version from GitHub:</span></span>
<span><span class='c'># install.packages("devtools")</span></span>
<span><span class='nf'>devtools</span><span class='nf'>::</span><span class='nf'><a href='https://remotes.r-lib.org/reference/install_github.html'>install_github</a></span><span class='o'>(</span><span class='s'>"tidyverse/blob"</span><span class='o'>)</span></span></pre>
``` r
# The easiest way to get blob is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just blob:
install.packages("blob")

# Or the the development version from GitHub:
# install.packages("pak")
pak::pak("tidyverse/blob")
```

## Example

To create a blob, use `blob()`, `new_blob()` or `as_blob()`:

<pre class='chroma'>
<span><span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://blob.tidyverse.org'>blob</a></span><span class='o'>)</span></span>
<span></span>
<span><span class='nv'>x1</span> <span class='o'>&lt;-</span> <span class='nf'><a href='https://rdrr.io/r/base/rawConversion.html'>charToRaw</a></span><span class='o'>(</span><span class='s'>"Good morning"</span><span class='o'>)</span></span>
<span><span class='nv'>x2</span> <span class='o'>&lt;-</span> <span class='nf'><a href='https://rdrr.io/r/base/raw.html'>as.raw</a></span><span class='o'>(</span><span class='nf'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='o'>(</span><span class='m'>0x48</span>, <span class='m'>0x65</span>, <span class='m'>0x6c</span>, <span class='m'>0x6c</span>, <span class='m'>0x6f</span><span class='o'>)</span><span class='o'>)</span></span>
<span></span>
<span><span class='nf'><a href='https://blob.tidyverse.org/reference/blob.html'>new_blob</a></span><span class='o'>(</span><span class='nf'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='o'>(</span><span class='nv'>x1</span>, <span class='nv'>x2</span><span class='o'>)</span><span class='o'>)</span></span>
<span><span class='c'>#&gt; &lt;blob[2]&gt;</span></span>
<span><span class='c'>#&gt; [1] blob[12 B] blob[5 B]</span></span>
<span><span class='nf'><a href='https://blob.tidyverse.org/reference/blob.html'>blob</a></span><span class='o'>(</span><span class='nv'>x1</span>, <span class='nv'>x2</span><span class='o'>)</span></span>
<span><span class='c'>#&gt; &lt;blob[2]&gt;</span></span>
<span><span class='c'>#&gt; [1] blob[12 B] blob[5 B]</span></span>
<span></span>
<span><span class='nf'><a href='https://blob.tidyverse.org/reference/blob.html'>as_blob</a></span><span class='o'>(</span><span class='nf'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='o'>(</span><span class='s'>"Good morning"</span>, <span class='s'>"Good evening"</span><span class='o'>)</span><span class='o'>)</span></span>
<span><span class='c'>#&gt; &lt;blob[2]&gt;</span></span>
<span><span class='c'>#&gt; [1] blob[12 B] blob[12 B]</span></span></pre>
``` r
library(blob)

x1 <- charToRaw("Good morning")
x2 <- as.raw(c(0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef))

new_blob(list(x1, x2))
#> <blob[2]>
#> [1] blob[12 B] blob[5 B]
blob(x1, x2)
#> <blob[2]>
#> [1] blob[12 B] blob[5 B]

as_blob(c("Good morning", "Good evening"))
#> <blob[2]>
#> [1] blob[12 B] blob[12 B]
```

------------------------------------------------------------------------

Please note that the ‘blob’ project is released with a [Contributor Code of Conduct](https://github.com/tidyverse/blob/blob/main/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
Please note that the ‘blob’ project is released with a [Contributor Code
of
Conduct](https://github.com/tidyverse/blob/blob/main/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.
Empty file added air.toml
Empty file.
Loading
Loading