-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement drive_id
class more fully
#364
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jennybc
commented
Jun 28, 2021
jennybc
commented
Jun 28, 2021
jennybc
commented
Jun 28, 2021
jennybc
commented
Jun 28, 2021
R/drive_id-class.R
Outdated
Comment on lines
78
to
83
# full <- format(x) | ||
# trunc <- format(paste0(substr(x, 1, 7), cli::symbol$continue)) | ||
# pillar::new_pillar_shaft( | ||
# list(full = full, trunc = trunc), | ||
# width = pillar::get_max_extent(full), | ||
# min_width = pillar::get_max_extent(trunc), | ||
# class = "pillar_shaft_drive_id" | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this worked but it does not quite do so (yet?).
hadley
approved these changes
Jun 30, 2021
jennybc
force-pushed
the
embrace-drive-id-class
branch
from
July 7, 2021 00:20
6f1ca7c
to
ac8cf09
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #93
Some aspects of this PR were done in a certain way, in order to generate discussion for a live code review in a group meeting
googledrive has always had
drive_id
, a lightweight S3 class to mark a string (or character vector) as file ID, instead of a filename.drive_id
pre-dated vctrs and was implemented in a very minimal way.Overall, it’s been OK, but there are annoying downsides:
space when printing
dribble
s, often at the expense ofname
, which isoften more interesting to the user.
drive_id
class.drive_id
object that are definitely not valid, like""
.Here’s what I mean:
This PR implements
drive_id
more fully and uses the capabilities in vctrs and pillar to address the above.Resources consulted:
Another relevant resource is Davis’s notes on
“adding dplyr and vctrs support to your tibble subclass so that it works with the tidyverse”.
I recently updated the technology behind the
dribble
subclass and, since theid
column of adribble
should be adrive_id
(but previously was not), these two efforts intersect.TL;DR here’s how things work now:
The final
drive_id
truncation strategy ended up being different. There is less truncation than shown here.Problems and observations
The
pillar::pillar_shaft()
method isn’t working how I want.Current work-around is to always truncate the
drive_id
s in a tibble.This is not great, because sometimes you really do need access to the whole id for copy/paste. r-lib/pillar#331
That 👆 was resolved by settling for the truncation normally done on
character
columns. It's not ideal but it's better than nothing.Lots ofas.character(id)
is necessary when incorporatingdrive_id
s into requests, because of:That 👆 was resolved by inheriting base class (character) in
new_drive_id()
.Created on 2021-06-28 by the reprex package (v2.0.0.9000)