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.
80b3b3a2e46cc1418f92497a1e8f84ae?d=identicon&s=25 Robert Jones (Guest)
on 2006-02-11 16: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 Jones...........

and for the .rhtml files it will look like:

<!-- Copyright 2006 Robert Jones.........

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 Jones
91d00b2e1d76029cb9175053a846051b?d=identicon&s=25 Michael Johnston (Guest)
on 2006-02-11 17: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 Johnston
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2006-02-12 00: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.
37b7b848b1e3d667174d28d32d04bcee?d=identicon&s=25 Charles M. Gerungan (Guest)
on 2006-02-12 08:04
(Received via mailing list)
On 12-feb-2006, at 0:13, David Mitchell 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.
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2006-02-12 08:27
(Received via mailing list)
Ah, my mistake - I read it as though he wanted to have a copyright
notice on each (published) page.
80b3b3a2e46cc1418f92497a1e8f84ae?d=identicon&s=25 Robert Jones (Guest)
on 2006-02-12 09: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.