README.md

# RegulaEx

[![Build Status](https://drone.heetch.net/api/badges/heetch/regula-ex/status.svg)](https://drone.heetch.net/heetch/regula-ex)
[![ReadTheDocs](https://readthedocs.org/projects/regula/badge/?version=latest&style=flat)](https://regula.readthedocs.io/en/latest/)
[![Godoc](http://img.shields.io/badge/elixir-documentation_(vpn)-blue.svg?style=flat-square)](http://docs.dev.heetch.internal/go/heetch/regula-ex/tag/v0.1.0/index.html)


An Elixir client to [Regula](https://github.com/heetch/regula). It provides a practical api to perform evaluation of rulesets against
given parameters and will return the appropriate Elixir type. 

It can be instrumented by overriding callbacks defined by `Regula.Service` in a custom module. See the tests for an example of doing so.

## Example

First let's create a client:

```
client = %Regula.client(endpoint: "http://localhost:5331")
```

Given the server has the following ruleset defined:
- ruleset path: `/foo/bar`
- params: string named "baz"
- returns: int64

```
Regula.get_string(client, "/foo/bar", %{"baz" => "value"})
# {:ok, 42, %Regula.EvalResult{data: "42", type: "int64", version: "some-ksuid"}}
```

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `regula` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:regula, "~> 0.1.0"}
  ]
end
```

## Others 

- `mix dialyzer` to run dyalizer on the code
- `mix test --cover` to check code coverage

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/regula](https://hexdocs.pm/regula).