Skip to content

Commit

Permalink
Publication settings, doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeb committed Oct 26, 2017
1 parent 692c245 commit 6676b85
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Miniban

**TODO: Add description**
## Simple and fast IBAN validation

```
Miniban.is_iban_valid?(iban) # -> true / false
```

## Installation

Expand Down
12 changes: 11 additions & 1 deletion lib/miniban.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ defmodule Miniban do

@doc """
Validate an IBAN
## Examples
iex> Miniban.is_valid_iban?("MD75EX0900002374642125EU")
true
iex> Miniban.is_valid_iban?("")
false
"""
def is_valid_iban?(input) do
def is_valid_iban?(input) when is_binary(input) do
{ prefix, rest } = String.replace(input, ~r/ +/, "")
|> String.upcase()
|> String.split_at(4)
Expand All @@ -28,4 +37,5 @@ defmodule Miniban do
|> String.to_integer()
|> rem(97)
end
def is_valid_iban?(_), do: false
end
23 changes: 22 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ defmodule Miniban.MixProject do
def project do
[
app: :miniban,
name: "Miniban",
version: "0.1.0",
elixir: "~> 1.6-dev",
elixir: "~> 1.5",
start_permanent: Mix.env() == :prod,
package: package(),
description: description(),
source_url: "https://github/webdeb/miniban-elixir",
deps: deps()
]
end
Expand All @@ -21,9 +25,26 @@ defmodule Miniban.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ex_doc, ">= 0.0.0", only: :dev},
# for benchmarks comparison
{:benchee, "~> 0.10", only: :dev},
{:bankster, "~> 0.2.2", only: :dev}
]
end

defp description() do
"Simple and fast IBAN validation"
end

defp package() do
[
# This option is only needed when you don't want to use the OTP application name
name: "miniban",
# These are the default files included in the package
files: ["lib", "mix.exs", "README*"],
maintainers: ["Boris Kotov"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github/webdeb/miniban-elixir"}
]
end
end
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
"bankster": {:hex, :bankster, "0.2.2", "28015dc2a05e44fd6bf8f2920532d8df60c687430b1e0a9927e8bfc805395faa", [], [], "hexpm"},
"benchee": {:hex, :benchee, "0.10.0", "7227e83ab81e4753610125d251bbf78c99167fbe7f931a8cbfbc3eda8526259c", [], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
"deep_merge": {:hex, :deep_merge, "0.1.1", "c27866a7524a337b6a039eeb8dd4f17d458fd40fbbcb8c54661b71a22fffe846", [], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
}

0 comments on commit 6676b85

Please sign in to comment.