Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter #35

Merged
merged 19 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
purrr,
rlang (>= 1.1.0),
S7,
snakecase,
stbl,
yaml
Suggests:
Expand Down
30 changes: 21 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
# Generated by roxygen2: do not edit by hand

S3method(length,"rapid::api_contact")
S3method(length,"rapid::api_info")
S3method(length,"rapid::api_license")
S3method(length,"rapid::contact")
S3method(length,"rapid::info")
S3method(length,"rapid::license")
S3method(length,"rapid::rapid")
S3method(length,"rapid::server_variable")
S3method(length,"rapid::servers")
export(api_contact)
export(api_info)
export(api_license)
S3method(length,"rapid::string_replacements")
export(as_contact)
export(as_info)
export(as_license)
export(as_rapid)
export(as_server_variables)
export(as_servers)
export(as_string_replacements)
export(contact)
export(info)
export(license)
export(rapid)
export(server_variable)
export(server_variable_list)
export(server_variables)
export(servers)
export(string_replacements)
if (getRversion() < "4.3.0") importFrom("S7", "@")
importFrom(S7,class_any)
importFrom(S7,class_character)
importFrom(S7,class_list)
importFrom(S7,class_missing)
importFrom(glue,glue)
importFrom(rlang,"%||%")
importFrom(rlang,check_dots_empty)
importFrom(rlang,check_dots_used)
importFrom(stbl,stabilize_chr_scalar)
importFrom(stbl,to_chr_scalar)
importFrom(yaml,read_yaml)
40 changes: 7 additions & 33 deletions R/00-properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

character_scalar_property <- function(x_arg, ...) {
S7::new_property(
class = S7::class_character,
class = class_character,
setter = function(self, value) {
# TODO: Watch S7 dev to see if this can be less hacky.
call <- rlang::caller_env(3)
value <- value %||% character()
value <- stbl::stabilize_chr_scalar(
Expand All @@ -20,39 +19,9 @@ character_scalar_property <- function(x_arg, ...) {
)
}

character_property <- function(x_arg, ...) {
S7::new_property(
class = S7::class_character,
setter = function(self, value) {
# TODO: Watch S7 dev to see if this can be less hacky.
call <- rlang::caller_env(3)
value <- value %||% character()
value <- stbl::stabilize_chr(
value,
allow_null = FALSE,
x_arg = x_arg,
call = call,
...
)
S7::prop(self, x_arg, check = FALSE) <- value
self
}
)
}

.url_regex <- "http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),{}]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"

url_scalar_property <- function(x_arg) {
character_scalar_property(x_arg, regex = .url_regex)
}

url_property <- function(x_arg) {
character_property(x_arg, regex = .url_regex)
}

enum_property <- function(x_arg) {
S7::new_property(
class = S7::class_list,
class = class_list,
setter = function(self, value) {
call <- rlang::caller_env(3)
if (!is.null(value) && !is.list(value)) {
Expand All @@ -70,8 +39,13 @@ enum_property <- function(x_arg) {
enumerations
}
)
if (!any(lengths(value))) {
value <- NULL
}
S7::prop(self, x_arg, check = FALSE) <- value
self
}
)
}

class_null <- S7::new_S3_class("NULL")
3 changes: 0 additions & 3 deletions R/00-shared-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#'
#' Reused parameter definitions are gathered here for easier editing.
#'
#' @param apid_list An API document as a list, such as that obtained by reading
#' an OAS document with [yaml::read_yaml()].
#' @param apid_url The url for an API document.
#' @param ... Catch-all for unimplemented properties.
#' @name .shared-parameters
#' @keywords internal
Expand Down
43 changes: 0 additions & 43 deletions R/01-info_contact.R

This file was deleted.

55 changes: 0 additions & 55 deletions R/01-info_license.R

This file was deleted.

72 changes: 0 additions & 72 deletions R/01-server_variable.R

This file was deleted.

82 changes: 0 additions & 82 deletions R/02-info.R

This file was deleted.

Loading