File Coverage

blib/lib/Perl/Critic/ThemeListing.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition 1 2 50.0
subroutine 7 7 100.0
pod 2 2 100.0
total 35 36 97.2


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