Skip to content

Commit

Permalink
Format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
nroi committed Sep 2, 2018
1 parent ecab238 commit 13eed6d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
7 changes: 2 additions & 5 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Used by "mix format"
[
inputs: [
"lib/**/*.{ex,exs}",
"test/**/*.{ex,exs}",
"mix.exs"
]
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
8 changes: 5 additions & 3 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
use Mix.Config

config :paracusia,
retry_after: 100, # if connecting to MPD failed, try again after x milliseconds
max_retry_attempts: 3 # Give up if no connection could be established after x attempts.
# if connecting to MPD failed, try again after x milliseconds
retry_after: 100,
# Give up if no connection could be established after x attempts.
max_retry_attempts: 3

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand All @@ -31,4 +33,4 @@ config :paracusia,
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
import_config "#{Mix.env}.exs"
import_config "#{Mix.env()}.exs"
3 changes: 2 additions & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ use Mix.Config

config :paracusia,
hostname: "localhost",
port: 9091 # port the mock server will listen on
# port the mock server will listen on
port: 9091
6 changes: 4 additions & 2 deletions lib/paracusia/message_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ defmodule Paracusia.MessageParser do
[{"foo", "bar"}, {"baz", "fam"}]
"""
def parse_uris(m) do
m |> String.split("\n", trim: true)
m
|> String.split("\n", trim: true)
|> Enum.map(fn item ->
case item |> String.split(": ", parts: 2) do
[first, second] -> {first, second}
Expand All @@ -60,7 +61,8 @@ defmodule Paracusia.MessageParser do
["Beatles", "Lady Gaga"]
"""
def parse_newline_separated_enum(m) do
m |> parse_uris
m
|> parse_uris
|> Enum.map(fn {_, value} -> value end)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/paracusia/mpd_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ defmodule Paracusia.MpdClient do
# closing its connection to Paracusia), connecting to MPD may fail if MPD takes longer to
# restart than Paracusia. For that reason, we retry connection establishment.
ip_addrs = ip_addresses(hostname)
if ip_addrs == [], do: raise "Unable to resolve IP address for hostname #{inspect hostname}"
if ip_addrs == [], do: raise("Unable to resolve IP address for hostname #{inspect(hostname)}")
sock = connect_retry(ip_addresses(hostname), port, 1, 0, retry_after, max_attempts)
{:ok, "OK MPD" <> _} = :gen_tcp.recv(sock, 0)

Expand Down Expand Up @@ -238,7 +238,7 @@ defmodule Paracusia.MpdClient do
end

def handle_info({:tcp_closed, _}, state) do
_ = Logger.warn "TCP connection closed by server."
_ = Logger.warn("TCP connection closed by server.")
{:stop, :disconnect_by_server, state}
end

Expand Down

0 comments on commit 13eed6d

Please sign in to comment.