NAME

Software::License::Custom - custom license handler

VERSION

version 0.1.0_02

DESCRIPTION

This module extends Software::License to give the possibility of specifying all aspects related to a software license in a custom file. This allows for setting custom dates, notices, etc. while still preserving compatibility with all places where Software::License is used, e.g. Dist::Zilla.

In this way, you should be able to customise some aspects of the licensing messages that would otherwise be difficult to tinker, e.g. adding a note in the notice, setting multiple years for the copyright notice or set multiple authors and/or copyright holders.

The license details should be put inside a file that contains different sections. Each section has the following format:

  • header line

    a line that begins and ends with two underscores __. The string between the begin and the end of the line is first depured of any non-word character, then used as the name of the section;

  • body

    a Text::Template (possibly a plain text file) where items to be expanded are enclosed between double braces.

Each section is terminated by the header of the following section or by the end of the file. Example:

__[ NAME ]__
The Foo-Bar License
__URL__
http://www.example.com/foo-bar.txt
__[ META_NAME ]__
foo_bar_meta
__{ META2_NAME }__
foo_bar_meta2
__[ NOTICE ]__
Copyright (C) 2000-2002 by P.R. Evious
Copyright (C) {{$self->year}} by {{$self->holder}}.

This is free software, licensed under {{$self->name}}.

__[ LICENSE ]__
            The Foo-Bar License

Well... this is only some sample text. I'm true... only sample text!!!

Yes, spanning more lines and more paragraphs.

The different formats for specifying the section name in the example above are only examples, you're invited to use a consistent approach.

METHODS

new

my $slc = Software::License::Custom->new({filename => 'LEGAL'});

Create a new object. Arguments are passed through an anonymous hash, the following keys are allowed:

filename

the file where the custom software license details are written.

load_sections_from

$slc->load_sections_from('MY-LEGAL-ASPECTS');

Loads the different sections of the license from the provided filename.

Returns the input object.

section_data

my $notice_template_reference = $slc->section_data('NOTICE');

Returns a reference to a textual template that can be fed to Text::Template (it could be simple text), according to what is currently loaded in the object.

name

my $name = $slc->name();

Returns the name of the license, see Software::License for details.

url

my $url = $slc->url();

Returns the URL of the license, see Software::License for details.

meta_name

my $meta_name = $slc->meta_name();

See Software::License. Note that this method is a class method in Software::License, so it has been kept as a class method as well. When called as a class method, it returns custom.

meta2_name

my $meta2_name = $slc->meta2_name();

See Software::License.

license

my $license = $slc->license();

Returns the license text, see Software::License for details.

notice

my $notice = $slc->notice();

Returns the notice text, see Software::License for details.

fulltext

my $fulltext = $slc->fulltext();

See Software::License for details.

version

my $version = $slc->version();

See Software::License for details. This method replicates the semantic of the same method from Software::License as of version 0.102340.

BUGS

This module uses Software::License as a base but reimplements most of its methods to lower coupling with an implementation that could possibly change. In particular, the _fill_in method in Software::License has been copied because it's private.

It is assumed that the Software::License object is a hash and that the key Software::License::Custom in this hash is free for use. These seem to be reasonable assumptions.

AUTHOR

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Flavio Poletti <polettix@cpan.org>.

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

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.