File Coverage

blib/lib/Perl/Critic/ThemeListing.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition 1 2 50.0
subroutine 6 6 100.0
pod 2 2 100.0
total 31 32 96.8


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