diff --git a/CHANGELOG.md b/CHANGELOG.md index 16173c7..750b5ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## Version 0.2.0 + +This version brings just one, but braking change. As it was discussed `to_upper` is a misleading name for a function. It is not clear what this function does. Since traditionally `uppercase` is just all uppercased letters. And it has nothing to do with `PascalCase`. + +### Braking changes + +- `UpperCase` renamed to `PascalCase` ([#2](https://github.com/sobolevn/recase/issues/2)) +- `Recase.to_upper/1` renamed to `Recase.to_pascal/1` ([#2](https://github.com/sobolevn/recase/issues/2)) + +### Tests + +- `upper_case_test.exs` renamed to `pascal_case_test.exs` + +### Documentation + +- Made changes to reflect `Pascal` and `Upper` case issue + + ## Version 0.1.1 ### Improvements diff --git a/README.md b/README.md index d8d430d..330cdcc 100644 --- a/README.md +++ b/README.md @@ -16,20 +16,20 @@ One can ask: "Why should I use `recase` when I can use built-in `Macro` module?" ```elixir def deps do - [{:recase, "~> 0.1"}] + [{:recase, "~> 0.2"}] end ``` ## Usage -### Upper +### Pascal -Upper (or Pascal) case uses mixed case with lower and upper cased characters. Separates words from each other with the upper case letters. Starts with upper case letter. +Pascal (or Upper) case uses mixed case with lower and upper cased characters. Separates words from each other with the upper case letters. Starts with upper case letter. ```elixir -Recase.to_upper("some-value") # => "SomeValue" -Recase.to_upper("Some value") # => "SomeValue" +Recase.to_pascal("some-value") # => "SomeValue" +Recase.to_pascal("Some value") # => "SomeValue" ``` ### Camel @@ -86,6 +86,12 @@ Recase.to_path("SomeValue") # => "Some/Value" Recase.to_path("some value", "\\") # => "some\\value" ``` + +## Changelog + +Full changelog is available [here](https://github.com/sobolevn/recase/blob/master/CHANGELOG.md). + + ## License -MIT. See [LICENSE.md](/LICENSE.md) for more details. +MIT. See [LICENSE.md](https://github.com/sobolevn/recase/blob/master/LICENSE.md) for more details. diff --git a/lib/recase.ex b/lib/recase.ex index f1d9eb0..fdae2f3 100644 --- a/lib/recase.ex +++ b/lib/recase.ex @@ -7,7 +7,7 @@ defmodule Recase do alias Recase.{ CamelCase, - UpperCase, + PascalCase, SnakeCase, KebabCase, ConstantCase, @@ -16,18 +16,18 @@ defmodule Recase do } @doc """ - Converts string to UpperCase aka PascalCase. + Converts string to PascalCase (aka UpperCase). ## Examples - iex> Recase.to_upper("some-value") + iex> Recase.to_pascal("some-value") "SomeValue" - iex> Recase.to_upper("some value") + iex> Recase.to_pascal("some value") "SomeValue" """ - @spec to_upper(String.t) :: String.t - def to_upper(value), do: UpperCase.convert(value) + @spec to_pascal(String.t) :: String.t + def to_pascal(value), do: PascalCase.convert(value) @doc """ Converts string to camelCase. diff --git a/lib/recase/cases/pascal_case.ex b/lib/recase/cases/pascal_case.ex new file mode 100644 index 0000000..f359ce5 --- /dev/null +++ b/lib/recase/cases/pascal_case.ex @@ -0,0 +1,32 @@ +defmodule Recase.PascalCase do + @moduledoc """ + Module to convert strings to `PascalCase` aka `UpperCase`. + + This module should not be used directly. + + Read about `PascalCase` here: + https://en.wikipedia.org/wiki/PascalCase + + ## Changed + + This name was introduced in version `0.2.0`, + it was named `UpperCase` before. + + But `UpperCase` was not clear enough. What is `uppercase`? + + 1. THIS IS UPPERCASE + 2. ThisIsAlsoUpperCase + + So, it was decided to rename this module into `PascalCase`. + For other details see: https://github.com/sobolevn/recase/issues/2 + """ + + alias Recase.CamelCase + + @spec convert(String.t) :: String.t + def convert(""), do: "" + def convert(value) do + <> = CamelCase.convert(value) + String.upcase(char) <> rest + end +end diff --git a/lib/recase/cases/upper_case.ex b/lib/recase/cases/upper_case.ex deleted file mode 100644 index b8f95d0..0000000 --- a/lib/recase/cases/upper_case.ex +++ /dev/null @@ -1,19 +0,0 @@ -defmodule Recase.UpperCase do - @moduledoc """ - Module to convert strings to `UpperCase` aka `PascalCase`. - - This module should not be used directly. - - Read about `UpperCase` here: - https://en.wikipedia.org/wiki/PascalCase - """ - - alias Recase.CamelCase - - @spec convert(String.t) :: String.t - def convert(""), do: "" - def convert(value) do - <> = CamelCase.convert(value) - String.upcase(char) <> rest - end -end diff --git a/mix.exs b/mix.exs index e94cbd8..a0cb747 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Recase.Mixfile do use Mix.Project - @version "0.1.1" + @version "0.2.0" @url "https://github.com/sobolevn/recase" def project do diff --git a/test/recase_test.exs b/test/recase_test.exs index 91bff0b..cd2ea27 100644 --- a/test/recase_test.exs +++ b/test/recase_test.exs @@ -14,8 +14,8 @@ defmodule RecaseTest do assert Recase.to_kebab("some value") == "some-value" end - test "should convert to UpperCase" do - assert Recase.to_upper("some value") == "SomeValue" + test "should convert to PascalCase" do + assert Recase.to_pascal("some value") == "SomeValue" end test "should convert to CONSTANT_CASE" do diff --git a/test/recase_test/upper_case_test.exs b/test/recase_test/pascal_case_test.exs similarity index 81% rename from test/recase_test/upper_case_test.exs rename to test/recase_test/pascal_case_test.exs index d380fd6..4407af4 100644 --- a/test/recase_test/upper_case_test.exs +++ b/test/recase_test/pascal_case_test.exs @@ -1,11 +1,11 @@ -defmodule Recase.UpperCaseTest do +defmodule Recase.PascalCaseTest do use ExUnit.Case - import Recase.UpperCase + import Recase.PascalCase - doctest Recase.UpperCase + doctest Recase.PascalCase - test "should upper case usual text" do + test "should pascal case usual text" do assert convert("upper case") == "UpperCase" assert convert("upper-case") == "UpperCase" assert convert("upper.case") == "UpperCase"