-
Notifications
You must be signed in to change notification settings - Fork 1
JESI-2210 #14
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request changes
src/io/jesi/backpack/string.cljc
Outdated
(defn ->snake_case [s] | ||
(some-> s | ||
->kebab-case | ||
(string/replace #"-" "_"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace chars instead of creating regex:
(string/replace \- \_)
'a-snail-can-sleep-for-three-years | ||
'slugsHaveFourNoses) | ||
(is (= "a_snail_can_sleep_for_three_years" a-snail-can-sleep-for-three-years)) | ||
(is (= "slugs_have_four_noses" slugsHaveFourNoses)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(is (true? (bp/macro? `defconsts))))) | ||
|
||
(testing "transforms the symbol values with the given function" | ||
(defconsts bp/->snake_case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does composing the body-fn work?
Since we may want a screaming snake_case, the easiest would be to: (comp string/upper-case bp/->snake_case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. Test added.
`(do ~@(for [s symbols | ||
:let [name (second s) | ||
body (str name)]] | ||
`(def ~name (~body-fn ~body))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need to extract body-fn
to a variable outside the loop, in case it's composed (see comment below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. It's fine as is.
👍 |
JESI-2210
0.0.13 already taken https://circleci.com/gh/jesims/backpack/516