File Coverage

blib/lib/Moonshine/Bootstrap/Component/Progress.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 3 3 100.0
pod n/a
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::Progress;
2              
3 5     5   231401 use Moonshine::Magic;
  5         157040  
  5         48  
4              
5 5     5   3319 use Params::Validate qw/HASHREF ARRAYREF/;
  5         17  
  5         508  
6              
7             extends (
8             'Moonshine::Bootstrap::Component',
9             'Moonshine::Bootstrap::Component::ProgressBar',
10             );
11              
12             has(
13             progress_spec => sub {
14             {
15             tag => { default => 'div' },
16             class_base => { default => 'progress' },
17             bar => { type => HASHREF, optional => 1},
18             stacked => { type => ARRAYREF, default => [ ]},
19             };
20             }
21             );
22              
23             sub progress {
24 7     7   49673 my ($self) = shift;
25              
26 7   100     71 my ( $base_args, $build_args ) = $self->validate_build(
27             {
28             params => $_[0] // {},
29             spec => $self->progress_spec,
30             }
31             );
32              
33 7         132 my $base_element = Moonshine::Element->new($base_args);
34            
35 7 100       17765 if ( my $bar = $build_args->{bar} ) {
36 2         37 $base_element->add_child( $self->progress_bar($bar) );
37             }
38              
39 7         71 for ( @{ $build_args->{stacked} } ) {
  7         30  
40 9         299 $base_element->add_child( $self->progress_bar($_) );
41             }
42              
43 7         142 return $base_element;
44             }
45              
46             1;
47              
48             __END__