| 1 | package Bread::Board::Dumper; | ||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||||||||||||
| 3 | # ABSTRACT: Pretty printer for visualizing the layout of your Bread::Board | ||||||||||||||||||||||
| 4 | 1 | $Bread::Board::Dumper::VERSION = '0.37'; | |||||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 0 | ▶ | sub dump { | ||||||||||||||||||||
|
Subroutine
dump: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||
| 8 | 0 | my ($self, $thing, $indent) = @_; | |||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 0 | ▶ | $indent = defined $indent ? $indent . ' ' : ''; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | 0 | my $output = ''; | |||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 0 | ▶ | if ($thing->isa('Bread::Board::Dependency')) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 15 | 0 | ▶ | $output .= join('', $indent, "depends_on: ", $thing->service_path || $thing->service->name, "\n"); | ||||||||||||||||||||
|
Condition0%0/3
$thing->service_path || $thing->service->name
MC/DC0%0/2
$thing->service_path || $thing->service->name
$thing->service_path
$thing->service->name
Truth table0%0/3
A || B
A= $thing->service_pathB= $thing->service->name
| |||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||
| 17 | elsif ($thing->does('Bread::Board::Service')) { | ||||||||||||||||||||||
| 18 | 0 | $output .= join('', $indent, "service: ", $thing->name, "\n" ); | |||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 0 | ▶ | if ($thing->does('Bread::Board::Service::WithDependencies')) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 21 | 0 | my $deps = $thing->dependencies; | |||||||||||||||||||||
| 22 | 0 | for my $key (sort keys %{$deps}) { | |||||||||||||||||||||
| 23 | 0 | $output .= $self->dump($deps->{$key}, $indent); | |||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||
| 27 | elsif ($thing->isa('Bread::Board::Container')) { | ||||||||||||||||||||||
| 28 | 0 | $output = join('', $indent, "container: ", $thing->name, "\n" ); | |||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 0 | $output .= $self->_dump_container($thing, $indent); | |||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||
| 32 | elsif ($thing->isa('Bread::Board::Container::Parameterized')) { | ||||||||||||||||||||||
| 33 | 0 | my $params = join ', ', @{ $thing->allowed_parameter_names }; | |||||||||||||||||||||
| 34 | 0 | $output = join('', $indent, "container: ", $thing->name, " [$params]\n" ); | |||||||||||||||||||||
| 35 | 0 | $output .= $self->_dump_container($thing, $indent); | |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | |||||||||||||||||||||||
| 38 | 0 | return $output; | |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | 0 | ▶ | sub _dump_container { | ||||||||||||||||||||
|
Subroutine
_dump_container: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 42 | 0 | my ($self, $c, $indent) = @_; | |||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 0 | my $output = ''; | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | 0 | my $subs = $c->sub_containers; | |||||||||||||||||||||
| 47 | 0 | for my $key (sort keys %{$subs}) { | |||||||||||||||||||||
| 48 | 0 | $output .= $self->dump($subs->{$key}, $indent); | |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | 0 | my $services = $c->services; | |||||||||||||||||||||
| 52 | 0 | for my $key (sort keys %{$services}) { | |||||||||||||||||||||
| 53 | 0 | $output .= $self->dump($services->{$key}, $indent); | |||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||
| 55 | |||||||||||||||||||||||
| 56 | 0 | return $output; | |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||
| 60 | |||||||||||||||||||||||
| 61 | 1 | ▶ | no Moose; 1; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 62 | |||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||