Skip to content
This repository was archived by the owner on May 21, 2021. It is now read-only.

Commit 59ce4d8

Browse files
Jean-Mathieu PotvinJean-Mathieu PotvinJean-Mathieu Potvin
authored
Merge features of 9002 release into main.
This is a big commit. 150 commits were squashed into it. The history is detailed below. It integrates a lot of new features that are detailed in NEWS.md and marks the 9002 development release. --- * Initial commit on class VectorBlueprint. Bundled doc in commit. This is incomplete work. The class name is temporary (at least for now) and and tests are ongoing. * Initial commit on class VectorBlueprints. Bundled doc in commit. Just like class VectorBlueprint, this is incomplete work. The class name is temporary (at least for now) and and tests are ongoing. * Change testthat for just tests in badges. * Insert joke / easter egg related to the great song I'm blue from Eiffel 65. Who said this needed to be serious? * Correct typos. * Preliminary work to include a $field slot in VectorBlueprint. This is still work in progress. - Include $length in class. - Include length arg in $initialize(). - Add a validation step for $length in $validate(). - Modify $format() to include or not $length. TBD, I am not satisfied with current format. - Change $as.list and $as.character bindings to $as_list and $as_character for consistency. * Latest improvements to VectorBlueprint. - Robustify $initialize() when length is ignored / NULL. Now favor NULL over missing. - $validate() now checks if $length < 0 when it is not NULL. - $format() is now more consistent. * Update collate field of DESCRIPTION and doc of Blueprint (updated @family Blueprint). * Update side files after build with VectorBlueprint and VectorBlueprints classes. * Add a Questions section. * Change how Blueprint object are printed. Result now includes package's version when $print() is called. * New utility internal function inject(). Useful to inject new named values into an existing R structure. Read doc for more information. * Update dependencies with packages yaml and jsonlite. - These packages are required to print and write JSON and YAML strings / files. These allows us to convert Blueprints objects to these conveninent and popular formats. - Also update URL and Contact fields, along with e-mail of author. * Update email of author to jm@potvin.xyz. Shorter and nicer. * Correct small typos. Forgot to use new names VectorBlueprint and VectorBlueprints at some places... These replaces very old names stemming from first prototype (Field and Fields). * Prepare terrain for inclusion of Github workflows. This workflows will launch R CMD CHECK on three popular OS whenever a commit or a merge is done in 'main'. This is conveninent, because it runs all unit tests and check builds in one swoop. Logos in README will change. Awaiting maturity of branch before changing this. * Set of small changes to class Blueprint. - Remove external constructor new_blueprint(). Will be replaced some day by a unified API; something like blueprint::new(mode). - Add valid_blueprint(), an external validator that checks an object's class and then validates it. - Changes unit tests accordingly. * Rename function is_valid_r6_instance() to validate_blueprint(). * Very light changes to function quiet() used for unit testing. * Remove VectorBlueprints class. Will be reintroduced later in dev cycle. * Changes to doc. * Rename class VectorBlueprint to Atomic. I will try to favor shorter syntax from now on. VectorBlueprint was a cool name, but it is too long and it's already implied that if you call a class from the package's namespace, you WILL get a blueprint. This is its purpose. * Reintroduce internal function valid_r6_instance(). Use simpler descriptions in unit tests. * Explicit testthat namespace. * Correct typo. Declare Imports in alphabetical order. * Remove R CMD INSTALL args. Don't keep source (this option sucks, let R reformat your code) and build for multiple architectures. * Correct small typos. * Introduce new function is_strict_atomic(). This function check if an object is a strict atomic: its class is itself derived from base types. This is safer. * New Blueprinter %bp% operators. Moved from class Atomic and generalized to all future classes of the package. * New script to hold default options. * Collection of small changes. - Include options.R mechanisms. - Rename as_list_utf8() to as_utf8_list(). - Correct typos. - Rename arg atom to atomic. - Move comments inside functions (when applicable). This follows the removal of stupid R CMD INSTALL keep.source option. - Lightly change how Atomic objects are printed. This follows the change introduced in $print() method of class Blueprint. - Light reformat of code. - Remove %>>% operator. Replaced by %bp% defined in Blueprinter.R. - Forgot to add argument validate in S3 dispatchers. * Update side-files. * Favor is_strict_atomic() over is.atomic(). Correct typos. * Correct typos in doc following R CMD CHECK results. * Favor is_strict_atomic() over is.atomic(). * Include assertions.R. This is needed for is_strict_atomic(). * Remove explicit format.CLASS() functions. Let R6 handle S3 dispatch. * New internal generic function as_utf8() to encode characters found in R structures to UTF-8. This is required for YAML and JSON I/O. This function replaces old method as_utf8_list() of class Atomic. * Total revamo of unit tests related to is_strict_atomic(). Now much more robust. Thoroughly documented. * Correct typos and introduce small optimizations. Nothing fancy. * New $generate() method. Useful to spawn vectors from Atomic blueprints. * Remove space. * Redesign function is_strict_atomic(). This version is work in progress and should flag pure vectors. See doc. Add better documentation of what is an Atomic value. * Correct typos in doc. * New function is_single(). Add doc. * New package doc file. * Update package's description and shorten it. Add package doc to Collate order. * Rename jsonlite_atomic_opts() to opts_jsonlite_atomic(). * Write NAs as NA, not null. * Remove forgotten comment. * Set of small changes. Moving to strict atomic types. - Remove private field classes. Not needed anymore. - Support of single values. - Check for $type values. - Revamp of $compare(). Much better now. - Adjust $generate(). Should be good now. - Correct typos. * Favor stopifnot() in internal utility functions (when possible). * New internal function add_headers(). * Robustify certain error checks. Nothing fancy. * Change function name in tests following previous commit. * Favor testthat::skip_() functions within tests. * New private field: $valid_types. This is a constant character vector holding strict atomic types' names. * Small adjustments to code. * Add package utils to Imports. * Bugfix in add_headers(). Force type to lower cases for match(). * Finalize methods $as_yaml() and $as_json(). Favor argument .validate over validate. We want this arg to be rather low-level, but still available to users. * Simplify doc. * Light change to syntax in add_headers(). * Partially re-arrange script. * Major re-arrangement of unit tests. - Better uniformity enforced. - use smaller test chunks. - Remove some useless comments. - Split big contexts into smaller ones, whenever we feel it is necessary. - Add some further small tests here and there for some specific edge cases. * Use roxygen2 templates. Ignore them in builds. * Various small improvements to doc. Now much more consistent. * Major doc revamp. Should be pretty much final now. * Small changes to doc. Now more precise. * Bugfix. Export internal methods, even if they are tied to an unexported internal generic. * Add arg ... to S3 methods to avoid R CMD CHECK errors. This argument is ignored. * Update side-files following significant progress on doc. * Use a NEWS file. * Remove unecessary lines. * Remove msg related to latest developments location (branch). * Ignore tests/testthat/_snaps/ in builds. This folder is created automatically by testthat. * Robustify %bp%. Add argument checks. * @symbol can now also be a scalar character. * New unit tests for %bp% operator (Blueprinter). * Add name of %bp% (Blueprinter). * Bugfix. When length > 0L, Atomic$new() was not returning a proper prototype for single values. * Major revamp of class Blueprint (again). - Favor active fields over regular fields. Values that should not be changed are now protected by function scopes. - Hide package version in private field pkg_ver. Make this value accessible through active field. - Simplify validate() methods. - Remove argument .validate everywhere. There is no field to validate now. - New get() and set() low-level mechanisms. - Change doc. - Change unit tests. * Small changes following revamp of super-class Blueprint. Correct small typos. * Supress warnings stemming from internal coercion of 'length' to integer in $initialize(). * New objects used in unit tests of class Atomic. * Add small comment in tests. * Remove unecessary missing arg checks. R does it anyway. * Bugfix. Functions used in tryCatch() loops needs to have an argument to properly work. * Correct typos. * Robustify tests following covr report. * Correct small typos in code and doc. * Standardization of unit tests structure. * Change order of arguments of add_headers(). * Correct typo. * Update side-files. * Separate self$format() and cat() calls. * Small changes to doc of $get() and $set(). * Test if class name and pkg version are returned by $print(). * Snapshots are now used. Using testthat 3e. Using covr. * Preparing terrain for merge into 'main'. - Bump dev version. - Bump test results. * Various small improvement followjg test phase. - Better doc. - Small bugfixes. - Add examples. - New $set(). Supersedes Blueprint$set(). We needed a way to prevent users from changing $type. * New low-level $get() and $set() methods. Small improvement to doc. Bugfixes. * New default YAML handlers functions to be passed to yaml::as.yaml(). * Change order of args in vapply() wrappers. Put those 'names' args at the end. * Improvements for function inject(). inject() is becoming essential to the pkg. Now, if the very first element passed to ... is either a list or a vector of length greater than 1, it is assumed that the child elements of ..1 should be used instead of ... Therefore, you can either pass args to inject() by parts (...) or as a whole (..1). * Update doc side files following fixes and improvements. * New roxygen2 templates for parameters field and value. * Initial commit to unit testing framework of class Atomic. This is a huge file because Atomic is an important class. It needs to be robust. We now uses snapshot tests introduced in testthat 3e. This is awesome for testing outputs. * Collective changes to unit testing framework. These changes were introduced at the same time the tests for class Atomic were written. This is because the framework needs to be as consistent as possible and thus, a lot of small changes here and there were introduced. It would not be useful to list them all and justify them. They are simply maturing with the package. * Bugfix. Ensure that a TRUE/FALSE value is returned. Change tests to reflect that. * Favor hyphens over underscores in file names. * Simplify script. * Rename validate_blueprint() to report_errors(). Better name. * Correct syntax typo. * Prepare terrain ahead of merge and bump dev version to 9002. * Remove snapshots. They can be generated anytime from unit tests so we don't need to track them. * Start ignoring testthat 3e snapshots. * New assertion functions is_named_list() and is_named_vctr(). Now used in codebase. * Correct various small typos. * Rewrite function inject() as a more robust S3 generic function with dedicated method for lists and vectors (default). * Add arg 'source_header' to add_headers(). New create_source_header() function that is called by add_headers(). Adding a 'source' header can now be deactivated. This will be useful in the future. * Assertion is_*() functions gain a new function a new accept_na arg. NA values can now be accepted/rejected as valid/invalid values in assertions. * Specify default value for args of internal functions. The behavior of those functions was lightly altered in order to handle these new default values. Specifying default args helps us specifying the contract, the interface. * Revamp of internal function opts_json_atomic(). The function now have a similar behavior to opts_yaml_handlers. It has an argument ... that captures named arguments and inject them into a default list of values with inject(). Default values can be overridden. Moreover, by doing so, we completely hide inject() from users; this function won't appear directly in codebase of methods. * New .source_header parameter template. * Remove default value. This is explicited b y @Usage. * Add snapshot test for $print() when length is ignored. * Collective set of small changes. - Add template parameter .source_header to $as_json() and $as_yaml(). - Add further details to arg ... of these two methods. - Specify default values to args when appropriate. - Change calls to add_headers() and opts_*() functions following their revamps. - Correct typos. * Specify default values of arguments when appropriate. Change behavior of methods to match that. * Add some arguments checks to tests of Atomic and Blueprint. * Update side files following changes. * Change order of tests to match order of methods. * Light rework of methods $as_yaml() and %as_json(). - Specify default values to args. - source_header becomes a regular argument. - Methods now return $self if output is written to file. * Small changes to doc. Added some relevent details. * Small changes in code order for consistency. * Split tests of classes Blueprint and Atomic in multiple files. - The main files holds all unit tests related to the machanisms. - The files marked with a -outputs focuses on outputs printed to a console or a file. - Add tests, robustify some others. Correct coverage to obtain 100% covr score. Remove temp notes related to covr in Atomic. - Light reformat. * Correct typo. * Prepare terrain for 9002 dev release and merge into main. * Small changes. - Change error msgs to be consistent with other error msgs of the package. - Arg 'name' must be a non-empty, non-NA scalar character. * Restrict field $name to non-empty, non-NA scalar characters. * New Atomic$bind() method. This is still an experimental feature. * Update README prior to 9002 build release. * Include testthat snapshots. They are stable now. Don't ignore them. * Correct various very small typos following last revision before 9002 release. * Run test of R 3.6.X, not R > 4.0. Transition to R4 will be done later in the year. * Bugfix. In examples, write to tempfiles, not to files located in root. Co-authored-by: Jean-Mathieu Potvin <jean-mathieu_potvin@cooperators.ca> Co-authored-by: Jean-Mathieu Potvin <info@jeanmathieupotvin.com>
1 parent 398ba0d commit 59ce4d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4023
-348
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
^\.Rproj\.user$
33
^\.gitignore$
44
^\.dev$
5+
^\.github$
6+
^man-roxygen$

.Rproj

-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ StripTrailingWhitespace: Yes
1717

1818
BuildType: Package
1919
PackageUseDevtools: Yes
20-
PackageInstallArgs: --no-multiarch --with-keep.source
2120
PackageRoxygenize: rd,collate,namespace,vignette

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

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Github CI/CD workflow
2+
#
3+
# This workflows was generated automatically by
4+
# usethis::use_github_action_check_standard(). It runs R CMD CHECK
5+
# via the rcmdcheck package on three OS (Ubuntu, macOS and Windows)
6+
# that runs the latest release of R. This is appropriate for package
7+
# to be submitted to CRAN.
8+
on:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
branches:
14+
- main
15+
16+
name: R-CMD-check
17+
18+
jobs:
19+
R-CMD-check:
20+
runs-on: ${{ matrix.config.os }}
21+
22+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
config:
28+
- {os: windows-latest, r: '3.6.3'}
29+
- {os: macOS-latest, r: '3.6.3'}
30+
- {os: ubuntu-20.04, r: '3.6.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
31+
32+
env:
33+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
34+
RSPM: ${{ matrix.config.rspm }}
35+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
40+
- uses: r-lib/actions/setup-r@v1
41+
with:
42+
r-version: ${{ matrix.config.r }}
43+
44+
- uses: r-lib/actions/setup-pandoc@v1
45+
46+
- name: Query dependencies
47+
run: |
48+
install.packages('remotes')
49+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
50+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
51+
shell: Rscript {0}
52+
53+
- name: Cache R packages
54+
if: runner.os != 'Windows'
55+
uses: actions/cache@v2
56+
with:
57+
path: ${{ env.R_LIBS_USER }}
58+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
59+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
60+
61+
- name: Install system dependencies
62+
if: runner.os == 'Linux'
63+
run: |
64+
while read -r cmd
65+
do
66+
eval sudo $cmd
67+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
68+
69+
- name: Install dependencies
70+
run: |
71+
remotes::install_deps(dependencies = TRUE)
72+
remotes::install_cran("rcmdcheck")
73+
shell: Rscript {0}
74+
75+
- name: Check
76+
env:
77+
_R_CHECK_CRAN_INCOMING_REMOTE_: false
78+
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
79+
shell: Rscript {0}
80+
81+
- name: Upload check results
82+
if: failure()
83+
uses: actions/upload-artifact@main
84+
with:
85+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
86+
path: check

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ vignettes/*.pdf
3232
*.utf8.md
3333
*.knit.md
3434

35-
# Files in development that should not be committed for a temporary period of time
35+
# Files in development
3636
.dev/
37+
38+
# Github workflows outputs
39+
.github/*.html

DESCRIPTION

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
Package: blueprint
22
Title: Efficient data schemas generator for R
3-
Version: 0.0.0.9001
3+
Version: 0.0.0.9002
44
Authors@R:
55
person(given = "Jean-Mathieu",
66
family = "Potvin",
77
role = c("aut", "cre"),
8-
email = "info@potvin.xyz",
8+
email = "jm@potvin.xyz",
99
comment = c(ORCID = "0000-0002-8237-422X"))
10-
Description: An efficient and consistent interface to generate
11-
all sorts of data schemas in R. Schemas are objects that
12-
dictate what should be put in R data structures. Blueprint
13-
is neutral. It works with any kind of recursive structure.
10+
Description: An unopinionated consistent interface to generate
11+
all sorts of data schemas in R. Data schemas are R objects
12+
that dictate what should go in R data structures.
1413
License: MIT + file LICENSE
1514
Encoding: UTF-8
1615
LazyData: true
1716
Roxygen: list(markdown = TRUE, r6 = TRUE)
1817
RoxygenNote: 7.1.1
18+
Config/testthat/edition: 3
1919
Depends:
2020
R (>= 3.5.0)
2121
Imports:
22-
R6
22+
R6,
23+
jsonlite,
24+
utils,
25+
yaml
2326
Suggests:
27+
covr,
2428
testthat
2529
ByteCompile: true
2630
NeedsCompilation: no
27-
URL: https://github.com/jeanmathieupotvin/blueprint, https://blueprint.potvin.xyz
31+
URL: https://blueprint.potvin.xyz, https://github.com/jeanmathieupotvin/blueprint
2832
BugReports: https://github.com/jeanmathieupotvin/blueprint/issues
29-
Contact: jean-mathieu_potvin@cooperators.ca
33+
Contact: info@blueprint.potvin.xyz
3034
Collate:
3135
'assertions.R'
3236
'utilities.R'
3337
'Blueprint.R'
38+
'options.R'
39+
'Atomic.R'
40+
'Blueprinter.R'
41+
'blueprint-package.R'

NAMESPACE

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method(format,Blueprint)
3+
S3method(as.character,Atomic)
4+
S3method(as.list,Atomic)
5+
S3method(as_utf8,character)
6+
S3method(as_utf8,default)
7+
S3method(as_utf8,list)
8+
S3method(inject,default)
9+
S3method(inject,list)
10+
export("%bp%")
11+
export(Atomic)
412
export(Blueprint)
13+
export(is_atomic)
514
export(is_blueprint)
15+
export(is_named_list)
16+
export(is_named_vctr)
617
export(is_scalar_character)
718
export(is_scalar_integer)
819
export(is_scalar_logical)
920
export(is_scalar_numeric)
10-
export(new_blueprint)
21+
export(is_single)
22+
export(is_strict_atomic)
23+
export(valid_atomic)
24+
export(valid_blueprint)

NEWS.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# blueprint 0.0.0.9002
2+
3+
* **New concepts**
4+
- *strict atomic types*
5+
+ Strict atomic are R types considered to be atomic objects in
6+
the package: `NULL`, `logical`, `integer`, `single` (yes, `single`, see
7+
documentation of the package for more information), `double`, `complex`,
8+
`character` and `raw` vectors.
9+
+ These are the fundamental building blocks of R.
10+
* **New classes**
11+
- `Atomic`
12+
+ A class to hold blueprints of *strict atomic vectors*. This is an
13+
important class packed with a lot of features. Just like strict atomic
14+
vectors are the building blocks of R, so is class `Atomic` for the
15+
package. All other `blueprint`'s classes will reuse this class.
16+
* **New features**
17+
- A new `%bp%` operator which can be used to construct blueprints in a
18+
concise way. We call it the *Blueprinter*.
19+
- New assertion functions: `is_single()`, `is_strict_atomic()`,
20+
`is_named_vctr()` and `is_named_list()`. These are very useful.
21+
* **Important changes**
22+
- Significant changes to class `Blueprint` to ensure consistency with class
23+
`Atomic`.
24+
- Package now imports packages `jsonlite` and `yaml` for I/O.
25+
* **Other important changes**
26+
- Hundreds of new unit tests. We now use a consistent test structure derived
27+
from `testthat` 3e edition.
28+
- New internal mechanisms / utility functions. They are more robust and
29+
better tested.
30+
- New options system for I/O with packages `jsonlite` and `yaml`.
31+
- New (experimental) Github workflows for future CI/CD pipeline.
32+
33+
# blueprint 0.0.0.9001
34+
35+
* **Package creation. Start tracking development process.**
36+
* **New features**
37+
- Blueprint
38+
+ A super-class that all other classes inherit.
39+
+ Provides low-level mechanisms such as `$get()` and `$set()` methods.

0 commit comments

Comments
 (0)