File Coverage

blib/lib/CPAN/Flatten/Distribution/Emitter.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 6 0.0
condition n/a
subroutine 3 7 42.8
pod 0 3 0.0
total 12 40 30.0


line stmt bran cond sub pod time code
1             package CPAN::Flatten::Distribution::Emitter;
2 1     1   3 use strict;
  1         1  
  1         26  
3 1     1   4 use warnings;
  1         0  
  1         28  
4              
5 1     1   3 use constant STOP => -1;
  1         1  
  1         200  
6              
7             sub new {
8 0     0 0   my ($class, %opt) = @_;
9 0           bless {%opt}, $class;
10             }
11              
12             sub print : method {
13 0     0 0   my ($self, $indent, $message) = @_;
14 0           my $fh = $self->{fh};
15 0           print {$fh} " " x $indent, $message, "\n";
  0            
16             }
17              
18             sub emit {
19 0     0 0   my ($self, $distribution, $fh) = @_;
20 0 0         $self = $self->new(fh => $fh) unless ref $self;
21              
22             $distribution->walk_down(sub {
23 0     0     my ($dist, $depth) = @_;
24 0 0         return if $dist->is_root;
25 0 0         return if $dist->is_dummy;
26 0           my @children = $dist->children;
27 0           $self->print(0, $dist->distfile);
28 0           $self->print(1, $_->distfile) for @children;
29 0           });
30             }
31              
32             1;