Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Optionally include copyright boilerplate in generated files

#4403

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 <===========

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Ryan Bigg
    Ryan Bigg

    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.

    -1

    April 15th, 2010 @ 11:00 AM

  2. Ryan Bigg
    Ryan Bigg
    • State changed from new to open

    April 15th, 2010 @ 11:04 AM

  3. Lenary
    Lenary

    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!

    -1

    April 15th, 2010 @ 11:12 AM

  4. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    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! :)

    -1

    April 15th, 2010 @ 11:41 AM

  5. Josh Nesbitt
    Josh Nesbitt

    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?

    -1

    April 15th, 2010 @ 01:15 PM

  6. Ryan Bigg
    Ryan Bigg
    • State changed from open to invalid

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

    April 15th, 2010 @ 01:18 PM