Starting the License Applicator project

This commit is contained in:
Mahesh Asolkar 2013-02-25 12:37:16 -08:00
commit e3b5ca3754
4 changed files with 107 additions and 0 deletions

60
licapp.pl Executable file
View File

@ -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' => '//'
};
}

13
licenses/apache_v2.header Normal file
View File

@ -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.

15
licenses/gpl_v3.header Normal file
View File

@ -0,0 +1,15 @@
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.

19
licenses/mit.header Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) <year> <copyright holders>
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.