Skip to content

Commit a170fb4

Browse files
authored
Merge pull request #15 from KWB-R/dev
Release v0.2.0
2 parents 76ee94d + c0eb00a commit a170fb4

29 files changed

Lines changed: 406 additions & 212 deletions

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
^index\.md$
1414
^README\.md$
1515
^R/\.setup\.R
16+
^\.github$

.github/workflows/R-CMD-check.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- main
6+
- dev
7+
pull_request:
8+
branches:
9+
- master
10+
- main
11+
- dev
12+
13+
name: R-CMD-check
14+
15+
jobs:
16+
R-CMD-check:
17+
runs-on: ${{ matrix.config.os }}
18+
19+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
config:
25+
- {os: macOS-latest, r: 'release'}
26+
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
27+
- {os: windows-latest, r: 'devel'}
28+
- {os: windows-latest, r: 'oldrel'}
29+
- {os: windows-latest, r: 'release'}
30+
31+
env:
32+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
33+
RSPM: ${{ matrix.config.rspm }}
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
38+
- uses: r-lib/actions/setup-r@master
39+
with:
40+
r-version: ${{ matrix.config.r }}
41+
42+
- uses: r-lib/actions/setup-pandoc@master
43+
44+
- name: Query dependencies
45+
run: |
46+
install.packages('remotes')
47+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2)
48+
shell: Rscript {0}
49+
50+
- name: Cache R packages
51+
if: runner.os != 'Windows'
52+
uses: actions/cache@v1
53+
with:
54+
path: ${{ env.R_LIBS_USER }}
55+
key: ${{ runner.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('depends.Rds') }}
56+
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3-
57+
58+
- name: Install system dependencies
59+
if: runner.os == 'Linux'
60+
env:
61+
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
62+
run: |
63+
Rscript -e "remotes::install_github('r-hub/sysreqs')"
64+
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
65+
sudo -s eval "$sysreqs"
66+
- name: Install dependencies
67+
run: |
68+
remotes::install_deps(dependencies = TRUE)
69+
remotes::install_cran("rcmdcheck")
70+
shell: Rscript {0}
71+
72+
- name: Check
73+
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check")
74+
shell: Rscript {0}
75+
76+
- name: Upload check results
77+
if: failure()
78+
uses: actions/upload-artifact@master
79+
with:
80+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
81+
path: check

.github/workflows/pkgdown.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- master
6+
- dev
7+
8+
name: pkgdown
9+
10+
jobs:
11+
pkgdown:
12+
runs-on: macOS-latest
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: r-lib/actions/setup-r@master
19+
20+
- uses: r-lib/actions/setup-pandoc@master
21+
22+
- name: Query dependencies
23+
run: |
24+
install.packages('remotes')
25+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
26+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
27+
shell: Rscript {0}
28+
29+
- name: Cache R packages
30+
uses: actions/cache@v2
31+
with:
32+
path: ${{ env.R_LIBS_USER }}
33+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
34+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
35+
36+
- name: Install dependencies
37+
run: |
38+
remotes::install_deps(dependencies = TRUE)
39+
install.packages("pkgdown", type = "binary")
40+
shell: Rscript {0}
41+
42+
- name: Install package
43+
run: R CMD INSTALL .
44+
45+
- name: Deploy package
46+
run: |
47+
git config --local user.email "actions@github.com"
48+
git config --local user.name "GitHub Actions"
49+
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'

.github/workflows/pr-commands.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
issue_comment:
3+
types: [created]
4+
name: Commands
5+
jobs:
6+
document:
7+
if: startsWith(github.event.comment.body, '/document')
8+
name: document
9+
runs-on: macOS-latest
10+
env:
11+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: r-lib/actions/pr-fetch@master
15+
with:
16+
repo-token: ${{ secrets.GITHUB_TOKEN }}
17+
- uses: r-lib/actions/setup-r@master
18+
- name: Install dependencies
19+
run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)'
20+
- name: Document
21+
run: Rscript -e 'roxygen2::roxygenise()'
22+
- name: commit
23+
run: |
24+
git add man/\* NAMESPACE
25+
git commit -m 'Document'
26+
- uses: r-lib/actions/pr-push@master
27+
with:
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}
29+
style:
30+
if: startsWith(github.event.comment.body, '/style')
31+
name: style
32+
runs-on: macOS-latest
33+
env:
34+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
35+
steps:
36+
- uses: actions/checkout@v2
37+
- uses: r-lib/actions/pr-fetch@master
38+
with:
39+
repo-token: ${{ secrets.GITHUB_TOKEN }}
40+
- uses: r-lib/actions/setup-r@master
41+
- name: Install dependencies
42+
run: Rscript -e 'install.packages("styler")'
43+
- name: Style
44+
run: Rscript -e 'styler::style_pkg()'
45+
- name: commit
46+
run: |
47+
git add \*.R
48+
git commit -m 'Style'
49+
- uses: r-lib/actions/pr-push@master
50+
with:
51+
repo-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- main
6+
pull_request:
7+
branches:
8+
- master
9+
- main
10+
11+
name: test-coverage
12+
13+
jobs:
14+
test-coverage:
15+
runs-on: macOS-latest
16+
env:
17+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- uses: r-lib/actions/setup-r@master
22+
23+
- uses: r-lib/actions/setup-pandoc@master
24+
25+
- name: Query dependencies
26+
run: |
27+
install.packages('remotes')
28+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
29+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
30+
shell: Rscript {0}
31+
32+
- name: Cache R packages
33+
uses: actions/cache@v1
34+
with:
35+
path: ${{ env.R_LIBS_USER }}
36+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
37+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
38+
39+
- name: Install dependencies
40+
run: |
41+
install.packages(c("remotes"))
42+
remotes::install_deps(dependencies = TRUE)
43+
remotes::install_cran("covr")
44+
shell: Rscript {0}
45+
46+
- name: Test coverage
47+
run: covr::codecov()
48+
shell: Rscript {0}

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: kwb.endnote
22
Title: Helper Functions for Analysing KWB Endnote Library
33
(Exported as .xml)
4-
Version: 0.1.0
4+
Version: 0.2.0
55
Authors@R:
66
c(person(given = "Michael",
77
family = "Rustler",
@@ -13,6 +13,8 @@ Authors@R:
1313
role = "ctb",
1414
email = "hauke.sonnenberg@kompetenz-wasser.de",
1515
comment = c(ORCID = "0000-0001-9134-2871")),
16+
person(given = "FAKIN",
17+
role = "fnd"),
1618
person(given = "Kompetenzzentrum Wasser Berlin gGmbH (KWB)",
1719
role = "cph"))
1820
Description: Helper Functions For Analysing KWB Endnote Library
@@ -35,7 +37,8 @@ Imports:
3537
tibble,
3638
tidyr,
3739
wordcloud2,
38-
xml2
40+
xml2,
41+
plotly
3942
Suggests:
4043
covr,
4144
knitr,
@@ -46,5 +49,5 @@ Remotes:
4649
github::kwb-r/kwb.utils
4750
Encoding: UTF-8
4851
LazyData: true
49-
RoxygenNote: 6.1.1
52+
RoxygenNote: 7.1.1
5053
VignetteBuilder: knitr

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# kwb.endnote 0.0.0.9000
22

3+
* Move to GitHub Actions as CI (from Travis/Appveyor)
34
* Added a `NEWS.md` file to track changes to the package.
45

56
* see https://style.tidyverse.org/news.html for writing a good `NEWS.md`

R/check_for_differences.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#' ### Check differences between two different versions of "KWB_documents.xml"
1818
#' ############################################################################
1919
#'
20-
#' old_xml <- extdata_file("2019-01-14_KWB_documents.xml")
21-
#' new_xml <- extdata_file("2019-07-09_KWB_documents.xml")
20+
#' old_xml <- extdata_file("2020-05-25_KWB-documents.xml")
21+
#' new_xml <- extdata_file("2020-06-17_KWB-documents.xml")
2222
#' old_list <- kwb.endnote::create_endnote_list(old_xml)
2323
#' new_list <- kwb.endnote::create_endnote_list(new_xml)
2424
#' old_df <- kwb.endnote::create_references_df(old_list)

R/create_references_df_from_list.R

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# colbind: Wrapper around dplyr::bind_cols(). Makes sure that no rows get lost
2+
# if the data frame to add has no rows.
3+
colbind <- function(df, df_2) {
4+
if (nrow(df_2) == 0L) {
5+
# Return the original data frame if the data frame to add has no columns
6+
if (ncol(df_2) == 0L) {
7+
return(df)
8+
}
9+
# Give the data frame to add one empty row (full of NA)
10+
df_2 <- df_2[1L, ]
11+
}
12+
dplyr::bind_cols(df, df_2)
13+
}
14+
115
#' @noRd
216
#' @keywords internal
317
null_to_na <- function(x, na_fill = NA_character_) {
@@ -154,6 +168,11 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
154168
collapse_val = "",
155169
element = 1)
156170
}
171+
172+
replace_newline_with_semicolon <- function(text) {
173+
gsub("\r", ", ", text)
174+
}
175+
157176
get_titles_style <- function(path) get_style(c("titles", path))
158177
get_period_style <- function(path) get_style(c("periodical", path))
159178
get_dates_style <- function(path) get_style(c("dates", path))
@@ -164,11 +183,11 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
164183
ref_type_name = attr(get_record_entry("ref-type"), which = "name"),
165184
abstract = get_abstract(record_list, collapse)
166185
) %>%
167-
dplyr::bind_cols(get_keywords(record_list, collapse = collapse)) %>%
168-
dplyr::bind_cols(get_authors(record_list, collapse = collapse)) %>%
169-
dplyr::bind_cols(get_secondary_authors(record_list, collapse = collapse)) %>%
170-
dplyr::bind_cols(get_tertiary_authors(record_list, collapse = collapse)) %>%
171-
dplyr::bind_cols(
186+
colbind(get_keywords(record_list, collapse = collapse)) %>%
187+
colbind(get_authors(record_list, collapse = collapse)) %>%
188+
colbind(get_secondary_authors(record_list, collapse = collapse)) %>%
189+
colbind(get_tertiary_authors(record_list, collapse = collapse)) %>%
190+
colbind(
172191
tibble::tibble(
173192
database_name = get_record_entry("database")[[1]],
174193
database_path = attr(get_record_entry("database"), which = "path"),
@@ -191,13 +210,13 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
191210
authaddress = get_style("auth-address"),
192211
edition = get_style("edition"),
193212
worktype = get_style("work-type"),
194-
label = get_style("label"),
213+
label = replace_newline_with_semicolon(get_style("label")),
195214
isbn = get_style("isbn"),
196-
language = get_style("language")
215+
language = replace_newline_with_semicolon(get_style("language"))
197216
)
198217
) %>%
199-
dplyr::bind_cols(get_pdfurls(record_list, collapse = collapse)) %>%
200-
dplyr::bind_cols(tibble::tibble(
218+
colbind(get_pdfurls(record_list, collapse = collapse)) %>%
219+
colbind(tibble::tibble(
201220
urls_related = get_style(c("urls", "related-urls", "url")),
202221
electronic_resource_num = get_style("electronic-resource-num"),
203222
custom1 = get_style("custom1"),

0 commit comments

Comments
 (0)