Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 2.1.1

### Fixed

- Replace usage of function `Keyword.validate/2` which is not usable with Elixir v1.9

## 2.1.0

### Changed
Expand Down
28 changes: 13 additions & 15 deletions lib/exos.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,19 @@ defmodule Exos.Proc do
end

def start_link(cmd, init, opts \\ []) do
known_opts = [:port_opts, :gen_server_opts, :event_fun, :etf_opts]
case Keyword.keyword?(opts) and match?({:ok, _}, Keyword.validate(opts, known_opts)) do
true ->
port_opts = Keyword.get(opts, :port_opts, [])
gen_server_opts = Keyword.get(opts, :gen_server_opts, [])
event_fun = Keyword.get(opts, :event_fun)
etf_opts = Keyword.get(opts, :etf_opts, [])
GenServer.start_link(Exos.Proc, {cmd, init, port_opts, event_fun, etf_opts}, gen_server_opts)

false ->
# If no key matches with our opts, then it means it is the old API being used.
IO.warn("You are using the old API of #{__MODULE__}.start_link/3 that takes Port.open/2
options as 3rd parameter. The new API takes a Keyword list instead to handle options of
the old API.")
start_link(cmd, init, [port_opts: opts])
supported_opts = [:port_opts, :gen_server_opts, :event_fun, :etf_opts]
if Keyword.keyword?(opts) and Enum.all?(Keyword.keys(opts), & &1 in supported_opts) do
port_opts = Keyword.get(opts, :port_opts, [])
gen_server_opts = Keyword.get(opts, :gen_server_opts, [])
event_fun = Keyword.get(opts, :event_fun)
etf_opts = Keyword.get(opts, :etf_opts, [])
GenServer.start_link(Exos.Proc, {cmd, init, port_opts, event_fun, etf_opts}, gen_server_opts)
else
# If no key matches with our opts, then it means it is the old API being used.
IO.warn("You are using the old API of #{__MODULE__}.start_link/3 that takes Port.open/2
options as 3rd parameter. The new API takes a Keyword list instead to handle options of
the old API.")
start_link(cmd, init, [port_opts: opts])
end
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Exos.Mixfile do
use Mix.Project

defp version, do: "2.1.0"
defp version, do: "2.1.1"

def project do
[
Expand Down