Skip to content

Commit a933aeb

Browse files
committed
Merge branch 'master' of github.com:boydm/scenic into boyd
2 parents 3565a14 + b03e6ff commit a933aeb

File tree

9 files changed

+208
-225
lines changed

9 files changed

+208
-225
lines changed

lib/scenic/cache.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,14 @@ defmodule Scenic.Cache do
302302

303303
# --------------------------------------------------------
304304
defp do_keys(scope) do
305-
:ets.match(@scope_table, {scope, :"$2", :_})
305+
@scope_table
306+
|> :ets.match({scope, :"$2", :_})
306307
|> List.flatten()
307308
end
308309

309310
# --------------------------------------------------------
310311
defp key_in_scope?(scope, key) do
311-
case :ets.match(@scope_table, {scope, key, :_}) do
312-
[] -> false
313-
_ -> true
314-
end
312+
:ets.match(@scope_table, {scope, key, :_}) != []
315313
end
316314

317315
# ============================================================================

lib/scenic/cache/hash.ex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ defmodule Scenic.Cache.Hash do
1717
end
1818

1919
# --------------------------------------------------------
20+
@spec valid_hash_types() :: [:ripemd160 | :sha | :sha224 | :sha256 | :sha384 | :sha512, ...]
2021
def valid_hash_types(), do: @hash_types
2122
# --------------------------------------------------------
23+
@spec valid_hash_type?(any()) :: boolean()
2224
def valid_hash_type?(hash_type), do: Enum.member?(@hash_types, hash_type)
2325
# --------------------------------------------------------
26+
@spec valid_hash_type!(any()) :: any() | no_return
2427
def valid_hash_type!(hash_type) do
2528
case Enum.member?(@hash_types, hash_type) do
2629
true ->
@@ -33,9 +36,10 @@ defmodule Scenic.Cache.Hash do
3336
end
3437

3538
# --------------------------------------------------------
39+
@spec binary(any(), any()) :: {:error, :invalid_hash_type} | {:ok, binary()}
3640
def binary(data, hash_type) do
3741
case valid_hash_type?(hash_type) do
38-
true -> {:ok, :crypto.hash(hash_type, data) |> Base.url_encode64(padding: false)}
42+
true -> {:ok, hash_type |> :crypto.hash(data) |> Base.url_encode64(padding: false)}
3943
false -> {:error, :invalid_hash_type}
4044
end
4145
end
@@ -127,7 +131,7 @@ defmodule Scenic.Cache.Hash do
127131
end
128132
end
129133

130-
# --------------------------------------------------------
134+
# --------------------------------------------------------
131135
def verify_file!(path_data), do: path_params(path_data) |> do_verify_file!()
132136

133137
defp do_verify_file!({path, hash, hash_type}) do
@@ -139,7 +143,8 @@ defmodule Scenic.Cache.Hash do
139143

140144
# --------------------------------------------------------
141145
def from_path(path) do
142-
String.split(path, ".")
146+
path
147+
|> String.split(".")
143148
|> List.last()
144149
end
145150

lib/scenic/cache/supervisor.ex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ defmodule Scenic.Cache.Supervisor do
1717

1818
# import IEx
1919

20-
# @name :scenic_cache_supervisor
21-
2220
@cache_registry :scenic_cache_registry
2321

2422
# ============================================================================
2523
# setup the viewport supervisor
2624

2725
def start_link() do
28-
# Supervisor.start_link(__MODULE__, :ok, name: @name)
2926
Supervisor.start_link(__MODULE__, :ok)
3027
end
3128

0 commit comments

Comments
 (0)