Skip to content

Commit

Permalink
Rename uppersnakecase to constcase
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlls committed Feb 13, 2022
1 parent d1dff87 commit 76abe42
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ print(string) # foo_bar_baz
string = casefy.snakecase("FOO BAR")
print(string) # foo_bar

# UPPER_SNAKE_CASE (a.k.a. constant)
string = casefy.uppersnakecase("fooBar")
# CONST_CASE
string = casefy.constcase("fooBar")
print(string) # FOO_BAR

# kebab-case
Expand Down
6 changes: 3 additions & 3 deletions casefy/casefy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def snakecase(string: str, keep_together: List[str] = None) -> str:
return re.sub(r"_$", "", string) if not trailing_underscore else string


def uppersnakecase(string: str) -> str:
"""Convert a string into UPPER_SNAKE_CASE.
def constcase(string: str) -> str:
"""Convert a string into CONST_CASE.
Args:
string (:obj:`str`):
The string to convert.
Returns:
:obj:`str`: The UPPER_SNAKE_CASED string.
:obj:`str`: The CONST_CASED string.
"""
if not string:
return ""
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Examples
string = casefy.snakecase("FOO BAR")
print(string) # foo_bar
# UPPER_SNAKE_CASE (a.k.a. constant)
string = casefy.uppersnakecase("fooBar")
# CONST_CASE
string = casefy.constcase("fooBar")
print(string) # FOO_BAR
# kebab-case
Expand Down
34 changes: 17 additions & 17 deletions tests/test_casefy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ def main():
assert "" == casefy.snakecase("")
assert "" == casefy.snakecase(None)

# UPPER_SNAKE_CASE
assert "FOO_BAR" == casefy.uppersnakecase("fooBar")
assert "FOO_BAR" == casefy.uppersnakecase("FooBar")
assert "FOO_BAR" == casefy.uppersnakecase("FOO BAR")
assert "FOO_BAR" == casefy.uppersnakecase("foo bar")
assert "FOO_BAR_2" == casefy.uppersnakecase("fooBar2")
assert "FOO_2_BAR" == casefy.uppersnakecase("foo2bar")
assert "FOO_2_BAR" == casefy.uppersnakecase("foo2Bar")
assert "FOO_2_BAR_2" == casefy.uppersnakecase("foo2Bar2")
assert "FOO_B_2_BAR_2" == casefy.uppersnakecase("FooB2_Bar2")
assert "FOO_BAR" == casefy.uppersnakecase("foo_bar")
assert "FOO_BAR" == casefy.uppersnakecase("foo-bar")
assert "FOO_BAR" == casefy.uppersnakecase("foo.bar")
assert "_BAR_BAZ" == casefy.uppersnakecase("_bar_baz")
assert "BAR_BAZ" == casefy.uppersnakecase(".bar_baz")
assert "" == casefy.uppersnakecase("")
assert "" == casefy.uppersnakecase(None)
# CONST_CASE
assert "FOO_BAR" == casefy.constcase("fooBar")
assert "FOO_BAR" == casefy.constcase("FooBar")
assert "FOO_BAR" == casefy.constcase("FOO BAR")
assert "FOO_BAR" == casefy.constcase("foo bar")
assert "FOO_BAR_2" == casefy.constcase("fooBar2")
assert "FOO_2_BAR" == casefy.constcase("foo2bar")
assert "FOO_2_BAR" == casefy.constcase("foo2Bar")
assert "FOO_2_BAR_2" == casefy.constcase("foo2Bar2")
assert "FOO_B_2_BAR_2" == casefy.constcase("FooB2_Bar2")
assert "FOO_BAR" == casefy.constcase("foo_bar")
assert "FOO_BAR" == casefy.constcase("foo-bar")
assert "FOO_BAR" == casefy.constcase("foo.bar")
assert "_BAR_BAZ" == casefy.constcase("_bar_baz")
assert "BAR_BAZ" == casefy.constcase(".bar_baz")
assert "" == casefy.constcase("")
assert "" == casefy.constcase(None)

# kebab-case
assert "foo-bar" == casefy.kebabcase("fooBar")
Expand Down

0 comments on commit 76abe42

Please sign in to comment.