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