File Coverage

blib/lib/POD/Credentials.pm
Criterion Covered Total %
statement 53 57 92.9
branch 11 18 61.1
condition 4 9 44.4
subroutine 12 12 100.0
pod 2 2 100.0
total 82 98 83.6


line stmt bran cond sub pod time code
1             package POD::Credentials;
2              
3 1     1   716 use warnings;
  1         2  
  1         33  
4 1     1   5 use strict;
  1         2  
  1         29  
5 1     1   13 use English qw( -no_match_vars);
  1         2  
  1         7  
6 1     1   1224 use version; our $VERSION = '0.04';
  1         2306  
  1         5  
7              
8             =head1 NAME
9              
10             POD::Credentials - POD credentials OO wrapper (see also, author, license, copyright)
11              
12             =head1 VERSION
13              
14             Version 0.04
15              
16             =head1 DESCRIPTION
17              
18             instance of this class is capable of setting up POD credentials, as
19             C and returning it as string
20              
21             =head1 SYNOPSIS
22              
23             use POD::Credentials;
24             my $cred = POD::Credentials->new({
25             author => 'Joe Doe',
26             license => ,
27             copyright =>
28             by author name with current year'>
29             });
30             print $cred->asString();
31              
32             ## it will automatically set B as the link to the name of the caller's package if defined and not C
33              
34             =head1 METHODS
35              
36             accessors/mutators are provided by L for each public field
37              
38             =head2 new()
39              
40             constructor, accepts single parameter - reference to hash where keys from the list:
41             C
42              
43             =head2 author()
44              
45             accessor/mutator for the C pod element
46              
47             =head2 copyright()
48              
49             accessor/mutator for the C pod element
50              
51             =head2 license()
52              
53             accessor/mutator for the C pod element
54              
55             =head2 year()
56              
57             accessor/mutator for the year used in C
58              
59             =head2 see_also()
60              
61             accessor/mutator for the C pod element
62              
63             =head2 end_module()
64              
65             if set then module will be finished with:
66              
67              
68             __END__
69            
70             1;
71              
72             and then credentials pod will be added
73              
74             =cut
75              
76 1     1   971 use POSIX qw(strftime);
  1         6254  
  1         8  
77 1     1   2176 use Class::Accessor::Fast;
  1         4107  
  1         11  
78 1     1   1009 use Class::Fields;
  1         11516  
  1         1451  
79 1     1   11 use Carp;
  1         2  
  1         66  
80 1     1   6 use base qw(Class::Accessor::Fast Class::Fields);
  1         2  
  1         124  
81 1     1   14472 use fields qw(author copyright license year see_also end_module);
  1         1982  
  1         10  
82             POD::Credentials->mk_accessors(POD::Credentials->show_fields('Public'));
83            
84             sub new {
85 2     2 1 1520 my ( $that, $param ) = @_;
86 2   33     18 my $class = ref($that) || $that;
87 2         9 my $self = fields::new($class);
88             # setting defaults
89 2         5998 $self->year(strftime "%Y", localtime(time));
90 2 50 66     21 if ($param && ref($param) ne 'HASH' ) {
91 0         0 croak("ONLY hash ref accepted as param and not: $param ");
92             }
93             ## initializing
94 2 50 33     3 map { $self->{$_} = $param->{$_} if $_ && $self->can($_)} keys %{$param}; ###
  1         11  
  2         6  
95            
96 2         12 return $self;
97             }
98            
99             =head2 asString()
100              
101             returns string repsresentation, no arguments accepted
102              
103             =cut
104              
105             sub asString {
106 2     2 1 464 my ($self) = @_;
107 2 100       6 my $string = $self->end_module?"\n\n1;\n\n__END__\n\n":"\n";
108 2         14 my($see_also, $author, $copyright, $license) = ($self->see_also, $self->author,$self->copyright,$self->license);
109 2 100       19 map { s/^\s+// if defined $_ }($see_also, $author, $copyright, $license);
  8         27  
110 2 50       5 if($see_also) {
111 0         0 $string .= "\n=head1 SEE ALSO\n\n$see_also\n";
112             }
113 2 50       7 if($author) {
114 2         6 $string .= "\n=head1 AUTHOR\n\n$author\n";
115             }
116 2 50       8 if($copyright) {
    50          
117 0         0 $string .= "\n=head1 COPYRIGHT\n\n$copyright\n";
118             } elsif($author) {
119 2         14 $string .= "\n=head1 COPYRIGHT\n\nCopyright (c) " . $self->year . ", $author. All rights reserved.\n";
120             }
121 2 50       15 if($license) {
122 0         0 $string .= "\n=head1 LICENSE\n\n$license\n";
123             } else {
124 2         5 $string .= "\n=head1 LICENSE\n\nThis program is free software.\nYou can redistribute it and/or modify it under the same terms as Perl itself.\n";
125             }
126 2         2 $string .= "\n=cut\n\n";
127 2         7 return $string;
128             }
129              
130             =head1 AUTHOR
131              
132             Maxim Grigoriev, maxim_at_fnal_gov
133              
134             =head1 BUGS
135              
136             Please report any bugs or feature requests to C, or through
137             the web interface at L.
138             I will be notified, and then you'll
139             automatically be notified of progress on your bug as I make changes.
140            
141              
142             =head1 SUPPORT
143              
144             You can find documentation for this module with the perldoc command.
145              
146             perldoc POD::Credentials
147              
148              
149             You can also look for information at:
150              
151             =over
152              
153             =item * RT: CPAN's request tracker
154              
155             L
156              
157             =item * AnnoCPAN: Annotated CPAN documentation
158              
159             L
160              
161             =item * CPAN Ratings
162              
163             L
164              
165             =item * Search CPAN
166              
167             L
168              
169             =back
170              
171             =head1 COPYRIGHT & LICENSE
172              
173             Copyright 2008-2009 Fermi Research Alliance (FRA).
174              
175             This program is free software; you can redistribute it and/or modify it
176             under the Fermitools license, see L
177              
178              
179             =cut
180              
181             1; # End of POD::Credentials