Skip to content

Commit

Permalink
Version 0.2.0 release
Browse files Browse the repository at this point in the history
Changes:
- `UpperCase` renamed to `PascalCase`
- `Recase.to_upper/1` renamed to `Recase.to_pascal/1`
- `upper_case_test.exs` renamed to `pascal_case_test.exs`
- Made changes to reflect `Pascal` and `Upper` case issue

Closes #2
  • Loading branch information
sobolevn committed Jul 15, 2017
1 parent 0a006da commit 569c429
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 38 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
12 changes: 6 additions & 6 deletions lib/recase.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Recase do

alias Recase.{
CamelCase,
UpperCase,
PascalCase,
SnakeCase,
KebabCase,
ConstantCase,
Expand All @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions lib/recase/cases/pascal_case.ex
Original file line number Diff line number Diff line change
@@ -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
<<char::binary-size(1), rest::binary>> = CamelCase.convert(value)
String.upcase(char) <> rest
end
end
19 changes: 0 additions & 19 deletions lib/recase/cases/upper_case.ex

This file was deleted.

2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/recase_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 569c429

Please sign in to comment.