Skip to content

Commit

Permalink
Delete unused components
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmi committed Jan 5, 2024
1 parent 3047edb commit 5747e17
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 450 deletions.
28 changes: 0 additions & 28 deletions lib/dsl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ defmodule Strom.DSL do
defstruct splitter: nil, opts: [], input: nil, partitions: %{}
end

defmodule Function do
defstruct function: nil, opts: [], inputs: []
end

defmodule Transform do
defstruct function: nil, acc: nil, inputs: [], call: nil
end

defmodule Module do
defstruct module: nil, opts: [], inputs: [], state: nil
end

defmodule Rename do
defstruct names: nil, rename: nil
end
Expand Down Expand Up @@ -75,16 +67,6 @@ defmodule Strom.DSL do
end
end

defmacro function(inputs, function, opts \\ []) do
quote do
%Strom.DSL.Function{
function: unquote(function),
opts: unquote(opts),
inputs: unquote(inputs)
}
end
end

defmacro transform(inputs, function, acc) do
quote do
%Strom.DSL.Transform{
Expand All @@ -105,16 +87,6 @@ defmodule Strom.DSL do
end
end

defmacro module(inputs, module, opts \\ []) do
quote do
%Strom.DSL.Module{
module: unquote(module),
opts: unquote(opts),
inputs: unquote(inputs)
}
end
end

defmacro from(module, opts \\ []) do
quote do
unless is_atom(unquote(module)) do
Expand Down
19 changes: 0 additions & 19 deletions lib/flow.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,9 @@ defmodule Strom.Flow do
%DSL.Splitter{opts: opts} = splitter ->
%{splitter | splitter: Strom.Splitter.start(opts)}

%DSL.Function{function: function, opts: opts} = fun ->
%{fun | function: Strom.Function.start(function, opts)}

%DSL.Transform{} = fun ->
%{fun | call: Strom.Transformer.start()}

%DSL.Module{module: module, opts: opts} = mod ->
module = Strom.Module.start(module, opts)
%{mod | module: module}

%DSL.Rename{names: names} = ren ->
rename = Strom.Renamer.start(names)
%{ren | rename: rename}
Expand Down Expand Up @@ -93,19 +86,13 @@ defmodule Strom.Flow do
%DSL.Splitter{splitter: splitter, input: input, partitions: partitions} ->
Strom.Splitter.call(flow, splitter, input, partitions)

%DSL.Function{function: function, inputs: inputs} ->
Strom.Function.call(flow, function, inputs)

%DSL.Transform{call: call, function: function, acc: acc, inputs: inputs} ->
if is_function(function, 2) do
Strom.Transformer.call(flow, call, inputs, {function, acc})
else
Strom.Transformer.call(flow, call, inputs, function)
end

%DSL.Module{module: module, inputs: inputs} ->
Strom.Module.call(flow, module, inputs)

%DSL.Rename{rename: rename, names: names} ->
Strom.Renamer.call(flow, rename, names)
end
Expand All @@ -130,14 +117,8 @@ defmodule Strom.Flow do
%DSL.Splitter{splitter: splitter} ->
Strom.Splitter.stop(splitter)

%DSL.Function{function: function} ->
Strom.Function.stop(function)

%DSL.Transform{call: call} ->
Strom.Transformer.stop(call)

%DSL.Module{module: module} ->
Strom.Module.stop(module)
end
end)

Expand Down
59 changes: 0 additions & 59 deletions lib/function.ex

This file was deleted.

67 changes: 0 additions & 67 deletions lib/loop.ex

This file was deleted.

73 changes: 0 additions & 73 deletions lib/module.ex

This file was deleted.

8 changes: 5 additions & 3 deletions lib/transformer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ defmodule Strom.Transformer do
end

def call(flow, %__MODULE__{} = call, names, {function, acc})
when is_map(flow) and is_list(names) and is_function(function, 3) do
when is_map(flow) and is_function(function, 3) do
names = if is_list(names), do: names, else: [names]

input_streams =
Enum.reduce(names, %{}, fn name, streams ->
Map.put(streams, {name, function, acc}, Map.fetch!(flow, name))
Expand Down Expand Up @@ -72,13 +74,13 @@ defmodule Strom.Transformer do
end

def call(flow, %__MODULE__{} = call, names, {function, acc})
when is_map(flow) and is_list(names) and is_function(function, 2) do
when is_map(flow) and is_function(function, 2) do
fun = fn el, acc, nil -> function.(el, acc) end
call(flow, %__MODULE__{} = call, names, {fun, acc})
end

def call(flow, %__MODULE__{} = call, names, function)
when is_map(flow) and is_list(names) and is_function(function, 1) do
when is_map(flow) and is_function(function, 1) do
fun = fn el, nil, nil -> {[function.(el)], nil} end
call(flow, %__MODULE__{} = call, names, {fun, nil})
end
Expand Down
65 changes: 0 additions & 65 deletions test/function_test.exs

This file was deleted.

Loading

0 comments on commit 5747e17

Please sign in to comment.