Skip to content
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

Export file-writing helpers #389

Merged
merged 10 commits into from
Jun 20, 2018
Merged

Export file-writing helpers #389

merged 10 commits into from
Jun 20, 2018

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Jun 19, 2018

Closes #366 any chance you'd consider exporting write_union?
Closes #344 Export edit_file

  • Re-locate some functions. helper.R had gotten quite large and diffuse.
  • Make is_in_proj() resilient to there being no active project
  • Export edit_file(), write_union(), write_over(); mark with @keywords internal
  • Process input path with user_path_prep() now that it's user-accessible

@jennybc jennybc requested a review from hadley as a code owner June 19, 2018 01:41
@jennybc jennybc removed the request for review from hadley June 19, 2018 01:41
@jennybc
Copy link
Member Author

jennybc commented Jun 19, 2018

Might be nice to add "Export edit_file" #344 to this PR, yes?

R/write.R Outdated
#' @param new_lines Character vector of lines to add, if not already present.
#' @param quiet Logical. Whether to message about what is happening.
#'
#' @return Logical indicating whether a write occurred, invisibly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keywords internal ?

@jennybc
Copy link
Member Author

jennybc commented Jun 19, 2018

Now includes #344 (Export edit_file) + a lot of moving functions around that I have long wanted to do.

R/write.R Outdated
#' readLines(tmp)
#'
#' ## clean up
#' file.remove(tmp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a non-awkward way to give this a name starting with edit_? That would make it more clearly a member of an existing family.

Copy link
Member Author

@jennybc jennybc Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. But perhaps write_over() and write_utf8() should also be exported -- why export only write_union()? And then they make their own little family.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write_utf8 definitely belongs elsewhere but seems good to export write_over

#' }
edit_file <- function(path) {
path <- user_path_prep(path)
dir_create(path_dir(path), recursive = TRUE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this call use_directory()? The additional messaging seems like it would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm a bit boxed into a corner atm. use_directory() assumes that input path is relative to the active project. Whereas all the write_*() helpers and edit_file() assume the input path can be taken at face value.

I'll take this as evidence that the functions re: directory creation aren't quite right yet. Will work on that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point; can definitely happen after this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will sort this out here: #393

@jennybc
Copy link
Member Author

jennybc commented Jun 19, 2018

Assuming CI goes well, I think this is done.

@jennybc jennybc changed the title Export write_union() Export file-writing and -editing helpers Jun 19, 2018
@jennybc jennybc changed the title Export file-writing and -editing helpers Export file-writing helpers Jun 19, 2018
@jennybc jennybc merged commit 979a865 into master Jun 20, 2018
@cboettig
Copy link
Contributor

🎉

@jennybc jennybc deleted the export-write-union branch June 20, 2018 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants