From 34bf2e40f2f38a4cee13e505cae429d53d790144 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 12 Jul 2017 11:31:52 +0300 Subject: [PATCH] Version 0.1.1 release --- CHANGELOG.md | 12 +++++ README.md | 67 ++++++++++++++++++++-------- mix.exs | 2 +- test/recase_test/camel_case_test.exs | 2 + 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d707a..16173c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## Version 0.1.1 + +### Improvements + +- Adds `Path/case`, `dot.case`, and `CONTANT_CASE` +- Updates tests + +### Documentation + +- Updates documentation +- Updates README + ## Version 0.1.0 diff --git a/README.md b/README.md index 5ed95ac..d8d430d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,13 @@ `Recase` helps you to convert a string from any case to any case. +## Why? + +One can ask: "Why should I use `recase` when I can use built-in `Macro` module?". But, you have to keep in mind that `Macro`'s functions are [not suitable](https://github.com/elixir-lang/elixir/blob/4aa81645b0588b56fb61cd154dcaee354732aa5c/lib/elixir/lib/macro.ex#L1265) for general case usage: + +> Do not use it as a general mechanism for underscoring or camelizing strings as it does not support Unicode or characters that are not valid in Elixir identifiers. + + ## Installation ```elixir @@ -18,44 +25,66 @@ end ### Upper -```elixir -Recase.to_upper("some-value") -# => "SomeValue" +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. -Recase.to_upper("Some value") -# => "SomeValue" +```elixir +Recase.to_upper("some-value") # => "SomeValue" +Recase.to_upper("Some value") # => "SomeValue" ``` ### Camel -```elixir -Recase.to_camel("some-value") -# => "someValue" +Camel case uses mixed case with lower and upper cased characters. Separates words from each other with the upper cased letters. Starts with lower case letter. -Recase.to_camel("Some Value") -# => "someValue" +```elixir +Recase.to_camel("some-value") # => "someValue" +Recase.to_camel("Some Value") # => "someValue" ``` ### Snake -```elixir -Recase.to_snake("someValue") -# => "some_value" +Snake cases uses all lower case. Uses `_` as a separator. -Recase.to_snake("Some Value") -# => "some_value" +```elixir +Recase.to_snake("someValue") # => "some_value" +Recase.to_snake("Some Value") # => "some_value" ``` ### Kebab +Kebab cases uses all lower case. Uses `-` as a separator. + +```elixir +Recase.to_kebab("someValue") # => "some-value" +Recase.to_kebab("Some Value") # => "some-value" +``` + +### Constant + +Constant case uses all upper case. Uses `_` as a separator. + ```elixir -Recase.to_kebab("someValue") -# => "some-value" +Recase.to_constant("SomeValue") # => "SOME_VALUE" +Recase.to_constant("some value") # => "SOME_VALUE" +``` + +### Dot -Recase.to_kebab("Some Value") -# => "some-value" +Dot case uses all lower case similar to snake case. Uses `.` as a separator. + +```elixir +Recase.to_dot("SomeValue") # => "some.value" +Recase.to_dot("some value") # => "some.value" ``` +### Path + +Path case preserves case, you can also provide a separator as the second argument. + +```elixir +Recase.to_path("SomeValue") # => "Some/Value" +Recase.to_path("some value", "\\") # => "some\\value" +``` ## License diff --git a/mix.exs b/mix.exs index beabea4..e94cbd8 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Recase.Mixfile do use Mix.Project - @version "0.1.0" + @version "0.1.1" @url "https://github.com/sobolevn/recase" def project do diff --git a/test/recase_test/camel_case_test.exs b/test/recase_test/camel_case_test.exs index 4e21dab..b6f53f7 100644 --- a/test/recase_test/camel_case_test.exs +++ b/test/recase_test/camel_case_test.exs @@ -12,6 +12,8 @@ defmodule Recase.CamelCaseTest do assert convert("camel_case") == "camelCase" assert convert("CamelCase") == "camelCase" assert convert("camelCase") == "camelCase" + assert convert("CAMelCase") == "camelCase" + assert convert("camel-casE") == "camelCase" end test "should not modify extra chars" do