A fork of inflections-clj with compatibility for Cherry.
A fork of inflections-clj with compatibility for Cherry.
(->rule pattern replacement)
(acronym s)
Returns the the acronym for s
if it is one, otherwise nil.
Returns the the acronym for `s` if it is one, otherwise nil.
(add-acronym! word)
Adds word
to the set of *acronyms*
.
Adds `word` to the set of `*acronyms*`.
(add-irregular! singular plural)
Add singular
and plural
to the set of *irregular-words*
.
Add `singular` and `plural` to the set of `*irregular-words*`.
(add-rule! rules rule)
(add-uncountable! word)
Adds word
to the set of *uncountable-words*
.
Adds `word` to the set of `*uncountable-words*`.
(camel-case word & [mode])
Convert word
to camel case. By default, camel-case converts to
UpperCamelCase. If the argument to camel-case is set to :lower then
camel-case produces lowerCamelCase.
Examples:
(camel-case "active_record") ;=> "ActiveRecord"
(camel-case "active_record" :lower) ;=> "activeRecord"
(camel-case "active_record/errors") ;=> "ActiveRecord/Errors"
(camel-case "active_record/errors" :lower) ;=> "activeRecord/Errors"
Convert `word` to camel case. By default, camel-case converts to UpperCamelCase. If the argument to camel-case is set to :lower then camel-case produces lowerCamelCase. Examples: (camel-case "active_record") ;=> "ActiveRecord" (camel-case "active_record" :lower) ;=> "activeRecord" (camel-case "active_record/errors") ;=> "ActiveRecord/Errors" (camel-case "active_record/errors" :lower) ;=> "activeRecord/Errors"
(camel-case-keys m & [mode])
Recursively apply camel-case on all keys of m.
Recursively apply camel-case on all keys of m.
(capitalize word)
Convert the first letter in word
to upper case.
Examples:
(capitalize "hello") ;=> "Hello"
(capitalize "HELLO") ;=> "Hello"
(capitalize "abc123") ;=> "Abc123"
Convert the first letter in `word` to upper case. Examples: (capitalize "hello") ;=> "Hello" (capitalize "HELLO") ;=> "Hello" (capitalize "abc123") ;=> "Abc123"
(coerce obj s)
Coerce the string s
to the type of obj
.
Coerce the string `s` to the type of `obj`.
(countable? s)
Returns true if s
is countable, otherwise false.
Returns true if `s` is countable, otherwise false.
(dasherize s)
Replaces all underscores in s
with dashes.
Examples:
(dasherize "puni_puni") ;=> "puni-puni"
Replaces all underscores in `s` with dashes. Examples: (dasherize "puni_puni") ;=> "puni-puni"
(delete-acronym! word)
Delete word
from the set of *acronyms*
.
Delete `word` from the set of `*acronyms*`.
(delete-irregular! singular plural)
Delete singular
and plural
from the set of irregular-words.
Delete `singular` and `plural` from the set of *irregular-words*.
(delete-uncountable! word)
Delete word
from the set of *uncountable-words*
.
Delete `word` from the set of `*uncountable-words*`.
(demodulize x)
Removes the module part from x
.
Examples:
(demodulize "inflections.MyRecord") ;=> "MyRecord"
(demodulize "ActiveRecord::CoreExtensions::String::Inflections") ;=> "Inflections"
(demodulize "Inflections") ;=> "Inflections"
Removes the module part from `x`. Examples: (demodulize "inflections.MyRecord") ;=> "MyRecord" (demodulize "ActiveRecord::CoreExtensions::String::Inflections") ;=> "Inflections" (demodulize "Inflections") ;=> "Inflections"
(foreign-key x & [sep])
Converts x
into a foreign key. The default separator "_" is
placed between the name and "id".
Examples:
(foreign-key "Message") ;=> "message_id"
(foreign-key "Message" false) ;=> "messageid"
(foreign-key "Admin::Post") ;=> "post_id"
Converts `x` into a foreign key. The default separator "_" is placed between the name and "id". Examples: (foreign-key "Message") ;=> "message_id" (foreign-key "Message" false) ;=> "messageid" (foreign-key "Admin::Post") ;=> "post_id"
(hyphenate x)
Hyphenate x, which is the same as threading x
through the str,
underscore and dasherize fns.
Examples:
(hyphenate 'Continent) ; => "continent"
(hyphenate "CountryFlag") ; => "country-flag"
Hyphenate x, which is the same as threading `x` through the str, underscore and dasherize fns. Examples: (hyphenate 'Continent) ; => "continent" (hyphenate "CountryFlag") ; => "country-flag"
(hyphenate-keys m)
Recursively apply hyphenate on all keys of m.
Recursively apply hyphenate on all keys of m.
(hyphenate-values m)
Recursively apply hyphenate on all values of m.
Recursively apply hyphenate on all values of m.
(init-inflections!)
Initialize the Inflections library with defaults.
Initialize the Inflections library with defaults.
(init-irregular-words!)
(init-plural-rules!)
(init-singular-rules!)
(irregular? word)
Returns true if word
is an irregular word, otherwise false.
Returns true if `word` is an irregular word, otherwise false.
(ordinalize x)
Turns x
into an ordinal string used to denote the position in an
ordered sequence such as 1st, 2nd, 3rd, 4th, etc.
Examples:
(ordinalize "1") ;=> "1st"
(ordinalize "23") ;=> "23rd"
Turns `x` into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th, etc. Examples: (ordinalize "1") ;=> "1st" (ordinalize "23") ;=> "23rd"
(parameterize x & [sep])
Replaces special characters in x
with the default separator
"-". so that it may be used as part of a pretty URL.
Examples:
(parameterize "Donald E. Knuth") ; => "donald-e-knuth"
(parameterize "Donald E. Knuth" "_") ; => "donald_e_knuth"
Replaces special characters in `x` with the default separator "-". so that it may be used as part of a pretty URL. Examples: (parameterize "Donald E. Knuth") ; => "donald-e-knuth" (parameterize "Donald E. Knuth" "_") ; => "donald_e_knuth"
(plural! & patterns-and-replacements)
Define rule(s) to map words from singular to plural.
Examples: (plural! #"$(?i)" "s") (plural! #"(ax|test)is$(?i)" "$1es" #"(octop|vir)us$(?i)" "$1i")
Define rule(s) to map words from singular to plural. Examples: (plural! #"$(?i)" "s") (plural! #"(ax|test)is$(?i)" "$1es" #"(octop|vir)us$(?i)" "$1i")
(pluralize count singular & [plural])
Attempts to pluralize the word unless count is 1. If plural is supplied, it will use that when count is > 1, otherwise it will use the inflector to determine the plural form.
Attempts to pluralize the word unless count is 1. If plural is supplied, it will use that when count is > 1, otherwise it will use the inflector to determine the plural form.
(reset-rules! rules)
Resets the list of plural rules.
Resets the list of plural rules.
(resolve-rule rule word)
(resolve-rules rules word)
(singular! & patterns-and-replacements)
Define rule(s) to map words from singular to plural.
Examples: (singular! #"(n)ews$(?i)" "$1ews") (singular! #"(m)ovies$(?i)" "$1ovie" #"([m|l])ice$(?i)" "$1ouse")
Define rule(s) to map words from singular to plural. Examples: (singular! #"(n)ews$(?i)" "$1ews") (singular! #"(m)ovies$(?i)" "$1ovie" #"([m|l])ice$(?i)" "$1ouse")
(slurp-rules & patterns-and-replacements)
Returns a seq of rules, where the pattern and replacement must be given in pairs of two elements.
Returns a seq of rules, where the pattern and replacement must be given in pairs of two elements.
(str-name x)
Same as clojure.core/name
, but keeps the namespace for keywords
and symbols.
Same as `clojure.core/name`, but keeps the namespace for keywords and symbols.
(stringify-keys m)
Recursively transform all keys of m into strings.
Recursively transform all keys of m into strings.
(stringify-values m)
Recursively transform all values of m into strings.
Recursively transform all values of m into strings.
(transform-keys m f)
Recursively transform all keys in the map m
by applying f
on them.
Recursively transform all keys in the map `m` by applying `f` on them.
(transform-values m f)
Recursively transform all map values of m by applying f on them.
Recursively transform all map values of m by applying f on them.
(uncountable? x)
Returns true if x
is uncountable, otherwise false.
Returns true if `x` is uncountable, otherwise false.
(underscore x)
The reverse of camel-case. Makes an underscored, lowercase form from the expression in the string.
Examples:
(underscore "ActiveRecord") ;=> "active_record"
(underscore "ActiveRecord::Errors") ;=> "active_record::errors"
The reverse of camel-case. Makes an underscored, lowercase form from the expression in the string. Examples: (underscore "ActiveRecord") ;=> "active_record" (underscore "ActiveRecord::Errors") ;=> "active_record::errors"
(underscore-keys m)
Recursively apply underscore on all keys of m.
Recursively apply underscore on all keys of m.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close