diff --git a/CHANGELOG.md b/CHANGELOG.md index 62bc030..ecf8ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/exos.ex b/lib/exos.ex index f88be95..7d7a8ff 100644 --- a/lib/exos.ex +++ b/lib/exos.ex @@ -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 diff --git a/mix.exs b/mix.exs index e2d599a..369f5f9 100644 --- a/mix.exs +++ b/mix.exs @@ -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 [