cli icon indicating copy to clipboard operation
cli copied to clipboard

Refactor RubyFileWriter

Open cllns opened this issue 1 year ago • 0 comments

Addresses #202

Although, I ended up not using slice.source_path. I had an implementation working that just took a Hanami::Slice and used .namespace and .source_path but it proved hard to test. I couldn't figure out how to register a slice into the Test::App.

Instead, the RubyFileWriter takes namespace and base_path, and we do the mapping in Generate::Command.

Happy to change this over if we can figure out a simple way to test that, to simplify the code, but I also feel like it's reasonable that a "File Writer" would require a namespace and a path as separate args, even though they're coupled in our apps.

I also changed the RubyFileWriter implementation so that call takes the file-specific args, instead of no args for call and all of them being passed to the initializer. I implemented this via helper class, as passing around all the variables that need to be passed around proved to make the code very messy.

I want to handle this refactoring before using RubyFileWriter in other generators.

cllns avatar Aug 01 '24 20:08 cllns