Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 and separate strategy packages #39

Merged
merged 6 commits into from
Feb 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ elixir:
- 1.5.0
- 1.6.0
otp_release:
- 19.0
- 19.1
- 19.2
- 20.2

matrix:
include:
- elixir: 1.4
otp_release: 19.2
env:
- MIX_ENV=test

cache:
directories:
- deps
- _build

script:
- mix compile --warning-as-errors
- if [ "$TRAVIS_ELIXIR_VERSION" == "1.6.0" ]; then mix format --check-formatted; fi
- mix credo
- mix test
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Ravenx Changelog

## v 2.0.0

* Strategies come in separate packages

## v 1.1.3

* Format base code using Elixir 1.6 formatter
Expand Down
58 changes: 42 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,54 @@ end

## Strategies

We currently support Slack and E-mail notifications (but there are more to come!).
From version 2.0, strategies come in separate packages, so the dependencies
needed are not added by default.

Also, there is the possibility of creating 3rd party integrations that works with Ravenx, as mentioned bellow
To define strategies, just add their packages to your `mix.exs` file and add
them to Ravenx configuration as follows:

```elixir
config :ravenx,
strategies: [
email: Ravenx.Strategy.Email
slack: Ravenx.Strategy.Slack
my_strategy: MyApp.Ravenx.MyStrategy
]
```

We currently maintain two strategies:

* **Slack**: [hex.pm](https://hex.pm/packages/ravenx_slack) | [GitHub](https://github.com/acutario/ravenx_slack)
* **E-mail** (based on Bamboo): [hex.pm](https://hex.pm/packages/ravenx_email) | [GitHub](https://github.com/acutario/ravenx_email)

Also, 3rd party strategies are supported and listed below.

### 3rd party strategies

Some amazing people created 3rd party strategies to use Ravenx with more services:
Amazing people created 3rd party strategies to use Ravenx with more services:

* **Pusher** (thanks to [@behind-design](https://github.com/behind-design)): [hex.pm](https://hex.pm/packages/ravenx_pusher) | [GitHub](https://github.com/behind-design/ravenx-pusher)
* **Telegram** (thanks to [@maratgaliev](https://github.com/maratgaliev)): [hex.pm](https://hex.pm/packages/ravenx_telegram) | [GitHub](https://github.com/maratgaliev/ravenx_telegram)

Anyone can create a strategy that works with Ravenx, so if you have one, please let us know to add it to this list.

### Custom strategies

Maybe there is some internal service you need to call to send notifications, so there is a way to create custom strategies for yout projects.

First of all, you need to create a module that meet the [required behaviour](https://github.com/acutario/ravenx/blob/master/lib/ravenx/strategy_behaviour.ex), like the example you can see [here](https://github.com/acutario/ravenx/blob/master/lib/ravenx/strategy/dummy.ex).

Then you can define custom strategies in application configuration:

```elixir
config :ravenx,
strategies: [
my_strategy: YourApp.MyStrategy
]
```

and start using your strategy to deliver notifications using the atom assigned (in the example, `my_strategy`).

## Single notification

Sending a single notification is as simply as calling this method:
Expand Down Expand Up @@ -170,19 +205,10 @@ Configuration can also be mixed by using the three methods:
* Dynamic configuration common to more than one scenario using a configuration module.
* Call-specific configuration sending a config Keyword list on `dispatch` method.

## Custom strategies

Maybe there is some internal service you need to call to send notifications, so there is a way to create custom strategies for yout projects.

First of all, you need to create a module that meet the [required behaviour](https://github.com/acutario/ravenx/blob/master/lib/ravenx/strategy_behaviour.ex), like the example you can see [here](https://github.com/acutario/ravenx/blob/master/lib/ravenx/strategy/dummy.ex).
## Contribute

Then you can define custom strategies in application configuration:
All contributions are welcome, and we really hope this repo will serve for beginners as well for more advanced developers.

```elixir
config :ravenx,
strategies: [
my_strategy: YourApp.MyStrategy
]
```
If you have any doubt, feel free to ask, but always respecting our [Code of Conduct](https://github.com/acutario/ravenx_slack/blob/master/CODE_OF_CONDUCT.md).

and start using your strategy to deliver notifications using the atom assigned (in the example, `my_strategy`).
To contribute, create a fork of the repository, make your changes and create a PR. And remember, talking on PRs/issues is a must!
141 changes: 0 additions & 141 deletions lib/ravenx/strategy/email.ex

This file was deleted.

84 changes: 0 additions & 84 deletions lib/ravenx/strategy/slack.ex

This file was deleted.

14 changes: 4 additions & 10 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Ravenx.Mixfile do
def project do
[
app: :ravenx,
version: "1.1.3",
elixir: "~> 1.3",
version: "2.0.0",
elixir: "~> 1.4",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
description: description(),
Expand All @@ -22,10 +22,7 @@ defmodule Ravenx.Mixfile do
# Type "mix help compile.app" for more information
def application do
[
mod: {Ravenx, []},
included_applications: [
:httpoison
]
mod: {Ravenx, []}
]
end

Expand All @@ -40,10 +37,6 @@ defmodule Ravenx.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:poison, "~> 2.0 or ~> 3.0"},
{:httpoison, "~> 1.0"},
{:bamboo, "~> 0.8"},
{:bamboo_smtp, "~> 1.4.0"},
{:ex_doc, ">= 0.0.0", only: :dev},
{:dialyxir, "~> 0.4", only: :dev},
{:credo, ">= 0.8.0", only: [:dev, :test]}
Expand All @@ -52,6 +45,7 @@ defmodule Ravenx.Mixfile do

defp docs do
[
main: "readme",
source_url: "https://github.com/acutario/ravenx",
extras: ["README.md"]
]
Expand Down