Rename functions

This commit is contained in:
Marcus Kammer 2024-04-03 10:34:08 +02:00
parent 4b585bb7a6
commit b0d7084a74
2 changed files with 20 additions and 20 deletions

View file

@ -20,11 +20,11 @@
:with-page :with-page
:remove-special-chars :remove-special-chars
:clean-form-str :clean-form-str
:build-name-str :build-str-name
:build-value-str :build-str-value
:build-value-prop-str :build-str-value-prop
:build-class-str :build-str-class
:build-id-str)) :build-str-id))
(in-package :dev.metalisp.sbt) (in-package :dev.metalisp.sbt)
@ -173,7 +173,7 @@ Returns:
A new string which can be used as HTML class." A new string which can be used as HTML class."
(string-downcase (substitute #\- #\Space (string-trim '(#\Space) str)))) (string-downcase (substitute #\- #\Space (string-trim '(#\Space) str))))
(defun build-name-str (name) (defun build-str-name (name)
"Builds a standardized string by adding a 'group-' prefix and applying cleaning "Builds a standardized string by adding a 'group-' prefix and applying cleaning
functions. functions.
@ -183,7 +183,7 @@ Returns:
A new standardized string." A new standardized string."
(concatenate 'string "group-" (clean-form-str name))) (concatenate 'string "group-" (clean-form-str name)))
(defun build-value-str (value) (defun build-str-value (value)
"Trims leading and trailing spaces from the given value string. "Trims leading and trailing spaces from the given value string.
VALUE: The string to be cleaned. VALUE: The string to be cleaned.
@ -192,16 +192,16 @@ Returns:
A new string without leading and trailing spaces." A new string without leading and trailing spaces."
(string-trim '(#\Space) value)) (string-trim '(#\Space) value))
(defun build-value-prop-str (value) (defun build-str-value-prop (value)
"Builds a value property string by applying various cleaning functions. "Builds a value property string by applying various cleaning functions.
VALUE: The initial value string. VALUE: The initial value string.
Returns: Returns:
A new value property string." A new value property string."
(clean-form-str (build-value-str value))) (clean-form-str (build-str-value value)))
(defun build-class-str (class name) (defun build-str-class (class name)
"Builds a class string by concatenating 'form-check-label' and a standardized "Builds a class string by concatenating 'form-check-label' and a standardized
name string. name string.
@ -211,9 +211,9 @@ NAME: The initial name string.
Returns: Returns:
A new class string." A new class string."
(concatenate 'string class " " (build-name-str name))) (concatenate 'string class " " (build-str-name name)))
(defun build-id-str (name value) (defun build-str-id (name value)
"Builds an ID string by concatenating a standardized name string and a sanitized "Builds an ID string by concatenating a standardized name string and a sanitized
value property string. value property string.
@ -224,6 +224,6 @@ VALUE: The initial value string.
Returns: Returns:
A new ID string." A new ID string."
(concatenate 'string (concatenate 'string
(build-name-str name) (build-str-name name)
"-" "-"
(remove-special-chars (build-value-prop-str value)))) (remove-special-chars (build-str-value-prop value))))

View file

@ -23,14 +23,14 @@
(testing "Cleans a form string for use as a name or identifier." (testing "Cleans a form string for use as a name or identifier."
(ok (string= (clean-form-str " hello WORLD") "hello-world")))) (ok (string= (clean-form-str " hello WORLD") "hello-world"))))
(deftest test-build-name-str (deftest test-build-str-name
(testing "Builds a standardized string by adding a 'group-' prefix and applying cleaning functions." (testing "Builds a standardized string by adding a 'group-' prefix and applying cleaning functions."
(ok (string= (build-name-str "somename") "group-somename")))) (ok (string= (build-str-name "somename") "group-somename"))))
(deftest test-build-value-str (deftest test-build-str-value
(testing "Trims leading and trailing spaces from the given value string." (testing "Trims leading and trailing spaces from the given value string."
(ok (string= (build-value-str " hello-world ") "hello-world")))) (ok (string= (build-str-value " hello-world ") "hello-world"))))
(deftest test-build-value-prop-str (deftest test-build-str-value-prop
(testing "Builds a value property string by applying various cleaning functions." (testing "Builds a value property string by applying various cleaning functions."
(ok (string= (build-value-prop-str " hello world ") "hello-world")))) (ok (string= (build-str-value-prop " hello world ") "hello-world"))))