File Coverage

blib/lib/Perl/Critic/ThemeListing.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition 1 2 50.0
subroutine 8 8 100.0
pod 2 2 100.0
total 39 40 97.5


line stmt bran cond sub pod time code
1             package Perl::Critic::ThemeListing;
2              
3 1     1   525 use 5.010001;
  1         4  
4 1     1   8 use strict;
  1         2  
  1         25  
5 1     1   6 use warnings;
  1         2  
  1         32  
6              
7 1     1   6 use English qw<-no_match_vars>;
  1         2  
  1         6  
8              
9 1     1   343 use Perl::Critic::Utils qw< hashify >;
  1         3  
  1         52  
10              
11 1     1   7 use overload ( q<""> => 'to_string' );
  1         2  
  1         9  
12              
13             our $VERSION = '1.146';
14              
15             #-----------------------------------------------------------------------------
16              
17             sub new {
18 1     1 1 28 my ($class, %args) = @_;
19              
20 1         3 my $self = bless {}, $class;
21              
22 1   50     43 $self->{_policies} = $args{-policies} || [];
23              
24 1         5 return $self;
25             }
26              
27             #-----------------------------------------------------------------------------
28              
29             sub to_string {
30 1     1 1 11 my ($self) = @_;
31              
32 1         4 my %themes;
33 1         2 foreach my $policy ( @{ $self->{_policies} } ) {
  1         4  
34 145         1121 my @themes = $policy->get_themes();
35 145         354 @themes{ @themes } = @themes;
36             }
37              
38 1         21 return join ("\n", sort keys %themes) . "\n";
39             }
40              
41             #-----------------------------------------------------------------------------
42              
43             1;
44              
45             __END__
46              
47             =pod
48              
49             =head1 NAME
50              
51             Perl::Critic::ThemeListing - List the themes of the installed Policies.
52              
53              
54             =head1 DESCRIPTION
55              
56             This is a helper class that gathers the themes of the installed
57             Policies. There are no user-serviceable parts here.
58              
59              
60             =head1 INTERFACE SUPPORT
61              
62             This is considered to be a non-public class. Its interface is subject
63             to change without notice.
64              
65              
66             =head1 CONSTRUCTOR
67              
68             =over
69              
70             =item C<< new( -policies => \@POLICY_OBJECTS ) >>
71              
72             Returns a reference to a new C<Perl::Critic::ThemeListing> object.
73              
74              
75             =back
76              
77              
78             =head1 METHODS
79              
80             =over
81              
82              
83             =item to_string()
84              
85             Returns a string representation of this C<ThemeListing>. See
86             L<"OVERLOADS"> for more information.
87              
88              
89             =back
90              
91              
92             =head1 OVERLOADS
93              
94              
95             When a L<Perl::Critic::ThemeListing|Perl::Critic::ThemeListing> is
96             evaluated in string context, it produces a one-line summary of the
97             default severity, policy name, and default themes for each
98             L<Perl::Critic::Policy|Perl::Critic::Policy> object that was given to
99             the constructor of this C<ThemeListing>.
100              
101              
102             =head1 AUTHOR
103              
104             Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
105              
106              
107             =head1 COPYRIGHT
108              
109             Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
110              
111             This program is free software; you can redistribute it and/or modify
112             it under the same terms as Perl itself. The full text of this license
113             can be found in the LICENSE file included with this module.
114              
115             =cut
116              
117             # Local Variables:
118             # mode: cperl
119             # cperl-indent-level: 4
120             # fill-column: 78
121             # indent-tabs-mode: nil
122             # c-indentation-style: bsd
123             # End:
124             # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :