View Source mix ex_factor (ExFactor v0.4.1)

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 adds the refactored function to the end of the file and change all calls to the new module's name. If the Module does not exist ExFactor will conditionally create the path and the module and the refactored function will be added to the new module.

Required command line args: --module, --function, --arity, --target.

  • :module is the fully-qualified source module containing the function to move.
  • :function is the name of the function (as a string)
  • :arity the arity of function to move.
  • :target is the fully-qualified destination for the removed function. If the moduel does not exist, it will be created.

Optional command line args: --source_path, --target_path, --dryrun, --verbose

  • :target_path Specify an alternate (non-standard) path for the source file.
  • :source_path Specify an alternate (non-standard) path for the destination file.
  • :dryrun Don't write any updates, only return the built results.
  • :verbose (Default false) include the :state and :file_contents key values.
  • :format (Default true) when false don't run the formatter

Example Usage:

mix ex_factor --module MyModule.ToChange --function fn_to_change
--arity 2 --target YourModule.ChangeTo

Example Usage:

mix ex_factor --module MyModule.ToChange --function fn_to_change
  --arity 2 --target YourModule.ChangeTo
  --no-format --no-dryrun --no-verbose

Link to this section Summary

Functions

Callback implementation for Mix.Task.run/1.

Link to this section Functions

Callback implementation for Mix.Task.run/1.