-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Description, License, test, functions, and more.
- Loading branch information
1 parent
ef7ab87
commit 048b485
Showing
18 changed files
with
341 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,9 @@ | |
^renv\.lock$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ | ||
^\.github$ | ||
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: R-CMD-check | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: macos-latest, r: 'release'} | ||
- {os: windows-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | ||
- {os: ubuntu-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'oldrel-1'} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: ${{ matrix.config.r }} | ||
http-user-agent: ${{ matrix.config.http-user-agent }} | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true | ||
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
name: pkgdown | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
pkgdown: | ||
runs-on: ubuntu-latest | ||
# Only restrict concurrency for non-PR jobs | ||
concurrency: | ||
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::pkgdown, local::. | ||
needs: website | ||
|
||
- name: Build site | ||
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) | ||
shell: Rscript {0} | ||
|
||
- name: Deploy to GitHub pages 🚀 | ||
if: github.event_name != 'pull_request' | ||
uses: JamesIves/[email protected] | ||
with: | ||
clean: false | ||
branch: gh-pages | ||
folder: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
.httr-oauth | ||
.DS_Store | ||
.quarto | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,18 @@ Type: Package | |
Title: Explore Your R Libraries | ||
Version: 0.0.0.9000 | ||
Author: Emil Johansson | ||
Maintainer: Joe Developer <[email protected]> | ||
Maintainer: Emil Johansson <[email protected]> | ||
Description: More about what it does (maybe more than one line) | ||
Use four spaces when indenting paragraphs within the Description. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
URL: https://github.com/eemiljohansson/libminer | ||
URL: https://github.com/eemiljohansson/libminer, https://eemiljohansson.github.io/libminer/ | ||
BugReports: https://github.com/eemiljohansson/libminer/issues | ||
RoxygenNote: 7.3.1 | ||
Suggests: | ||
testthat (>= 3.0.0) | ||
Config/testthat/edition: 3 | ||
Imports: | ||
fs, | ||
purrr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2024 | ||
COPYRIGHT HOLDER: libminer authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2024 libminer authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' Provides a brief summary of the package libraries on your machine | ||
#' | ||
#' @param sizes Should the sizes of the libraries be calculated? | ||
#' Logical; default `FALSE`. | ||
#' | ||
#' @return A data.frame containing the count of packages in each of the user's | ||
#' libraries. A `lib_size` column is included if `sizes = TRUE`. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' lib_summary() | ||
#' lib_summary(sizes = TRUE) | ||
|
||
lib_summary <- function(sizes = FALSE) { | ||
pkgs <- utils::installed.packages() | ||
pkg_tbl <- table(pkgs[, "LibPath"]) | ||
pkg_df <- as.data.frame(pkg_tbl, stringsAsFactors = FALSE) | ||
names(pkg_df) <- c("Library", "n_packages") | ||
|
||
if (sizes) { | ||
pkg_df$lib_size <- vapply( | ||
pkg_df$Library, | ||
function(x) { | ||
sum(fs::file_size(fs::dir_ls(x, recurse = TRUE))) | ||
}, | ||
FUN.VALUE = numeric(1) | ||
) | ||
} | ||
pkg_df | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
|
||
|
||
# libminer | ||
|
||
<!-- badges: start --> | ||
|
||
[![R-CMD-check](https://github.com/eemiljohansson/libminer/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eemiljohansson/libminer/actions/workflows/R-CMD-check.yaml) | ||
<!-- badges: end --> | ||
|
||
The goal of libminer is to provide an overview of your R library setup. It is a toy | ||
package created as a part of a workshop and not meant for serious use. | ||
|
||
## Installation | ||
|
||
You can install the development version of libminer from [GitHub](https://github.com/) with: | ||
|
||
```r | ||
# install.packages("devtools") | ||
devtools::install_github("ateucher/libminer") | ||
``` | ||
|
||
## Example usage | ||
|
||
To get a count of installed packages in each of your library locations, | ||
optionally with the total sizes, use the `lib_summary()` function: | ||
|
||
```{r example} | ||
library(libminer) | ||
lib_summary() | ||
# specify `sizes = TRUE` to calculate the total size on disk of your packages | ||
lib_summary(sizes = TRUE) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# libminer | ||
|
||
<!-- badges: start --> | ||
|
||
[![R-CMD-check](https://github.com/eemiljohansson/libminer/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eemiljohansson/libminer/actions/workflows/R-CMD-check.yaml) | ||
<!-- badges: end --> | ||
|
||
The goal of libminer is to provide an overview of your R library setup. | ||
It is a toy package created as a part of a workshop and not meant for | ||
serious use. | ||
|
||
## Installation | ||
|
||
You can install the development version of libminer from | ||
[GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("ateucher/libminer") | ||
``` | ||
|
||
## Example usage | ||
|
||
To get a count of installed packages in each of your library locations, | ||
optionally with the total sizes, use the `lib_summary()` function: | ||
|
||
``` r | ||
library(libminer) | ||
lib_summary() | ||
``` | ||
|
||
## Library | ||
## 1 /private/var/folders/9t/gsrg0j4n7532tzbczy_49d_h0000gp/T/RtmpNXqntB/temp_libpathde634e8ad5b3 | ||
## 2 /Users/emiljohansson/Library/Caches/org.R-project.R/R/renv/library/libminer-ceb45e55/R-4.3/aarch64-apple-darwin20 | ||
## 3 /Users/emiljohansson/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.3/aarch64-apple-darwin20/ac5c2659 | ||
## n_packages | ||
## 1 1 | ||
## 2 98 | ||
## 3 29 | ||
|
||
``` r | ||
# specify `sizes = TRUE` to calculate the total size on disk of your packages | ||
lib_summary(sizes = TRUE) | ||
``` | ||
|
||
## Library | ||
## 1 /private/var/folders/9t/gsrg0j4n7532tzbczy_49d_h0000gp/T/RtmpNXqntB/temp_libpathde634e8ad5b3 | ||
## 2 /Users/emiljohansson/Library/Caches/org.R-project.R/R/renv/library/libminer-ceb45e55/R-4.3/aarch64-apple-darwin20 | ||
## 3 /Users/emiljohansson/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.3/aarch64-apple-darwin20/ac5c2659 | ||
## n_packages lib_size | ||
## 1 1 15159 | ||
## 2 98 161383021 | ||
## 3 29 1630 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
url: https://eemiljohansson.github.io/libminer/ | ||
template: | ||
bootstrap: 5 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(libminer) | ||
|
||
test_check("libminer") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
test_that("lib_summary fails appropriately", { | ||
expect_error(lib_summary(sizes = "foo"), "not interpretable as logical") | ||
}) | ||
|
||
test_that("sizes argument works", { | ||
res <- lib_summary(sizes = TRUE) | ||
expect_equal(names(res), c("Library", "n_packages", "lib_size")) | ||
expect_type(res$lib_size, "double") | ||
}) |