File Coverage

blib/lib/Perl/Critic/PolicyListing.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition 2 2 100.0
subroutine 9 9 100.0
pod 2 2 100.0
total 42 42 100.0


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