Forum: Ruby on Rails [OT] How to prepend copyright notices to each source file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Robert J. (Guest)
on 2006-02-11 17:20
(Received via mailing list)
Sorry for the off-topic post, but I guess someone else may hit the same
issue....

Having developed a rails application, I now need to put GPL text and a
copyright notice at the start of each source file.  For the .rb files,
this
will look like:

# Copyright 2006 Robert J............

and for the .rhtml files it will look like:

<!-- Copyright 2006 Robert J..........

Can anyone think of a neat way to do this prepending programatically on
Linux, rather than by hand?  I'm sure I can be done with awk, sed, grep
etc.

Thanks in advance,
--
Robert J.
Michael J. (Guest)
on 2006-02-11 18:18
(Received via mailing list)
make a script addhead in root directory:

#!/bin/sh
cat $2 $1 > $1.tmp
mv $1.tmp $1

then execute
find . -name "*.rb" -exec ./addhead {} header.txt \;

Michael J.
David M. (Guest)
on 2006-02-12 01:13
(Received via mailing list)
If you're using a layout file, put it in there.

If you're resorting to sed/awk/etc. for stuff like this, personally
I'd think that your design needs to be looked at and possibly
refactored.

Layouts are incredibly handy...

Regards

Dave M.
Charles M. Gerungan (Guest)
on 2006-02-12 09:04
(Received via mailing list)
On 12-feb-2006, at 0:13, David M. wrote:

>> Having developed a rails application, I now need to put GPL text
>> and a
>> copyright notice at the start of each source file.

> If you're using a layout file, put it in there.
>
> If you're resorting to sed/awk/etc. for stuff like this, personally
> I'd think that your design needs to be looked at and possibly
> refactored.

Refactored? He wanted the notice "at the start of each source file."

--
Regards, Charles.
David M. (Guest)
on 2006-02-12 09:27
(Received via mailing list)
Ah, my mistake - I read it as though he wanted to have a copyright
notice on each (published) page.
Robert J. (Guest)
on 2006-02-12 10:55
(Received via mailing list)
Thanks Michael - works like a charm.  So simple too.

Robert
This topic is locked and can not be replied to.