Skip to content

Commit eb97c17

Browse files
committed
Merge branch 'r-1.1.0.9001' into production
2 parents 79f7766 + 383c1c6 commit eb97c17

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: blob
22
Title: A Simple S3 Class for Representing Vectors of Binary Data ('BLOBS')
3-
Version: 1.1.0.9000
3+
Version: 1.1.0.9001
44
Authors@R: c(
55
person("Hadley", "Wickham", role = c("aut")),
66
person("Kirill", "Müller", , "krlmlr+r@mailbox.org", role = c("cre")),
@@ -12,7 +12,8 @@ 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-
pillar
15+
pillar,
16+
prettyunits
1617
License: GPL-3
1718
Encoding: UTF-8
1819
LazyData: true

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### blob 1.1.0.9001 (2017-11-30)
2+
3+
- Now using the prettyunits package to format data sizes.
4+
5+
16
### blob 1.1.0.9000 (2017-11-29)
27

38
- Use `B` instead of `b` as unit.

R/format.R

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,7 @@ is_vector_s3.blob <- function(x) TRUE
3333

3434
blob_size <- function(x, digits = 3, trim = TRUE, ...) {
3535
x <- vapply(x, length, numeric(1))
36-
37-
units <- c("kB", "MB", "GB", "TB")
38-
power <- min(floor(log(abs(x), 1000)), length(units))
39-
if (power < 1) {
40-
unit <- "B"
41-
} else {
42-
unit <- units[[power]]
43-
x <- x / (1024 ^ power)
44-
}
45-
46-
x1 <- signif(x, digits = digits %||% 3)
47-
x2 <- format(x1, big.mark = ",", scientific = FALSE, trim = trim)
48-
paste0(x2, " ", unit)
36+
prettyunits::pretty_bytes(x)
4937
}
5038

5139
#' @importFrom pillar pillar_shaft
@@ -54,7 +42,7 @@ pillar_shaft.blob <- function(x, ...) {
5442
out <- ifelse(
5543
is.na(x),
5644
NA_character_,
57-
paste0(pillar::style_subtle("["), blob_size(x, ...), pillar::style_subtle("]"))
45+
paste0(pillar::style_subtle("<raw "), blob_size(x, ...), pillar::style_subtle(">"))
5846
)
5947

6048
pillar::new_pillar_shaft_simple(out, align = "right")

0 commit comments

Comments
 (0)