new_pre_release_ids {smvr}R Documentation

Pre-release identifiers

Description

A class representing a collection of identifiers, which are used for representing pre-release versions.

There are two functions to create the pre_release_ids vector:

Usage

new_pre_release_ids(...)

parse_pre_release_ids(x)

Arguments

...

<dynamic-dots> Single pre-release identifiers. Each identifier can be something to be cast to a pre_release_identifier vector by vctrs::vec_cast(). All components must be of the same length or length 1 (will be recycled).

x

A character vector representing pre-release identifiers. Each identifier separated by a dot (.) will be parsed as a pre_release_identifier.

Details

If the components are empty, they are treated as the highest precedence pre-release ids, which is used to indicate that the version is not a pre-release version.

Value

A pre_release_ids vector.

Limitations

There are some limitations on the number of identifiers in some operations:

Please refer to the examples for details.

Examples

# Each components are concatenated with a dot
new_pre_release_ids("rc", 1:3)

ids <- parse_pre_release_ids(
  c("", "alpha.beta", "alpha.1", "beta", "beta.11", "beta.2")
)
ids

# Empty ids have the highest precedence
# (Used to indicate not a pre-release version)
vctrs::vec_sort(ids)

# Can be compared with string notation
ids[ids > "beta.2"]

# Limitations:
# 1. When comparing with a string, the number of identifiers in the string
#    must not exceed 5.
try(ids[ids > "beta.2.3.4.5.6"])

# This works since the string is parsed first.
ids[ids > parse_pre_release_ids("beta.2.3.4.5.6")]

# 2. When assigning, the number of identifiers in the value being assigned
#    must not exceed the number of identifiers in the target or 5,
#    whichever is larger.
try(ids[1] <- parse_pre_release_ids("beta.2.3.4.5.6"))

[Package smvr version 0.2.0 Index]