Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Recover readability of big ugly parsing block
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubén Caro committed Jun 9, 2015
1 parent 2a7bb7a commit eb30894
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/sshex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ defmodule SSHEx do
end

# Parse ugly response
defp receive_and_parse_response(channel, timeout, stdout, stderr, status, closed) do
defp receive_and_parse_response(chn, tout, stdout, stderr, status, closed) do
response = receive do
{:ssh_cm, _, res} -> res
after
timeout -> { :error, :taimaut }
tout -> { :error, :taimaut }
end

case response do
{:data, ^channel, 1, new_data} -> {:loop, {channel, timeout, stdout, stderr <> new_data, status, closed}}
{:data, ^channel, 0, new_data} -> {:loop, {channel, timeout, stdout <> new_data, stderr, status, closed}}
{:eof, ^channel} -> {:loop, {channel, timeout, stdout, stderr, status, closed}}
{:exit_signal, ^channel, _, _} -> {:loop, {channel, timeout, stdout, stderr, status, closed}}
{:exit_status, ^channel, new_status} -> {:loop, {channel, timeout, stdout, stderr, new_status, closed}}
{:closed, ^channel} -> {:loop, {channel, timeout, stdout, stderr, status, true}}
{:data, ^chn, 1, new_data} -> {:loop, {chn, tout, stdout, stderr <> new_data, status, closed}}
{:data, ^chn, 0, new_data} -> {:loop, {chn, tout, stdout <> new_data, stderr, status, closed}}
{:eof, ^chn} -> {:loop, {chn, tout, stdout, stderr, status, closed}}
{:exit_signal, ^chn, _, _} -> {:loop, {chn, tout, stdout, stderr, status, closed}}
{:exit_status, ^chn, new_status} -> {:loop, {chn, tout, stdout, stderr, new_status, closed}}
{:closed, ^chn} -> {:loop, {chn, tout, stdout, stderr, status, true}}
x -> x
end
end
Expand Down

0 comments on commit eb30894

Please sign in to comment.