This project is archived and is in readonly mode.

#4403 ✓invalid
Andrea Campi

Optionally include copyright boilerplate in generated files

Reported by Andrea Campi | April 15th, 2010 @ 10:14 AM

Every time I use a generator, the first thing I do when editing the generated files is add some copyright boilerplate to the top of the file. That doesn't sound DRY at all.

It would be cool if the generators could optionally include a file at the top.
I would propose that the generators should look for a .copyright.txt.erb file in Rails.root, or if that doesn't exist in $HOME. If neither exists, no boilerplate would be added.
The reason why I propose a .erb is that it would be cool to be able to at least interpolate the current year.

For reference, this would be the content of my $HOME/.copyright.txt.erb

============> cut <===========
# Copyright (c) #{current_year} ZephirWorks
# All rights reserved.
============> cut <===========

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg April 15th, 2010 @ 11:00 AM

    I thought that a LICENSE file in the root of your project implied the license was for all files inside. I don't know why it needs to be at the top of every file, it just seems like useless garbage to me when I'm working on an application and I end up removing it.


  • Ryan Bigg

    Ryan Bigg April 15th, 2010 @ 11:04 AM

    • State changed from “new” to “open”
  • Lenary

    Lenary April 15th, 2010 @ 11:12 AM

    This seems relatively astute, and not dangerous if you don't want to enable it through options.

    That said, it might be an idea to look at how you could get thor to automatically do this with class extension or something via the ./lib directory.

    Another avenue to look down would be completely custom generators, which you keep in a gem or repository. I'm not sure of the particulars of how rails 3 loads generators, but i'm sure you could investigate more!

    All in all, I think this is probably a good feature, but not for core rails. This is what gems/plugins are for!


  • Jeff Kreeftmeijer

    Jeff Kreeftmeijer April 15th, 2010 @ 11:41 AM

    Adding copyright information to the top of every file is the thing doesn't really sound DRY to me. I think it's perfect (and more DRY, for that matter) to just add a LICENCE file in your root. Also, I can't really see any reason why I would ever use this. Like Sam said though, put it in a gem! :)


  • Josh Nesbitt

    Josh Nesbitt April 15th, 2010 @ 01:15 PM

    I don't really understand why you would want to add more line noise to every file. A LICENSE file should suffice. Put it into a gem?


  • Ryan Bigg

    Ryan Bigg April 15th, 2010 @ 01:18 PM

    • State changed from “open” to “invalid”

    This has been downvoted by enough people that it's invalid.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket