Skip to content

Commit

Permalink
List of delimiters. Fixed path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Feb 14, 2019
1 parent c880007 commit e1a7bd4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/recase/cases/generic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Recase.Generic do
This module should not be used directly.
"""

@splitters Application.get_env(:recase, :delimiters, :symbol)
@splitters Application.get_env(:recase, :delimiters, [?\s, ?\n, ?\t, ?_, ?., ?-, ?#, ??, ?!])

@delimiters (case @splitters do
list when is_list(list) ->
Expand Down
7 changes: 6 additions & 1 deletion lib/recase/cases/path_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ defmodule Recase.PathCase do
@sep "/"

@spec convert(String.t(), String.t()) :: String.t()
def convert(value, separator \\ @sep) when is_binary(value),
def convert(value, separator \\ @sep)

def convert(<<separator::binary-size(1), rest::binary>>, separator),
do: separator <> convert(rest, separator)

def convert(value, separator) when is_binary(value),
do: rejoin(value, separator: separator, case: :none)
end
4 changes: 2 additions & 2 deletions test/recase_test/camel_case_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ defmodule Recase.CamelCaseTest do
assert convert("CamelCase") == "camelCase"
assert convert("camelCase") == "camelCase"
assert convert("CAMelCase") == "camelCase"
assert convert("camel-casE") == "camelCase"
assert convert("camel-casE") == "camelCasE"
end

test "should not modify extra chars" do
assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\""
assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\""
end

test "should return single letter" do
Expand Down
2 changes: 1 addition & 1 deletion test/recase_test/pascal_case_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Recase.PascalCaseTest do
end

test "should not modify extra chars" do
assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\""
assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\""
end

test "should return single letter" do
Expand Down
2 changes: 1 addition & 1 deletion test/recase_test/path_case_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Recase.PathCaseTest do
end

test "should not modify extra chars" do
assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\""
assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\""
end

test "should return single letter" do
Expand Down

0 comments on commit e1a7bd4

Please sign in to comment.