Skip to content

Commit

Permalink
Use @callback instead of use Behaviour (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
davydog187 authored and alco committed Sep 7, 2017
1 parent 83f1e0f commit 01e8462
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 9 additions & 11 deletions lib/porcelain/drivers/driver_common.ex
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
defmodule Porcelain.Driver.Common do
@moduledoc false

use Behaviour
@callback exec(prog :: binary, args :: [binary], opts :: Keyword.t) :: any
@callback exec_shell(prog :: binary, opts :: Keyword.t) :: any
@callback spawn(prog :: binary, args :: [binary], opts :: Keyword.t) :: Porcelain.Process
@callback spawn_shell(prog :: binary, opts :: Keyword.t) :: Porcelain.Process

defcallback exec(prog :: binary, args :: [binary], opts :: Keyword.t)
defcallback exec_shell(prog :: binary, opts :: Keyword.t)
defcallback spawn(prog :: binary, args :: [binary], opts :: Keyword.t)
defcallback spawn_shell(prog :: binary, opts :: Keyword.t)

defcallback feed_input(port :: port, input :: iodata)
defcallback process_data(data :: binary, output :: any, error :: any)
defcallback send_signal(port :: port, signal :: Porcelain.Process.signal)
defcallback stop_process(port :: port) :: integer
@callback feed_input(port :: port, input :: iodata) :: any
@callback process_data(data :: binary, output :: any, error :: any) :: tuple
@callback send_signal(port :: port, signal :: Porcelain.Process.signal) :: boolean | nil
@callback stop_process(port :: port) :: integer


alias Porcelain.Driver.Common.StreamServer
Expand Down Expand Up @@ -162,7 +160,7 @@ defmodule Porcelain.Driver.Common do
end

defp send_result(out, err, opt, result) do
result = if opt == :discard, do: result = nil, else: result
result = if opt == :discard, do: nil, else: result
msg = {self(), :result, result}

out_ret = case out do
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
%{"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}}
%{"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}}

0 comments on commit 01e8462

Please sign in to comment.