insert copyright

This is a little Ruby system to insert copyrights into your source files based on a set copyright contained somewhere on your hard drive. The source and 60 test files are here, though the main file is insert-copyright.rb:


To use it you first create your copyright file in ~/.copyright; you can also pass in onto the command line with the -f switch, such as:

insert_copyright -r copyright.txt...

Mine looks like this:

Copyright (C) %YEAR% Jeffrey Palm. All rights reserved.

As you can see there is a %YEAR declaration that will be substituted with the current year. The other substitutions are %DATE%, %TIME%, and %DATETIME%. After this you simply pass it any of the following types of files (generated by passing in the -h switch); and these are of the form file-type / file extensions, interpreters:

Ruby / ruby,rb / ruby
PHP / php,inc / php
Shellscript / bash,sh,tcsh,ash / bash,sh,tcsh,ash
Perl / perl,pl / perl
Python / py,jython,python / python,jython
ML / ml,sml / ml
Java / java / 
Javascript / js / 
C / c,cc,cpp,cs / 
HTML / html,htm / 
Scheme / ss,scm / scheme,mzc
Lisp / lsp,lisp / lisp

The idea is that you can pass in whatever kind of file, first determined by file extension, then by interpreter declaration in the start of the file, such as

#!/usr/bin/env ruby