Skip to content

Commit

Permalink
refactor and format
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoch-cars committed Sep 18, 2021
1 parent 4a90b3e commit 6517e8a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Use at your peril, _for now._
- [] find types referenced in the moved specs
- [] find private functions references in refactored fn bodies.
- [] update test file refs by CLI option
- [] format changes
- [] ElixirLS integration for VSCode?
- [] Write the module code to rename usages of the refactored function
- [] guthub actions, run test suite
Expand All @@ -34,6 +33,7 @@ Use at your peril, _for now._
- [X] Write a mix task to invoke the Refactorer
- [X] dry-run option
- [X] CLI output, list files changed and created.
- [X] format changes

## Installation

Expand Down
14 changes: 13 additions & 1 deletion lib/ex_factor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ defmodule ExFactor do
alias ExFactor.Remover

@doc """
Call Extractor module emaplce/1
Call Extractor, Remover, and Formatter modules
"""
def refactor(opts) do
source_module = Keyword.fetch!(opts, :source_module)
target_module = Keyword.fetch!(opts, :target_module)

opts =
opts
|> Keyword.put_new(:target_path, path(target_module))
|> Keyword.put_new(:source_path, path(source_module))

emplace = Extractor.emplace(opts)
remove = Remover.remove(opts)
{emplace, remove}
end

def path(module) do
Path.join(["lib", Macro.underscore(module) <> ".ex"])
end
end
4 changes: 1 addition & 3 deletions lib/ex_factor/extractor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ defmodule ExFactor.Extractor do
end
end

defp path(module) do
Path.join(["lib", Macro.underscore(module) <> ".ex"])
end
defp path(module), do: ExFactor.path(module)

defp refactor_message, do: "#refactored function moved with ExFactor"

Expand Down
4 changes: 1 addition & 3 deletions lib/ex_factor/remover.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ defmodule ExFactor.Remover do
File.write(path, contents, [:write])
end

defp path(module) do
Path.join(["lib", Macro.underscore(module) <> ".ex"])
end
defp path(module), do: ExFactor.path(module)
end

0 comments on commit 6517e8a

Please sign in to comment.