ropensci / ruODK

ruODK: An R Client for the ODK Central API
https://docs.ropensci.org/ruODK/
GNU General Public License v3.0
42 stars 13 forks source link

Handle ODK Central semver #150

Closed florianm closed 7 months ago

florianm commented 1 year ago

Feature

ruODK uses an environment variable ODKC_VERSION to keep track of the major and minor version of ODK Central. This helps to determine backwards incompatible behaviour. The internal handling is somewhat hacky in that the major.minor version is treated as floating point as.double number which worked completely fine with the old ODK Central versioning scheme.

With the new ODK Central versioning scheme that uses the release year as major version, and running minor and patch versions, we should handle the Central version better.

I propose to use the R package semver which gracefully compares version strings across both schemas.

versions <- semver::parse_version(c("1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "2023.1.1", "2023.2.1", "2023.2.2"))

versions
#> [1] Maj: 1 Min: 0 Pat: 0
#> 
#> [2] Maj: 1 Min: 1 Pat: 0
#> 
#> [3] Maj: 1 Min: 2 Pat: 0
#> 
#> [4] Maj: 1 Min: 3 Pat: 0
#> 
#> [5] Maj: 1 Min: 4 Pat: 0
#> 
#> [6] Maj: 1 Min: 5 Pat: 0
#> 
#> [7] Maj: 2023 Min: 1 Pat: 1
#> 
#> [8] Maj: 2023 Min: 2 Pat: 1
#> 
#> [9] Maj: 2023 Min: 2 Pat: 2

rank(versions)
#> [1] 1 2 3 4 5 6 7 8 9

Created on 2023-08-03 with reprex v2.0.2