File Coverage

blib/lib/Perl/ToPerl6/TransformerListing.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::ToPerl6::TransformerListing;
2              
3 2     2   1453 use 5.006001;
  2         5  
4 2     2   8 use strict;
  2         4  
  2         48  
5 2     2   18 use warnings;
  2         3  
  2         68  
6              
7 2     2   9 use English qw(-no_match_vars);
  2         3  
  2         13  
8              
9 2     2   774 use Perl::ToPerl6::Transformer qw();
  2         3  
  2         48  
10              
11 2     2   7 use overload ( q<""> => 'to_string' );
  2         3  
  2         16  
12              
13             our $VERSION = '0.03';
14              
15             #-----------------------------------------------------------------------------
16              
17             sub new {
18 2     2 1 928 my ($class, %args) = @_;
19              
20 2         7 my $self = bless {}, $class;
21              
22 2   100     12 my $transformers = $args{-transformers} || [];
23 2         6 $self->{_transformers} = [ sort _by_type @{ $transformers } ];
  2         39  
24              
25 2         10 return $self;
26             }
27              
28             #-----------------------------------------------------------------------------
29              
30             sub to_string {
31 1     1 1 627 my ($self) = @_;
32              
33 1         6 Perl::ToPerl6::Transformer::set_format( "%s %p [%t]\n" );
34              
35 1         2 return join q{}, map { "$_" } @{ $self->{_transformers} };
  38         1121  
  1         5  
36             }
37              
38             #-----------------------------------------------------------------------------
39              
40 37     37   120 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::ToPerl6::TransformerListing - Display minimal information about Transformers.
51              
52              
53             =head1 DESCRIPTION
54              
55             This is a helper class that formats a set of Transformer 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( -transformers => \@POLICY_OBJECTS ) >>
70              
71             Returns a reference to a new C<Perl::ToPerl6::TransformerListing> 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<TransformerListing>. See
84             L<"OVERLOADS"> for more information.
85              
86              
87             =back
88              
89              
90             =head1 OVERLOADS
91              
92             When a L<Perl::ToPerl6::TransformerListing|Perl::ToPerl6::TransformerListing> is
93             evaluated in string context, it produces a one-line summary of the
94             default severity, transformer name, and default themes for each
95             L<Perl::ToPerl6::Transformer|Perl::ToPerl6::Transformer> object that was given to
96             the constructor of this C<TransformerListing>.
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 :