This project is archived and is in readonly mode.
In generators #gsub_file should not silently alter files.
-
José Valim
- State changed from new to invalid
gsub_file should not ask for file collision. file_collision is done when you are creating a file in a place where another already exists. For instance, scaffold uses gsub_file to add routes to your config/routes.rb. If it asked every time if you want to modify it or not, it would be painful.
If Cucumber is going risky operation, they should ask their users before:
if yes?("Do you want to change your database.yml?") gsub_file ... endDoes it make sense?
-
Aslak Hellesøy
Thanks José - I wasn't aware of #yes? - I'll use that.
-
José Valim
You're welcome! Here is a list of methods that comes from Thor:
http://rdoc.info/rdoc/wycats/thor/blob/4f5da62d135aa10122e8c51f0c0d...
And here are the ones that Rails adds:
http://github.com/rails/rails/tree/master/railties/lib/rails/genera...
Regards!
-
Sam Goldstein
I agree that users (e.g. cucumber) should deal with the prompt/confirmation logic for
gsub_filesince this logic may vary case to case. It would be nice ifgsub_filesimply output that a change has taken place. Something like:changed config/database.ymlThis would help end users of generators know that a file had been changes, especially in cases (like database.yml) where it may be excluded from SCM. It doesn't make sense for each generator to have to roll their own code to tell the user that a file has changed.
-
José Valim
gsub_file does output. Unless you ask not to.