commit e3b5ca37548f656ebfd0d87ff87087233a68d944 Author: Mahesh Asolkar Date: Mon Feb 25 12:37:16 2013 -0800 Starting the License Applicator project diff --git a/licapp.pl b/licapp.pl new file mode 100755 index 0000000..1100c25 --- /dev/null +++ b/licapp.pl @@ -0,0 +1,60 @@ +#!/bin/env perl + +use strict; +use warnings; +use File::Find; +use FileHandle; +use Data::Dumper; +use Getopt::Long; +use Cwd; + +# Application configuration and state storage +my $app = {}; + +# Defaults +$app->{'options'}->{'directory'} = getcwd; +$app->{'options'}->{'license'} = 'mit'; + +# Command line options +my $correct_usage = GetOptions ( + 'directory=s' => \$app->{'options'}->{'directory'}, + 'license=s' => \$app->{'options'}->{'license'}); + +setup_license_pretty_names($app); +setup_filetype_comment_mapping($app); + +print "Applying '" + . $app->{'license_pretty_names'}->{$app->{'options'}->{'license'}} + . "' license to files in '" + . $app->{'options'}->{'directory'} + ."' directory\n"; + +# +# Subroutines +# +sub setup_license_pretty_names { + my ($app) = @_; + + $app->{'license_pretty_names'} = { + 'mit' => 'MIT', + 'gpl_v1' => 'GPL v1', + 'gpl_v2' => 'GPL v2', + 'gpl_v3' => 'GPL v3', + 'apache_v2' => 'Apache v2', + 'apache_v1' => 'Apache v1' + }; +} + +sub setup_filetype_comment_mapping { + my ($app) = @_; + + $app->{'filetype_commants'} = { + '.pl' => '#', + '.rb' => '#', + '.erb' => [''], + '.html' => [''], + '.v' => '//', + '.sv' => '//', + '.vr' => '//' + }; +} diff --git a/licenses/apache_v2.header b/licenses/apache_v2.header new file mode 100644 index 0000000..004c62e --- /dev/null +++ b/licenses/apache_v2.header @@ -0,0 +1,13 @@ +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/licenses/gpl_v3.header b/licenses/gpl_v3.header new file mode 100644 index 0000000..55a3551 --- /dev/null +++ b/licenses/gpl_v3.header @@ -0,0 +1,15 @@ + +Copyright (C) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/licenses/mit.header b/licenses/mit.header new file mode 100644 index 0000000..78dba97 --- /dev/null +++ b/licenses/mit.header @@ -0,0 +1,19 @@ +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.