Skip to content

Commit 684c0ed

Browse files
committed
import pillar instead of tibble
- Now importing pillar instead of tibble, and using colored formatting.
1 parent bb9f28f commit 684c0ed

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Description: R's raw vector is useful for storing a single binary object.
1212
use as a column in data frame.
1313
Imports:
1414
methods,
15-
tibble
15+
pillar
1616
License: GPL-3
1717
Encoding: UTF-8
1818
LazyData: true

NAMESPACE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ S3method(format,blob)
1515
S3method(is.na,blob)
1616
S3method(is_vector_s3,blob)
1717
S3method(obj_sum,blob)
18+
S3method(pillar_shaft,blob)
1819
S3method(print,blob)
1920
S3method(type_sum,blob)
2021
export(as.blob)
2122
export(blob)
2223
export(new_blob)
2324
importFrom(methods,setOldClass)
24-
importFrom(tibble,is_vector_s3)
25-
importFrom(tibble,obj_sum)
26-
importFrom(tibble,type_sum)
25+
importFrom(pillar,is_vector_s3)
26+
importFrom(pillar,obj_sum)
27+
importFrom(pillar,pillar_shaft)
28+
importFrom(pillar,type_sum)

R/format.R

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ print.blob <- function(x, ...) {
1616
}
1717

1818
#' @export
19-
#' @importFrom tibble type_sum
19+
#' @importFrom pillar type_sum
2020
type_sum.blob <- function(x) {
2121
"blob"
2222
}
2323

2424
#' @export
25-
#' @importFrom tibble obj_sum
25+
#' @importFrom pillar obj_sum
2626
obj_sum.blob <- function(x) {
2727
format(x, trim = FALSE)
2828
}
2929

3030
#' @export
31-
#' @importFrom tibble is_vector_s3
31+
#' @importFrom pillar is_vector_s3
3232
is_vector_s3.blob <- function(x) TRUE
3333

3434
blob_size <- function(x, digits = 3, trim = TRUE, ...) {
@@ -47,3 +47,15 @@ blob_size <- function(x, digits = 3, trim = TRUE, ...) {
4747
x2 <- format(x1, big.mark = ",", scientific = FALSE, trim = trim)
4848
paste0(x2, " ", unit)
4949
}
50+
51+
#' @importFrom pillar pillar_shaft
52+
#' @export
53+
pillar_shaft.blob <- function(x, ...) {
54+
out <- ifelse(
55+
is.na(x),
56+
NA_character_,
57+
paste0(pillar::style_subtle("["), blob_size(x, ...), pillar::style_subtle("]"))
58+
)
59+
60+
pillar::new_pillar_shaft_simple(out, align = "right")
61+
}

0 commit comments

Comments
 (0)