aboutsummaryrefslogtreecommitdiff
path: root/lib/boltex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/boltex')
-rw-r--r--lib/boltex/bolt.ex8
-rw-r--r--lib/boltex/pack_stream.ex10
-rw-r--r--lib/boltex/utils.ex6
3 files changed, 12 insertions, 12 deletions
diff --git a/lib/boltex/bolt.ex b/lib/boltex/bolt.ex
index 984d0b6..d433ea6 100644
--- a/lib/boltex/bolt.ex
+++ b/lib/boltex/bolt.ex
@@ -89,7 +89,8 @@ defmodule Boltex.Bolt do
Messages have to be in the form of {[messages], signature}.
"""
def send_messages(transport, port, messages) do
- Enum.map(messages, &generate_binary_message/1)
+ messages
+ |> Enum.map(&generate_binary_message/1)
|> generate_chunks
|> Enum.each(&(transport.send(port, &1)))
end
@@ -151,7 +152,7 @@ defmodule Boltex.Bolt do
]
with {:success, %{}} = data <- receive_data(transport, port),
- do: [data | receive_data(transport, port) |> List.wrap]
+ do: [data | transport |> receive_data(port) |> List.wrap]
end
@doc """
@@ -178,7 +179,7 @@ defmodule Boltex.Bolt do
* `:failure`
"""
def receive_data(transport, port, previous \\ []) do
- case do_receive_data(transport, port) |> unpack do
+ case transport |> do_receive_data(transport) |> unpack do
{:record, _} = data ->
receive_data transport, port, [data | previous]
@@ -207,7 +208,6 @@ defmodule Boltex.Bolt do
{:error, :timeout} ->
{:error, :no_more_data_received}
other ->
- IO.inspect Utils.hex_encode other
raise "receive failed"
end
end
diff --git a/lib/boltex/pack_stream.ex b/lib/boltex/pack_stream.ex
index 736351f..aeca3a9 100644
--- a/lib/boltex/pack_stream.ex
+++ b/lib/boltex/pack_stream.ex
@@ -56,9 +56,8 @@ defmodule Boltex.PackStream do
def decode(<< 0xD5, list_size :: 16 >> <> bin), do: list(bin, list_size)
def decode(<< 0xD6, list_size :: 32 >> <> bin), do: list(bin, list_size)
def decode(<< 0xD7 >> <> bin) do
- position =
- for(<< byte <- bin >>, do: byte)
- |> Enum.find_index(&(&1 == 0xDF))
+ bytes = for(<< byte <- bin >>, do: byte)
+ position = Enum.find_index bytes, &(&1 == 0xDF)
<< list :: binary-size(position), 0xDF, rest :: binary >> = bin
@@ -71,9 +70,8 @@ defmodule Boltex.PackStream do
def decode(<< 0xD9, entries :: 16 >> <> bin), do: map(bin, entries)
def decode(<< 0xDA, entries :: 32 >> <> bin), do: map(bin, entries)
def decode(<< 0xDB >> <> bin) do
- position =
- for(<< byte <- bin >>, do: byte)
- |> Enum.find_index(&(&1 == 0xDF))
+ bytes = for(<< byte <- bin >>, do: byte)
+ position = Enum.find_index bytes, &(&1 == 0xDF)
<< map:: binary-size(position), 0xDF, rest :: binary >> = bin
diff --git a/lib/boltex/utils.ex b/lib/boltex/utils.ex
index 333217e..fea5759 100644
--- a/lib/boltex/utils.ex
+++ b/lib/boltex/utils.ex
@@ -1,4 +1,6 @@
defmodule Boltex.Utils do
+ @moduledoc "Different utils used to debugging and helping."
+
def reduce_to_binary(enumerable, transform) do
Enum.reduce enumerable, <<>>, fn(data, acc) -> acc <> transform.(data) end
end
@@ -8,7 +10,7 @@ defmodule Boltex.Utils do
end
def hex_decode(hex_list) do
- for(hex <- hex_list, do: Integer.parse(hex, 16) |> elem(0))
- |> reduce_to_binary(&<<&1>>)
+ integers = for(hex <- hex_list, do: hex |> Integer.parse(16) |> elem(0))
+ reduce_to_binary integer, &<<&1>>
end
end