Skip to content

Commit

Permalink
Merge pull request #14 from inbo/hansvancalster-patch-1
Browse files Browse the repository at this point in the history
Finalise version 0.0.3
  • Loading branch information
ThierryO committed Mar 12, 2019
2 parents 42e5905 + e200e42 commit 4b1f2fd
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: git2rdata
Title: Store and Retrieve Data.frames in a Git Repository
Version: 0.0.2.9000
Version: 0.0.3
Authors@R: c(
person(
"Thierry", "Onkelinx", role = c("aut", "cre"),
Expand Down
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git2rdata 0.0.2 (2019-02-26)

* metadata is added as a list to the objects rather than in YAML format.
* the [yaml](https://cran.r-project.org/package=yaml) package is used to store the metadata list in YAML format.
* `write_vc()` now used the 'strict' argument instead of 'override'
* `write_vc()` now uses the 'strict' argument instead of 'override'
* the functionality `rm_data()` is split into `rm_data()` and `prune_meta()` (#9)

### NEW FEATURES
Expand All @@ -30,9 +30,9 @@ git2rdata 0.0.2 (2019-02-26)
* each helpfile contains a working example (#11)
* README updated (#12)
* Updated the rationale with links to the vignettes
* `git2rdata` has an hexsticker logo
* `git2rdata` has a hexsticker logo
* A DOI is added
* The installation instructions uses `remotes` and build the vignettes
* The installation instructions use `remotes` and build the vignettes
* `auto_commit()` was removed because of limited extra functionality over `git2r::commit()`
* dataframes are read and written by base R functions instead of `readr` functions

Expand Down
2 changes: 1 addition & 1 deletion R/list_data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' list available data objects in the repository
#' List available data files
#' @param root the `root` of the repository. Either a path or a `git-repository`
#' @param path relative `path` from the `root`. Defaults to the `root`
#' @inheritParams base::list.files
Expand Down
4 changes: 3 additions & 1 deletion R/read_vc.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#' Read a \code{data.frame} from a repository
#' Read a \code{data.frame}
#'
#' Note that the dataframe has to be written with `write_vc()` before it can be read with `read_vc()`.
#' @inheritParams write_vc
#' @return The \code{data.frame} with the file names and hashes as attributes
#' @rdname read_vc
Expand Down
2 changes: 1 addition & 1 deletion R/write_vc.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Write a \code{data.frame} to a git repository
#' Write a \code{data.frame}
#'
#' This will create two files. The `".tsv"` file contains the raw data.
#' The `".yml"` contains the meta data on the columns in YAML format.
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
[![DOI](https://zenodo.org/badge/147685405.svg)](https://zenodo.org/badge/latestdoi/147685405)
## Rationale

The `git2rdata` package writes and reads dataframes as plain text files. Important information is stored in a metadata file.
The `git2rdata` package is an R package for writing and reading dataframes as plain text files. Important information is stored in a metadata file.

1. Storing metadata allows to maintain variables classes. By default, the data is optimized for file storage prior to writing. This make the data less human readable and can be turned off. Details on the implementation are available on the [plain text](https://inbo.github.io/git2rdata/articles/plain_text.html) vignette.
1. Storing metadata also allows to minimize row base [diffs](https://en.wikipedia.org/wiki/Diff) between two consecutive [commits](https://en.wikipedia.org/wiki/Commit_(version_control)). This is a useful feature when storing data as plain text files under version control. Details on this part of the implementation is available at the [version control](https://inbo.github.io/git2rdata/articles/version_control.html) vignette. Although `git2rdata` was envisioned with a [git](https://git-scm.com/) workflow in mind, it can also be used in combination with other version control systems like [subversion](https://subversion.apache.org/) or [mercurial](https://www.mercurial-scm.org/).
1. `git2rdata` is intended to facility a reproducible and traceable workflow. A toy example is given in the [workflow](https://inbo.github.io/git2rdata/articles/workflow.html) vignette.
1. The [efficiency](https://inbo.github.io/git2rdata/articles/efficiency.html) vignette gives some insight on the efficiency in terms of file storage, git repository size and speed for writing and reading.
1. Storing metadata allows to maintain the classes of variables. By default, the data is optimized for file storage prior to writing. This makes the data less human readable and can be turned off. Details on the implementation are available in the [plain text](https://inbo.github.io/git2rdata/articles/plain_text.html) vignette.
1. Storing metadata also allows to minimize row based [diffs](https://en.wikipedia.org/wiki/Diff) between two consecutive [commits](https://en.wikipedia.org/wiki/Commit_(version_control)). This is a useful feature when storing data as plain text files under version control. Details on this part of the implementation are available in the [version control](https://inbo.github.io/git2rdata/articles/version_control.html) vignette. Although `git2rdata` was envisioned with a [git](https://git-scm.com/) workflow in mind, it can also be used in combination with other version control systems like [subversion](https://subversion.apache.org/) or [mercurial](https://www.mercurial-scm.org/).
1. `git2rdata` is intended to facilitate a reproducible and traceable workflow. A toy example is given in the [workflow](https://inbo.github.io/git2rdata/articles/workflow.html) vignette.
1. The [efficiency](https://inbo.github.io/git2rdata/articles/efficiency.html) vignette provides some insight into the efficiency in terms of file storage, git repository size and speed for writing and reading.

## Installation

Install the development version

```r
# installation requires the "remotes" packages
# installation requires the "remotes" package
# install.package("remotes")

# install with vignettes (recommended)
Expand All @@ -38,7 +38,7 @@ remotes::install_github("inbo/git2rdata"))

## Main usage

Dataframes are stored using `write_vc()` and retrieved with `read_vc()`. Both share the arguments `root` and `file`. Root refers to a base location where the dataframe should be stored. It can either point to a local directory or a local git repository. `file` is the file name to use and can include a path relative to `root`. Make sure the relative path stays within `root`.
Dataframes are stored using `write_vc()` and retrieved with `read_vc()`. Both functions share the arguments `root` and `file`. `root` refers to a base location where the dataframe should be stored. It can either point to a local directory or a local git repository. `file` is the file name to use and can include a path relative to `root`. Make sure the relative path stays within `root`.

```r
library(git2rdata)
Expand All @@ -55,7 +55,7 @@ Please use the output of `citation("git2rdata")`
## Folder structure

- `R`: The source scripts of the [R](https://cran.r-project.org/) functions with documentation in [Roxygen](https://github.com/klutometis/roxygen) format
- `man`: The help file in [Rd](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Rd-format) format
- `man`: The help files in [Rd](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Rd-format) format
- `testthat`: R scripts with unit tests using the [testthat](http://testthat.r-lib.org/) framework
- `vignettes`: source code for the vignettes describing the package
- `man-roxygen`: templates for documentation in Roxygen format
Expand All @@ -78,4 +78,4 @@ git2rdata

## Contributions

Contribution to `git2rdata` are welcome. Please read our [Contributing guidelines](.github/CONTRIBUTING.md) first. The `git2rdata` project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
Contributions to `git2rdata` are welcome. Please read our [Contributing guidelines](.github/CONTRIBUTING.md) first. The `git2rdata` project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/inbo/git2rdata",
"issueTracker": "https://github.com/inbo/git2rdata/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.2.9000",
"version": "0.0.3",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -163,7 +163,7 @@
}
],
"readme": "https://github.com/inbo/git2rdata/blob/master/README.md",
"fileSize": "334.831KB",
"fileSize": "336.015KB",
"contIntegration": [
"https://travis-ci.org/inbo/git2rdata",
"https://ci.appveyor.com/project/ThierryO/git2rdata/branch/master",
Expand Down
4 changes: 2 additions & 2 deletions man/list_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/read_vc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/write_vc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkgdown/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ body {
font-family: FlandersArtSans-Light, Verdana, Arial, sans-serif;
}

.row{
background-color: #ffffff;
}

a {
color: #c04384;
}
Expand Down
17 changes: 11 additions & 6 deletions tests/testthat/test_d_recent_commit.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
context("recent_commit")

# currently odb_blobs() can't handle subsecond commits
# when TRUE Sys.sleep(1.1) is added before each commit
subsecond <- TRUE
# git timings don't handle subsecond changes
# therefore Sys.sleep(subsecond) is added before each commit
subsecond <- 1.2

root <- tempfile(pattern = "git2rdata-recent")
dir.create(root)
Expand All @@ -25,14 +25,14 @@ write_vc(
test_data[5:6, ], file = "test1", root = root, stage = TRUE,
sorting = "test_Date"
)
if (subsecond) Sys.sleep(1.1)
Sys.sleep(subsecond)
commit_3 <- commit(root, "update first file")

write_vc(
test_data[7:8, ], file = "test3", root = root, stage = TRUE,
sorting = "test_Date"
)
if (subsecond) Sys.sleep(1.1)
Sys.sleep(subsecond)
commit_4 <- commit(root, "add third file")

write_vc(
Expand Down Expand Up @@ -70,8 +70,13 @@ write_vc(
sorting = "test_Date"
)
commit_7 <- commit(root, "second subsecond")
write_vc(
test_data[15:16, ], file = "subsecond", root = root, stage = TRUE,
sorting = "test_Date"
)
commit_8 <- commit(root, "third subsecond")
expect_warning(
output <- recent_commit(file = "subsecond", root, data = TRUE),
"Multiple commits within the same second"
)
expect_true(all(output$commit %in% c(commit_6$sha, commit_7$sha)))
expect_true(all(output$commit %in% c(commit_6$sha, commit_7$sha, commit_8$sha)))
Loading

0 comments on commit 4b1f2fd

Please sign in to comment.