GRAYBYTE WORDPRESS FILE MANAGER2863

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /usr/share/perl5/vendor_perl/Software/License/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /usr/share/perl5/vendor_perl/Software/License//Custom.pm
use strict;
use warnings;
package Software::License::Custom;
# ABSTRACT: custom license handler
$Software::License::Custom::VERSION = '0.103013';
use parent 'Software::License';

use Carp;
use Text::Template;

#pod =head1 DESCRIPTION
#pod
#pod This module extends L<Software::License> to give the possibility of specifying
#pod all aspects related to a software license in a custom file.  This allows for
#pod setting custom dates, notices, etc. while still preserving compatibility with
#pod all places where L<Software::License> is used, e.g. L<Dist::Zilla>.
#pod
#pod In this way, you should be able to customise some aspects of the licensing
#pod messages that would otherwise be difficult to tinker, e.g. adding a note
#pod in the notice, setting multiple years for the copyright notice or set multiple
#pod authors and/or copyright holders.
#pod
#pod The license details should be put inside a file that contains different
#pod sections. Each section has the following format:
#pod
#pod =begin :list
#pod
#pod = header line
#pod
#pod This is a line that begins and ends with two underscores C<__>. The string
#pod between the begin and the end of the line is first depured of any non-word
#pod character, then used as the name of the section;
#pod
#pod = body
#pod
#pod a L<Text::Template> (possibly a plain text file) where items to be
#pod expanded are enclosed between double braces
#pod
#pod =end :list
#pod
#pod Each section is terminated by the header of the following section or by
#pod the end of the file. Example:
#pod
#pod    __[ NAME ]__
#pod    The Foo-Bar License
#pod    __URL__
#pod    http://www.example.com/foo-bar.txt
#pod    __[ META_NAME ]__
#pod    foo_bar_meta
#pod    __{ META2_NAME }__
#pod    foo_bar_meta2
#pod    __[ NOTICE ]__
#pod    Copyright (C) 2000-2002 by P.R. Evious
#pod    Copyright (C) {{$self->year}} by {{$self->holder}}.
#pod
#pod    This is free software, licensed under {{$self->name}}.
#pod
#pod    __[ LICENSE ]__
#pod                The Foo-Bar License
#pod
#pod    Well... this is only some sample text.  Verily... only sample text!!!
#pod
#pod    Yes, spanning more lines and more paragraphs.
#pod
#pod The different formats for specifying the section name in the example
#pod above are only examples, you're invited to use a consistent approach.
#pod
#pod =method new
#pod
#pod    my $slc = Software::License::Custom->new({filename => 'LEGAL'});
#pod
#pod Create a new object. Arguments are passed through an anonymous hash, the
#pod following keys are allowed:
#pod
#pod   filename - the file where the custom software license details are stored
#pod
#pod =cut

sub new {
   my ($class, $arg) = @_;

   my $filename = delete $arg->{filename};

   my $self = $class->SUPER::new($arg);

   $self->load_sections_from($filename) if defined $filename;

   return $self;
}

#pod =method load_sections_from
#pod
#pod    $slc->load_sections_from('MY-LEGAL-ASPECTS');
#pod
#pod Loads the different sections of the license from the provided filename.
#pod
#pod Returns the input object.
#pod
#pod =cut

sub load_sections_from {
   my ($self, $filename) = @_;

   # Sections are kept inside a hash
   $self->{'Software::License::Custom'}{section_for} = \my %section_for;

   my $current_section = '';
   open my $fh, '<', $filename or croak "open('$filename'): $!";

   while (<$fh>) {
      if (my ($section) = m{\A __ (.*) __ \n\z}mxs) {
         ($current_section = $section) =~ s/\W+//gmxs;
      }
      else {
         $section_for{$current_section} .= $_;
      }
   }
   close $fh;

   # strip last newline from all items
   s{\n\z}{}mxs for values %section_for;

   return $self;
}

#pod =method section_data
#pod
#pod    my $notice_template_reference = $slc->section_data('NOTICE');
#pod
#pod Returns a reference to a textual template that can be fed to
#pod L<Text::Template> (it could be simple text), according to what is
#pod currently loaded in the object.
#pod
#pod =cut

sub section_data {
   my ($self, $name) = @_;
   my $section_for = $self->{'Software::License::Custom'}{section_for} ||= {};
   return unless exists $section_for->{$name};
   return unless defined $section_for->{$name};
   return \$section_for->{$name};
}

#pod =head1 MORE METHODS
#pod
#pod The following methods, found in all software license classes, look up and
#pod render the template with the capitalized form of their name.  In other words,
#pod the C<license> method looks in the C<LICENSE> template.
#pod
#pod For now, the C<meta_name> and C<meta2_name> methods return C<custom> if called
#pod on the class.  This may become fatal in the future.
#pod
#pod =for :list
#pod * name
#pod * url
#pod * meta_name
#pod * meta2_name
#pod * license
#pod * notice
#pod * fulltext
#pod * version
#pod
#pod =cut

sub name       { shift->_fill_in('NAME') }
sub url        { shift->_fill_in('URL') }

sub meta_name  {
   my $self = shift;
   return 'custom' unless ref $self;
   return $self->_fill_in('META_NAME')
}

sub meta2_name {
  my $self = shift;
  return 'custom' unless ref $self;
  $self->_fill_in('META2_NAME')
}

sub license    { shift->_fill_in('LICENSE') }
sub notice     { shift->_fill_in('NOTICE') }

sub fulltext {
   my ($self) = @_;
   return join "\n", $self->notice, $self->license;
}

sub version {
   my ($self) = @_;
   return unless $self->section_data('VERSION');
   return $self->_fill_in('VERSION')
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Software::License::Custom - custom license handler

=head1 VERSION

version 0.103013

=head1 DESCRIPTION

This module extends L<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 L<Software::License> is used, e.g. L<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:

=over 4

=item header line

This is a line that begins and ends with two underscores C<__>. 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;

=item body

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

=back

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

=head1 METHODS

=head2 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 stored

=head2 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.

=head2 section_data

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

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

=head1 MORE METHODS

The following methods, found in all software license classes, look up and
render the template with the capitalized form of their name.  In other words,
the C<license> method looks in the C<LICENSE> template.

For now, the C<meta_name> and C<meta2_name> methods return C<custom> if called
on the class.  This may become fatal in the future.

=over 4

=item *

name

=item *

url

=item *

meta_name

=item *

meta2_name

=item *

license

=item *

notice

=item *

fulltext

=item *

version

=back

=head1 AUTHOR

Ricardo Signes <rjbs@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Ricardo Signes.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
March 03 2024 19:11:23
root / root
0755
AGPL_3.pm
34.534 KB
October 27 2017 15:45:28
root / root
0644
Apache_1_1.pm
3.252 KB
October 27 2017 15:45:28
root / root
0644
Apache_2_0.pm
11.887 KB
October 27 2017 15:45:28
root / root
0644
Artistic_1_0.pm
7.211 KB
October 27 2017 15:45:28
root / root
0644
Artistic_2_0.pm
9.485 KB
October 27 2017 15:45:28
root / root
0644
BSD.pm
2.179 KB
October 27 2017 15:45:28
root / root
0644
CC0_1_0.pm
9.047 KB
October 27 2017 15:45:28
root / root
0644
Custom.pm
8.609 KB
October 27 2017 15:45:28
root / root
0644
EUPL_1_1.pm
13.558 KB
October 27 2017 15:45:28
root / root
0644
EUPL_1_2.pm
14.313 KB
October 27 2017 15:45:28
root / root
0644
FreeBSD.pm
2.053 KB
October 27 2017 15:45:28
root / root
0644
GFDL_1_2.pm
21.155 KB
October 27 2017 15:45:28
root / root
0644
GFDL_1_3.pm
23.597 KB
October 27 2017 15:45:28
root / root
0644
GPL_1.pm
13.114 KB
October 27 2017 15:45:28
root / root
0644
GPL_2.pm
18.466 KB
October 27 2017 15:45:28
root / root
0644
GPL_3.pm
35.108 KB
October 27 2017 15:45:28
root / root
0644
LGPL_2_1.pm
24.762 KB
October 27 2017 15:45:28
root / root
0644
LGPL_3_0.pm
8.532 KB
October 27 2017 15:45:28
root / root
0644
MIT.pm
1.75 KB
October 27 2017 15:45:28
root / root
0644
Mozilla_1_0.pm
20.487 KB
October 27 2017 15:45:28
root / root
0644
Mozilla_1_1.pm
26.681 KB
October 27 2017 15:45:28
root / root
0644
Mozilla_2_0.pm
17.124 KB
October 27 2017 15:45:28
root / root
0644
None.pm
0.923 KB
October 27 2017 15:45:28
root / root
0644
OpenSSL.pm
3.924 KB
October 27 2017 15:45:28
root / root
0644
Perl_5.pm
1.734 KB
October 27 2017 15:45:28
root / root
0644
PostgreSQL.pm
1.727 KB
October 27 2017 15:45:28
root / root
0644
QPL_1_0.pm
5.25 KB
October 27 2017 15:45:28
root / root
0644
SSLeay.pm
3.84 KB
October 27 2017 15:45:28
root / root
0644
Sun.pm
14.976 KB
October 27 2017 15:45:28
root / root
0644
Zlib.pm
1.549 KB
October 27 2017 15:45:28
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF