path.chain

Concise structure for path chaining

https://github.com/krzjoa/path.chain

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Concise structure for path chaining

Basic Info
Statistics
  • Stars: 10
  • Watchers: 1
  • Forks: 1
  • Open Issues: 1
  • Releases: 0
Created over 6 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# path.chain 


[![CRAN status](https://www.r-pkg.org/badges/version/path.chain)](https://CRAN.R-project.org/package=path.chain)
[![Documentation](https://img.shields.io/badge/documentation-path.chain-orange.svg?colorB=E91E63)](https://krzjoa.github.io/path.chain/)
[![Travis build status](https://travis-ci.org/krzjoa/path.chain.svg?branch=master)](https://travis-ci.org/krzjoa/path.chain)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/krzjoa/path.chain?branch=master&svg=true)](https://ci.appveyor.com/project/krzjoa/path.chain)
[![Buy hex
stciker](https://img.shields.io/badge/buy%20hex-path.chain-green)](https://www.redbubble.com/i/sticker/path-chain-R-package-hex-sticker-by-krzjoa/45140988.EJUG5?asc=u)


> Concise structure for chainable paths

## Installation

``` r
# install.packages("devtools")
devtools::install_github("krzjoa/path.chain")
```
## Example
If you are using RStudio, you know that among many excellent features of this IDE there is a **path autocompletion**.

![rstudio](man/figures/path_chain.gif)


However, you can also meet situations, when that may be not enough.
Most of all, I mean bigger projects, where you store a complex file structure in the **config** file. 
You can handle such configuration YAML file using the library named [`config`](https://github.com/rstudio/config).
You may encounter a situation, when you'll want to save current directory structure in this config.

### Basic usage
```{r config.yml}
library(magrittr)
library(path.chain)

# Create an example file stucture
tmp <- create_temp_dir("files")
create_sample_dir(tmp, override = TRUE)

# Sample structure we've already created looks as follows
fs::dir_tree(tmp)

# Loading stucture
file.structure <- path_chain(tmp)
file.structure$data$example1.RData

# Loading stucture with naming convention
file.structure <- path_chain(tmp, naming = naming_k)
file.structure$kData$kExample1

# Saving file structure
file.structure %>% 
  as_config(root.name = "kRoot", wrap = "kDirs") %>%  # Required by `{config}` package
  yaml::write_yaml(temp_path("config.yaml"))
```

```{yaml} 
default:
  kDirs:
    kRoot: files/
    kData:
      kRoot: data/
      kExample1: kExample1
      kExample2: kExample2
      kPersons: kPersons
    kDocs:
      kRoot: docs/
      kSchema: kSchema
```

### Loading config file
```{r as_path_chain}
k.dirs <- config::get("kDirs", "default", temp_path("config.yaml")) %>% 
  as_path_chain()

class(k.dirs)

k.dirs$kData$.
k.dirs$kData$kExample1
```

### Path validation
```{r old.options, echo=FALSE}
old.options <- options()
```

```{r validate}
on_path_not_exists(~ print("Path {.x} not exists"))
is_path_valid <- function(x) if (!grepl("\\.fst", x)) print("Invalid file")
on_validate_path(is_path_valid)

level2.b <- path_link("fileA.RData")
level2.a <- path_link("fileB.fst")
level1   <- path_link("data", list(level2.a = level2.a , level2.b = level2.b))
root     <- path_link("files", list(level1))

root$data$level2.a
root$data$level2.b
```

```{r clean, echo=FALSE}
options(old.options)
```

Owner

  • Name: Krzysztof Joachimiak
  • Login: krzjoa
  • Kind: user
  • Location: Poznań, Poland

Data Scientist & Software Developer

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 2
  • Total pull requests: 2
  • Average time to close issues: 2 months
  • Average time to close pull requests: 29 days
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 3.5
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: 2 months
  • Average time to close pull requests: 29 days
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 3.5
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • WurmPeter (2)
Pull Request Authors
  • WurmPeter (3)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 220 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: path.chain

Concise Structure for Chainable Paths

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 220 Last month
Rankings
Stargazers count: 17.9%
Forks count: 28.8%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Average: 39.8%
Downloads: 87.0%
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • logger * imports
  • rlang * imports
  • stringi * imports
  • config * suggests
  • fs * suggests
  • knitr * suggests
  • magrittr * suggests
  • rmarkdown * suggests
  • testthat >= 2.1.0 suggests
  • yaml * suggests