Skip to content

Commit

Permalink
chore: remove elixir prefix for generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamez committed Nov 26, 2024
1 parent cb50a53 commit 97745a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/protox/generate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ defmodule Protox.Generate do
defp generate_files(output_path, code, true = _muliple_files) do
Enum.map(code, fn {:defmodule, _, [module_name | _]} = module_code ->
snake_module_name =
module_name |> to_string() |> String.replace(".", "") |> Macro.underscore()
module_name
|> Module.split()
|> Enum.map_join("_", &Macro.underscore/1)

%FileContent{
name: Path.join(output_path, snake_module_name <> ".ex"),
Expand Down
8 changes: 4 additions & 4 deletions test/protox/generate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ defmodule Protox.GenerateTest do

assert [
%Protox.Generate.FileContent{
name: "generated_code/elixir_bar.ex",
name: "generated_code/bar.ex",
content: bar_content
},
%Protox.Generate.FileContent{
name: "generated_code/elixir_foo.ex",
name: "generated_code/foo.ex",
content: foo_content
}
] = files_content
Expand Down Expand Up @@ -98,11 +98,11 @@ defmodule Protox.GenerateTest do

assert [
%Protox.Generate.FileContent{
name: "generated_code/elixir_namespace_bar.ex",
name: "generated_code/namespace_bar.ex",
content: bar_content
},
%Protox.Generate.FileContent{
name: "generated_code/elixir_namespace_foo.ex",
name: "generated_code/namespace_foo.ex",
content: foo_content
}
] = files_content
Expand Down

0 comments on commit 97745a6

Please sign in to comment.