Skip to content

Commit

Permalink
Document using Spell and specifying dependencies
Browse files Browse the repository at this point in the history
Remove optional dependencies from requirements, requiring the library
user to specify them explicitly.

Resolves MyMedsAndMe#16
  • Loading branch information
jtmoulia committed Sep 18, 2015
1 parent 8e1ce65 commit 0964890
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ Spell uses GitHub [issues](https://github.com/MyMedsAndMe/spell/issues) and
Spell has a mailing list at [email protected]; general questions or ideas are
welcome there. See [librelist](http://librelist.com/) for how to sign up.

## Using Spell with your Elixir Project

To use Spell from within your Elixir library add, add it to your `mix.exs` deps,
along with the required transport and serialization libraries:

```elixir
defp deps do
...
# Required:
{:spell, "~> 0.1"},
# Required if using the websocket transport:
{:websocket_client, github: "jeremyong/websocket_client", tag: "v0.7"},
# Required if using the JSON serializer:
{:poison, "~> 1.4"},
# Required if using the msgpack serializer:
{:msgpax, "~> 0.7"}
end
```

Fetch the dependencies by running:

```
$ mix deps.get
```

## How it Works

You can run the examples you're about to run into, though first you'll need
Expand Down
30 changes: 17 additions & 13 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Spell.Mixfile do
elixir: "~> 1.0",
description: description,
package: package,
deps: deps,
deps: deps(Mix.env),
aliases: aliases,
docs: docs,
preferred_cli_env: ["test.all": :test,
Expand All @@ -23,7 +23,6 @@ defmodule Spell.Mixfile do
def application do
[applications: [:logger,
:websocket_client,
:poison,
:pbkdf2],
mod: {Spell, []}]
end
Expand All @@ -47,19 +46,24 @@ defmodule Spell.Mixfile do
end

# TODO: allow transport/serialization deps to be filtered out
defp deps do
defp deps(:prod) do
[
# Req'd by: `Spell.Transport.Websocket`
{:websocket_client, github: "jeremyong/websocket_client", tag: "v0.7"},
# Req'd by: `Spell.Serializer.JSON`
{:poison, "~> 1.4.0"},
# Req'd by: `Spell.Serializer.MessagePack`
{:msgpax, "~> 0.7"},
# Req'd by: `Spell.Authentication.CRA`
{:pbkdf2, github: "pma/erlang-pbkdf2", branch: "master"},
# Doc deps
{:earmark, "~> 0.1", only: :doc},
{:ex_doc, "~> 0.7", only: :doc}
{:pbkdf2, github: "pma/erlang-pbkdf2", branch: "master"}
]
end

defp deps(_) do
deps(:prod) ++ [
# Req'd by: `Spell.Transport.Websocket`
{:websocket_client, github: "jeremyong/websocket_client", tag: "v0.7"},
# Req'd by: `Spell.Serializer.JSON`
{:poison, "~> 1.4"},
# Req'd by: `Spell.Serializer.MessagePack`
{:msgpax, "~> 0.7"},
# Doc deps
{:earmark, "~> 0.1", only: :doc},
{:ex_doc, "~> 0.7", only: :doc}
]
end

Expand Down

0 comments on commit 0964890

Please sign in to comment.