is_git2rmeta: Check Whether a Git2rdata Object Has Valid Metadata.

Description Usage Arguments Value See Also Examples

View source: R/is_git2rmeta.R

Description

Valid metadata is a file with .yml extension. It has a top level item ..generic. This item contains git2rdata (the version number), hash (a hash on the metadata) and data_hash (a hash on the data file). The version number must be the current version.

Usage

1
is_git2rmeta(file, root = ".", message = c("none", "warning", "error"))

Arguments

file

the name of the git2rdata object. Git2rdata objects cannot have dots in their name. The name may include a relative path. file is a path relative to the root. Note that file must point to a location within root.

root

The root of a project. Can be a file path or a git-repository. Defaults to the current working directory (".").

message

a single value indicating the type of messages on top of the logical value. "none": no messages, "warning": issue a warning in case of an invalid metadata file. "error": an invalid metadata file results in an error. Defaults to "none".

Value

A logical value. TRUE in case of a valid metadata file. Otherwise FALSE.

See Also

Other internal: is_git2rdata(), meta(), upgrade_data()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# create a directory
root <- tempfile("git2rdata-")
dir.create(root)

# store a file
write_vc(iris[1:6, ], "iris", root, sorting = "Sepal.Length")
# check the stored file
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

# Remove the metadata from the existing git2rdata object. Then it stops
# being a git2rdata object.
junk <- file.remove(file.path(root, "iris.yml"))
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

# recreate the file and remove the data and keep the metadata. It stops being
# a git2rdata object, but the metadata remains valid.
write_vc(iris[1:6, ], "iris", root, sorting = "Sepal.Length")
junk <- file.remove(file.path(root, "iris.tsv"))
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

# clean up
junk <- file.remove(list.files(root, full.names = TRUE), root)

git2rdata documentation built on Jan. 21, 2021, 5:07 p.m.