@@ -14,8 +14,7 @@ write_resource <- function(package, resource_name, directory = ".",
1414 resource <- resource(package , resource_name )
1515
1616 # Resource contains new data
17- data_location <- attr(resource , " data_location" )
18- if (data_location == " df" ) {
17+ if (resource $ read_from == " df" ) {
1918 if (compress ) {
2019 file_name <- paste(resource_name , " csv" , " gz" , sep = " ." )
2120 } else {
@@ -29,14 +28,15 @@ write_resource <- function(package, resource_name, directory = ".",
2928 resource $ mediatype <- " text/csv"
3029 resource $ encoding <- " utf-8" # Enforced by readr::write_csv()
3130 resource $ dialect <- NULL
31+ resource $ read_from <- NULL
3232 resource $ data <- NULL
3333
3434 # Resource originally had data property
35- } else if (data_location == " data" ) {
36- # Do nothing
35+ } else if (resource $ read_from == " data" ) {
36+ resource $ read_from <- NULL
3737
3838 # Resource has local paths (optionally mixed with URLs)
39- } else if (data_location == " path" ) {
39+ } else if (resource $ read_from == " path" ) {
4040 # Download or copy file to directory, point path to file name (in that dir)
4141 # Note that existing files will not be overwritten
4242 out_paths <- vector()
@@ -56,15 +56,14 @@ write_resource <- function(package, resource_name, directory = ".",
5656 }
5757 out_paths <- append(out_paths , file_name )
5858 }
59+ resource $ read_from <- NULL
5960 resource $ path <- out_paths
6061
6162 # Resource has URL paths (only)
62- } else if (data_location == " url" ) {
63+ } else if (resource $ read_from == " url" ) {
6364 # Don't touch file, leave URL path as is
65+ resource $ read_from <- NULL
6466 }
6567
66- # Remove attributes
67- attr(resource , " data_location" ) <- NULL
68-
6968 return (resource )
7069}
0 commit comments