Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: packs-rails support #99

Open
wilsonehusin opened this issue Mar 26, 2024 · 3 comments · May be fixed by #198
Open

Feature request: packs-rails support #99

wilsonehusin opened this issue Mar 26, 2024 · 3 comments · May be fixed by #198
Labels
help wanted Extra attention is needed

Comments

@wilsonehusin
Copy link

I'm trying out annotaterb on a Rails project which has packs-rails setup. The packs/ directory doesn't get automatically picked up, understandably.

  1. I tried to use :root_dir: ['.', 'packs/*'] and only app/ directory in the root gets picked up, none of the packs were recognized.
    • I also tried variations of packs/* by expanding it to packs/packone packs/packtwo etc, still doesn't work.
  2. I tried to use `:model_dir: ['app/models', 'packs/*/app/models'] and still the packs aren't picked up. However, expanding the glob works!

While the title is specifically on packs-rails, I wouldn't mind having a compromise via :root_dir: or :model_dir: if it supports globs 😄

P.S. 👋🏻 hey Andrew, hope you've been well!

Versions

  • annotaterb 4.6.0
  • rails 6.1
  • ruby 3.1
@drwl
Copy link
Owner

drwl commented Mar 28, 2024

Hi Wilson, I'm doing alright, hope you're doing good as well. I haven't used pack-rails gem before so let me take a look into it. I think there's demand for supporting alternative structures as also seen in #82.

I'm hoping to dedicate some time soon to get a good understanding of the different use cases and a path forward.

@gmcabrita
Copy link
Contributor

gmcabrita commented May 30, 2024

To unblock us we updated our rake task to look like this:

# This rake task was added by annotate_rb gem.

# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil?
  require "annotate_rb"
  require "yaml"

  config_file = ".annotaterb.yml"
  config = YAML.load_file(config_file)
  model_dirs = `find packs -type d -name 'app/models' -prune -o -path '*/app/models' -type d`.split("\n").sort
  config[:model_dir] = ["app/models"] + model_dirs
  File.open(config_file, "w") { |f| YAML.dump(config, f) }

  AnnotateRb::Core.load_rake_tasks
end

It would be nice to have support for this in annotaterb though!

@jeromepl
Copy link

Having the config file be a ruby script had the advantage that we could more easily customize things like this. With annotate, we could do:

"model_dir" => Dir.glob("**/app/models").join(","),

An approach to get something similar in a yaml file could be to allow ERB syntax to be used in the file. So we could do:

model_dir: <%= Dir.glob("**/app/models").join(",") %>

@drwl drwl added the help wanted Extra attention is needed label Feb 17, 2025
sinsoku added a commit to sinsoku/annotaterb that referenced this issue Feb 27, 2025
We often want to specify multiple directories in `root_dir` and `model_dir`.
For example, when using engines, packs-rails, etc.

* https://github.com/rubyatscale/packs-rails
* https://guides.rubyonrails.org/engines.html

This commit supports the glob pattern with these options, making it easy
to specify multiple directories.

fixes drwl#99
@sinsoku sinsoku linked a pull request Feb 27, 2025 that will close this issue
sinsoku added a commit to sinsoku/annotaterb that referenced this issue Mar 3, 2025
We often want to specify multiple directories in `root_dir` and `model_dir`.
For example, when using engines, packs-rails, etc.

* https://github.com/rubyatscale/packs-rails
* https://guides.rubyonrails.org/engines.html

This commit supports the glob pattern with these options, making it easy
to specify multiple directories.

fixes drwl#99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants