Skip to content

Commit

Permalink
Merge pull request #67 from ropensci/subc
Browse files Browse the repository at this point in the history
Refactor internal code
  • Loading branch information
dieghernan authored Mar 7, 2024
2 parents e88aa91 + 3f7182a commit be9eb01
Show file tree
Hide file tree
Showing 108 changed files with 4,692 additions and 4,232 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: '4.0'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters: linters_with_defaults() # see vignette("lintr")
encoding: "UTF-8"
exclusions: list(
"data-raw",
"tests/testthat/test_ci/test-full_cff.R",
"tests/testthat/test_ci",
"vignettes/cffr.Rmd",
"vignettes/bibtex_cff.Rmd"
)
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.5.0.9000
# CITATION file created with {cffr} R package, v0.99.0.9000
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

Expand All @@ -8,7 +8,7 @@ message: 'To cite package "cffr" in publications use:'
type: software
license: GPL-3.0-or-later
title: 'cffr: Generate Citation File Format (''cff'') Metadata for R Packages'
version: 0.5.0.9000
version: 0.99.0.9000
doi: 10.21105/joss.03900
abstract: The Citation File Format version 1.2.0 <https://doi.org/10.5281/zenodo.5171937>
is a human and machine readable file format which provides citation metadata for
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cffr
Title: Generate Citation File Format ('cff') Metadata for R Packages
Version: 0.5.0.9000
Version: 0.99.0.9000
Authors@R: c(
person("Diego", "Hernangómez", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8457-4658")),
Expand Down
18 changes: 18 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
S3method("[",cff_pers_list)
S3method("[",cff_ref_list)
S3method(as.data.frame,cff)
S3method(as.data.frame,cff_pers)
S3method(as.data.frame,cff_pers_list)
S3method(as.data.frame,cff_ref)
S3method(as.data.frame,cff_ref_list)
S3method(as.list,cff)
S3method(as.person,cff)
S3method(as.person,cff_pers)
S3method(as.person,cff_pers_list)
S3method(as.person,cff_ref)
S3method(as.person,cff_ref_list)
S3method(as_bibentry,"NULL")
S3method(as_bibentry,cff)
S3method(as_bibentry,cff_ref)
S3method(as_bibentry,cff_ref_list)
S3method(as_bibentry,character)
S3method(as_bibentry,default)
S3method(as_bibentry,list)
S3method(as_cff,Bibtex)
S3method(as_cff,bibentry)
S3method(as_cff,default)
Expand All @@ -14,6 +30,8 @@ S3method(head,cff)
S3method(print,cff)
S3method(tail,cff)
S3method(toBibtex,cff)
S3method(toBibtex,cff_pers)
S3method(toBibtex,cff_pers_list)
export(as.cff)
export(as_bibentry)
export(as_cff)
Expand Down
53 changes: 41 additions & 12 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ to non-core functions**, hence the natural workflow (`cff_create()` →

## Major changes

### Classes and methods

Now **cffr** implements a new class system for
[`definitions.reference`](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreference),
[`definitions.person`](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsperson)
and
[`definitions.entity`](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsentity)
objects:

- List of `definitions.reference` (e.g, `references)` has class
`cff_ref_list, cff` and individual elements (e.g `preferred-citation` or
each member of `references`) has class `cff_ref, cff`.
- List of `definitions.person` or `definitions.entity` (e.g. `authors`,
`contact`) has class `cff_pers_list, cff` and individual elements (e.g
`publisher` or each member of `authors`) has class `cff_pers, cff`.

This change allow to write specific [S3
Methods](https://adv-r.hadley.nz/s3.html) and extend the capabilities of the
package.

- New `as_cff()` S3 generic method (replacing `as.cff()`): This method coerces
**R** objects to `cff` class format. Current methods provided are:
- `as_cff.Bibtex()`.
- `as_cff.bibentry()`, replacing cff_parse_citation().
- `as_cff.person()`, similar to `as_cff_person()` but only for `person`
objects. We recommend using `as_cff_person()` since it can coerce also
string representing authors in BibTeX markup (`"{von Neumen}, James"`),
that can't be captured properly via methods.
- New `as_bibentry()` method for a variety of classes (`character`, `list`,
`NULL` and classes defined by **cffr**).
- The following **base** and **utils** methods supports now `cff` class:
(TODO)
- `as.data.frame.cff()`.
- `as.person()`, although **only** for `definitions.person` or
`definitions.entity` (e.g. `authors`, `contacts`, `editors`,
`publisher,` etc.).
- `head.cff()`, `tail.cff()`.
- `toBibtex.cff()`.

### API

The API has been completely reviewed to provide more clarity on functions naming
Expand All @@ -17,8 +56,8 @@ would warn when used, providing advice on the replacement function.

#### Deprecation

- `cff_to_bibtex()` and `cff_extract_to_bibtex()`: replaced by
`as_bibentry()`.
- `cff_to_bibtex()` and `cff_extract_to_bibtex()`: replaced by `as_bibentry()`
method.
- `cff_from_bibtex()`: replaced by `cff_read_bib()` (for `*.bib` files) and
`cff_read_bib_text()` (for character strings).
- `write_bib()` and `write_citation()` : replaced by `cff_write_bib()` and
Expand All @@ -33,14 +72,6 @@ would warn when used, providing advice on the replacement function.

### New capabilities

- New `as_cff()` S3 generic method (replacing `as.cff()`): This method coerces
**R** objects to `cff-class` format. Current methods provided are:
- `as_cff.Bibtex()`.
- `as_cff.bibentry()`, replacing cff_parse_citation().
- `as_cff.person()`, similar to `as_cff_person()` but only for `person`
objects. We recommend using `as_cff_person()` since it can parse also
string representing authors in BibTeX markup (`"{von Neumen}, James"`),
that can't be captured properly via methods.
- Now reading from external files is performed exclusively by `cff_read()`
(that is designed to fit all supported file types on a single entry point)
and the new specific readers (that are used under the hood by `cff_read()`),
Expand All @@ -54,8 +85,6 @@ would warn when used, providing advice on the replacement function.
## Other changes

- Minimum **R** version required now is **4.0.0**.
- Now `class()` of `cff` objects are `c("cff", "list")` instead of single
value (`"cff"`).
- New S3 **base** and **utils** methods added:
- `as.data.frame.cff().`
- `as.person.cff()`, that provides results **only** for CFF keys defined
Expand Down
Loading

0 comments on commit be9eb01

Please sign in to comment.