Skip to content

Pass .annotaterb.yml through ERB#225

Merged
drwl merged 3 commits intodrwl:mainfrom
fxn:main
Jun 17, 2025
Merged

Pass .annotaterb.yml through ERB#225
drwl merged 3 commits intodrwl:mainfrom
fxn:main

Conversation

@fxn
Copy link
Contributor

@fxn fxn commented Jun 12, 2025

Hi!

This PR proposes passing .annotaterb.yml through ERB, as Rails does with config/database.yml or fixtures, for instance.

Real use case is the ability to compute model_dir dynamically. As you know, in annotate the configuration can be expressed in Ruby, and therefore it can be as dynamic as you need to. But if you migrate to annotaterb, that is lost.

I wrote this patch on behalf of a client of mine (Gusto), whose main application has more than two hundred model dirs. They are now hard-coded in .annotaterb.yml, but you need to maintain that list, verify consistency in CI, etc. On the other hand, if you could compute the list in the config file itself, you could forget about it (as it was the case with annotate).

I have created a test suite for load_config, and documentation is also updated (README and migration guide). The variable yaml_code is named after the parameter in the signature of the called method.

The CHANGELOG seems more ad-hoc, maybe you prefer to modify this one? Please just tell me if you'd like me to do it anyway :).

@fxn fxn changed the title Pass .annotate.yml through ERB Pass .annotaterb.yml through ERB Jun 12, 2025
@drwl
Copy link
Owner

drwl commented Jun 15, 2025

Hi @fxn thanks for submitting this. Happy to help get this merged this in, seems like there might be an unrelated 2.7 error and then just needs linting via standard.

@drwl
Copy link
Owner

drwl commented Jun 15, 2025

I merged in a PR that drops Ruby 2.7 support, so if you rebase or merge latest development, it'll "fix" the unit test that is failing in 2.7

@fxn
Copy link
Contributor Author

fxn commented Jun 15, 2025

Thanks @drwl! Branch updated and standard is green now.

@drwl drwl merged commit ba4bb2e into drwl:main Jun 17, 2025
22 checks passed
@drwl
Copy link
Owner

drwl commented Jun 18, 2025

Just fyi, I released 4.16.0 and it should contain this change.

@fxn
Copy link
Contributor Author

fxn commented Jun 18, 2025

@drwl that's awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants