fetchTimestampHelpers: Methods to assist in writing and debugging custom...

Description Usage Arguments Examples

Description

These functions are used within vizlab fetchTimestamp() methods and may be useful within custom methods as well.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
urlFetcher(id, location = NA, remoteURL)

writeTimestamp(new.timestamp, viz, timestamp.mtime = NA)

updateTimestamp(viz, verbose = FALSE)

formatTimestamp(timestamp)

locateTimestampFile(id)

readTimestamp(viz)

Arguments

id

the viz id - should be the same as for the viz in the calling function

location

the fetched data file location - should be the same as for the viz in the calling function. May be NA if you're only passing the output to fetchTimestamp(); required for fetch().

remoteURL

the new URL to use for fetching the data and/or timestamp (assuming fetch() or fetchTimestamp() is called on the results of this function)

new.timestamp

the new timestamp to write to file

viz

a viz item (e.g., from as.viz)

timestamp.mtime

the timestamp to assign to the timestamp file's metadata (using Sys.setFileTime - sets the mtime=modified time property); NA leaves the metadata alone

verbose

logical to pass on to remake::make()

timestamp

POSIXct timestamp to format into a character string

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
# this custom method probably won't do what you want,
# just shows how to use the helper functions
fetchTimestamp.myfetcher <- function(viz) {
  timestamp.file <- locateTimestampFile(viz$id)
  old.timestamp <- readTimestamp(viz)
  new.timestamp <- getOnlineTimestamp() # made-up function, not implemented
  if(!file.exists(timestamp.file) || old.timestamp < new.timestamp) {
    writeTimestamp(new.timestamp, viz)
  }
  invisible()
}

## End(Not run)
## Not run: 
fetchTimestamp.myfetcher <- function(viz) {
  url <- constructURLFromViz(viz)
  urlLastModified(viz$id, remoteURL=url)
}

## End(Not run)

USGS-VIZLAB/vizlab documentation built on July 10, 2019, 12:08 a.m.