Configurable parsers (continued)#375
Conversation
Co-authored-by: Davis Namsons <davisnamsons@gmail.com>
|
I have signed the CLA! |
|
I had some tests failing sporadically, so I've managed to surface three different failure modes with the seeds: I still need to track down the root cause, but the default parsers aren't registered in seeds Unfortunately, I haven't had time to dig into it. Hopefully I'll get to it on the weekend |
|
@richardmarbach 1. Remove
|
|
Thanks for looking into it, @euglena1215! Those fixes resolved the outstanding issues with the tests. |
|
Hi @gmcgibbon ! Is there any information missing to review this pull request? I would like to provide that support! |
|
I'm also interested in using the Packwerk HAML plugin! Is there anything else needed for this pull request? or is it just waiting for review? |
|
Not sure who the active maintainers are but based on PR history, @gmcgibbon or @nvasilevski perhaps Any chance of merging this? As with a lot of the other devs here, I also want to use these changes to add a slim parser 🙏 🚀 |
Co-authored-by: Davis Namsons davisnamsons@gmail.com
Due to stalled activity in #243, I took liberty and completed the change requests from #243 (comment)
Due to messy merge conflicts, I decided to redo the feature with a fresh commit history. I co-authored @dnamsons, as he did most of the hard work!
This is the first time I've used minitest, so I'd love some feedback on my usage. The rest of the PR body is a copy of the original.
What are you trying to accomplish?
As discussed on #142, this change allows for additional parsers to be added.
This also allows extracting the erb parser out of packwerk(which might be desired - #142 (comment)).
What approach did you choose and why?
modified the
Packwerk::Parsers::Factoryclass to store parsers in an instance variable and made this variable modifiable via the use of anattr_accessor.moved the regex constants into their respective parser classes and added a new method
.match?to each parser class which verifies if a given path is relevant to the parser.changed
Packwerk::Parsers::Factory#for_pathto iterate through the defined parsers to find a parser whosematch?method returns true.I considered multiple different alternatives to how new parsers can be defined(and the existing ones removed) but could not land on a satisfactory solution, so I stuck with the simplest one in hopes I could get some advice on how best to proceed.
Currently every parser is initialized anew for every new file that matches with its regex. I considered either storing already initialized parser instances in the
parsersinstance variable or, alternatively, creating a sort of a "cache" of parser instances but wasn't sure on which would be preferable.What should reviewers focus on?
As mentioned above, my current approach to the the configuration of parsers is simplistic, I would appreciate any input on how to make this be more in line with the general structure of packwerk.
Type of Change
Additional Release Notes
Checklist