-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fns added. refactor and cleanup needed.
- Loading branch information
1 parent
8bc9c52
commit eca25dd
Showing
6 changed files
with
451 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
defmodule ExFactor do | ||
@moduledoc """ | ||
Documentation for `ExFactor`. | ||
`ExFactor` is a refactoring helper. | ||
By identifying a Module, function name, and arity, it will identify all non-test usages | ||
and extract them to a new Module. | ||
If the Module exists, it add the function to the end of the file and change all calls to the | ||
new module's name. | ||
""" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule ExFactor.Neighbors do | ||
@moduledoc """ | ||
Documentation for `ExFactor.Neighbors`. | ||
""" | ||
|
||
def prev(block, fn_name) do | ||
block | ||
|> Enum.reduce({[], []}, fn el, acc -> | ||
eval_elem(el, acc, fn_name) | ||
end) | ||
|> elem(1) | ||
end | ||
|
||
defp eval_elem({type, _, [{name, _, _} | _]} = el, {pending, acc}, name) | ||
when type in [:def, :defp] do | ||
{[], acc ++ pending ++ [el]} | ||
end | ||
|
||
defp eval_elem({type, _, _}, {_pending, acc}, _name) when type in [:def, :defp] do | ||
{[], acc} | ||
end | ||
|
||
defp eval_elem({type, _, _}, {pending, acc}, _name) when type in [:alias] do | ||
{pending, acc} | ||
end | ||
|
||
defp eval_elem(el, {pending, acc}, _name) do | ||
{pending ++ [el], acc} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.