Skip to content

Commit

Permalink
feat(Changex.Formatter.Elixir): pass options list instead of version
Browse files Browse the repository at this point in the history
The version argument that is passed through to the elixir parser is now
a keyword list. This will easily enable other options to be passed in
the future (such as the GitHub url)

The other formatter will be changed to a similar format in the future.

BREAKING CHANGE: Calling `Changex.Formatter.Elixir.format` with a string
as the second argument is no longer valid. Instead you can call
`Changex.Formatter.Elixir.format` with an options list as the second
argument. This list can contain a `version` key.
  • Loading branch information
Gary Rennie committed Sep 14, 2014
1 parent 8d292b2 commit c3919d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/changex/formatter/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ defmodule Changex.Formatter.Elixir do
* [Scope 2] commit 8
"""
def format(commits, version \\ nil) do
heading(version) <> types(commits)
def format(commits, options \\ []) do
heading(Keyword.get(options, :version)) <> types(commits)
end

defp heading(version) do
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/changex/diff.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ defmodule Mix.Tasks.Changex.Diff do
Changex.Formatter.Markdown.format(commits, version) |> IO.puts
end
defp output(commits, "elixir", version) do
Changex.Formatter.Elixir.format(commits, version) |> IO.puts
Changex.Formatter.Elixir.format(commits, version: version) |> IO.puts
end
defp output(commits, formatter, version) do
apply(Module.concat([formatter]), :format, [commits, version])
Expand Down
4 changes: 2 additions & 2 deletions test/changex/formatter/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule Changex.Formatter.ElixirTest do
end

test "Formatting with an explicit version", %{commits: commits} do
assert Changex.Formatter.Elixir.format(commits, "v10") == expected_markdown("v10")
assert Changex.Formatter.Elixir.format(commits, version: "v10") == expected_markdown("v10")
end

test "Formatting with an implicit version", %{commits: commits} do
Expand All @@ -37,7 +37,7 @@ defmodule Changex.Formatter.ElixirTest do
* Bug fixes
* [policy] remove reference to data retention length
""" |> String.rstrip
assert Changex.Formatter.Elixir.format(commits, "v10") == expected
assert Changex.Formatter.Elixir.format(commits, version: "v10") == expected
end

defp expected_markdown(version) do
Expand Down

0 comments on commit c3919d4

Please sign in to comment.