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

make the location of USAGE file configurable #3501

Closed

Conversation

sinisterchipmunk
Copy link
Contributor

Imagine this scenario:

Lots of generators:

lib/generators/foo/bar/bar_generator.rb
lib/generators/baz/bab/bab_generator.rb

... some of which reuse the same templates in different contexts. So they set a common source_root to lib/generators/templates.

Rails will look for a usage file in lib/generators/USAGE and will use the same usage file for both generators! Not necessarily a good thing!

This pull request exposes a usage_file class method on Generator::Base to allow explicitly setting the location of the usage file.

@josevalim
Copy link
Contributor

If you want to change the location of the usage file, you can easily do: desc File.read("path/to/file"). Thanks for the pull request but I don't think we need to add more configurations on top of that.

@josevalim josevalim closed this Nov 3, 2011
@sinisterchipmunk
Copy link
Contributor Author

Yes, but doing this and retaining the functionality from #3494 starts to get messy:

desc ERB.new(File.read("path/to/usage")).result(binding)

Also, this doesn't allow deferring of the ERB template processing until runtime. It must be evaluated at class definition, at which point the application may or may not have loaded. This has an effect if the generator is sensitive to the Rails application configuration.

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.

None yet

2 participants