Skip to content

Commit 6073a5f

Browse files
committed
Added CHANGELOG.md
1 parent 0dc882f commit 6073a5f

File tree

7 files changed

+53
-23
lines changed

7 files changed

+53
-23
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/deps
33
erl_crash.dump
44
*.ez
5+
/doc

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## [1.0.0]
2+
### Added
3+
- First release

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Diff
22
====
33

4-
A diff library in Elixir
4+
A simple diff library in Elixir
55

66

77
## Diff.diff
88

9-
Compares 2 binaries and returns a list of changes from the first given binary with the second
9+
Compares 2 terms that have an implementation of the `Diff.Diffable` protocol and returns a list of changes from the first given binary with the second
1010

1111
The diff function can take the following options:
1212

@@ -24,7 +24,7 @@ iex(1)> Diff.diff("test", "taste")
2424

2525
## Diff.patch
2626

27-
Applies the given patches to the binary. Takes an optional third parameter to turn
27+
Applies the given patches to the term. Takes an optional third parameter to turn
2828
the patched list created from applying the patches back into the type needed.
2929

3030

@@ -47,3 +47,7 @@ iex(1)> patches = Diff.diff("test", "taste")
4747
iex(2)> Diff.patch("test", patches, &Enum.join/1)
4848
"taste"
4949
```
50+
51+
52+
`Diff.diff` and `Diff.patch` both take as a first parameter a term that has an implementation of the `Diff.Diffable` protocol.
53+
By default one exist for `BitString` and `List`

lib/diff/diffable.ex

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
defprotocol Diff.Diffable do
2+
@moduledoc """
3+
Protocol used by `Diff` module to turn input into a list
4+
to calculate diffs
5+
"""
26
def to_list(diffable)
37
end
48

59
defimpl Diff.Diffable, for: BitString do
610
def to_list(diffable) do
711
String.graphemes(diffable)
812
end
13+
end
914

10-
defimpl Diff.Diffable, for: List do
11-
def to_list(diffable) do
12-
diffable
13-
end
15+
defimpl Diff.Diffable, for: List do
16+
def to_list(diffable) do
17+
diffable
1418
end
1519
end

lib/diff/matrix.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule Diff.Matrix do
2+
@moduledoc false
23

34
def new(rows, columns) do
45
List.duplicate(List.duplicate(0, columns), rows)
@@ -8,11 +9,11 @@ defmodule Diff.Matrix do
89
list = Enum.fetch!(matrix, i)
910
Enum.fetch!(list, j)
1011
end
11-
12+
1213
def put(matrix, i, j, new_value) do
1314
list = Enum.fetch!(matrix, i)
1415
list = List.update_at(list, j, fn(_) -> new_value end)
15-
List.update_at(matrix, i, fn(_) -> list end)
16+
List.update_at(matrix, i, fn(_) -> list end)
1617
end
1718

1819
end

mix.exs

+27-14
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,43 @@ defmodule Diff.Mixfile do
33

44
def project do
55
[app: :diff,
6-
version: "0.0.1",
6+
name: "Diff",
7+
version: "1.0.0",
78
elixir: "~> 1.0",
9+
description: description,
10+
package: package,
11+
source_url: "https://github.com/bryanjos/diff",
812
build_embedded: Mix.env == :prod,
913
start_permanent: Mix.env == :prod,
1014
deps: deps]
1115
end
1216

13-
# Configuration for the OTP application
14-
#
15-
# Type `mix help compile.app` for more information
1617
def application do
1718
[applications: [:logger]]
1819
end
1920

20-
# Dependencies can be Hex packages:
21-
#
22-
# {:mydep, "~> 0.3.0"}
23-
#
24-
# Or git/path repositories:
25-
#
26-
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
27-
#
28-
# Type `mix help deps` for more examples and options
2921
defp deps do
30-
[]
22+
[
23+
{:earmark, "~> 0.2", only: :dev },
24+
{:ex_doc, "~> 0.11", only: :dev },
25+
{:credo, "~> 0.2.0", only: :dev }
26+
]
27+
end
28+
29+
defp description do
30+
"""
31+
A simple diff library
32+
"""
33+
end
34+
35+
defp package do
36+
[
37+
files: ["lib", "mix.exs", "README*", "LICENSE*", "CHANGELOG*"],
38+
maintainers: ["Bryan Joseph"],
39+
licenses: ["MIT"],
40+
links: %{
41+
"GitHub" => "https://github.com/bryanjos/diff"
42+
}
43+
]
3144
end
3245
end

mix.lock

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
%{"bunt": {:hex, :bunt, "0.1.5"},
2+
"credo": {:hex, :credo, "0.2.6"},
3+
"earmark": {:hex, :earmark, "0.2.1"},
4+
"ex_doc": {:hex, :ex_doc, "0.11.4"}}

0 commit comments

Comments
 (0)