https://github.com/ixpantia/gitear
R wrapper to the gitea API
https://github.com/ixpantia/gitear
gitea hacktoberfest r rstats
Last synced: 11 months ago
JSON representation
R wrapper to the gitea API
- Host: GitHub
- URL: https://github.com/ixpantia/gitear
- Owner: ixpantia
- Created: 2018-09-12T13:55:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-02T21:37:04.000Z (about 2 years ago)
- Last Synced: 2025-03-24T15:49:52.906Z (12 months ago)
- Topics: gitea, hacktoberfest, r, rstats
- Language: R
- Homepage: https://ixpantia.github.io/gitear/
- Size: 897 KB
- Stars: 5
- Watchers: 0
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(gitear)
library(dplyr)
library(dplyr)
library(jsonlite)
library(mockery)
```
[](https://cran.r-project.org/package=gitear)
[](https://travis-ci.org/ixpantia/gitear)
[](https://codecov.io/gh/ixpantia/gitear?branch=master)
The goal of gitear is to request your self-hosted Git service data and import
it to R in a tidy data frame.
`gitear` is a package that communicates with the
[gitea](https://gitea.io/en-us/) API.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("ixpantia/gitear")
```
## Usage
First go to your gitea self hosted service and grab your API Token. Then you
should be able to the following:
```{r, echo = FALSE}
r <- readRDS(system.file("helper_data/response_example.RDS",
package = "gitear"))
content_issues <- jsonlite::fromJSON(system.file("helper_data/get_issues.json",
package = "gitear"))
mockery::stub(where = get_issues,
what = "GET",
how = r)
mockery::stub(where = get_issues,
what = "fromJSON",
how = content_issues)
```
```{r example}
# Credentials
api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
url_ixpantia <- "https://prueba.com"
# Example function use
issues <- get_issues(base_url = url_ixpantia,
api_key = api_token,
owner = "empresa",
repo = "repo_prueba")
issues
```
## **Environmental variables:**
In order to work with environmental variables to make your scripts safer from
somebody getting your credentials, you can follow the next workflow:
1. Create an .Renviron file with your credentials
2. Restart your R session
3. Store your credentials in an object for using it in your script
Your script could look something like this:
```{r example_2}
# Storing credentials in an object
example_key <- Sys.getenv("example_key")
example_url <- Sys.getenv("example_url")
# Using a function from gitear
issues <- get_issues(base_url = example_url,
api_key = example_key,
owner = "empresa",
repo = "repo_prueba")
# Check the output
glimpse(issues)
```
