| 1 | # | ||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||
| 3 | # | ||||||||||
| 4 | |||||||||||
| 5 | package Rex::Batch; | ||||||||||
| 6 | |||||||||||
| 7 | 16 | ▶ | use v5.14.4; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 16 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 16 | our $VERSION = '1.16.1'; # VERSION | |||||||||
| 11 | |||||||||||
| 12 | 16 | ▶ | use Rex::Logger; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 16 | ▶ | use Rex::TaskList; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 16 | ▶ | use vars qw(%batchs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | sub create_batch { | ||||||||
|
Subroutine
create_batch: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 18 | 1 | my $class = shift; | |||||||||
| 19 | 1 | my $batch_name = shift; | |||||||||
| 20 | 1 | my $batch_desc = pop; | |||||||||
| 21 | 1 | my @task_names = @_; | |||||||||
| 22 | 1 | my $task_list = Rex::TaskList->create; | |||||||||
| 23 | |||||||||||
| 24 | 1 | for my $task_name (@task_names) { | |||||||||
| 25 | 2 | ▶ | die "ERROR: no task: $task_name" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | unless $task_list->is_task($task_name); | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | $batchs{$batch_name} = { | |||||||||
| 30 | desc => $batch_desc, | ||||||||||
| 31 | task_names => \@task_names | ||||||||||
| 32 | }; | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub get_batch { | ||||||||
|
Subroutine
get_batch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 36 | 1 | my $class = shift; | |||||||||
| 37 | 1 | my $batch_name = shift; | |||||||||
| 38 | |||||||||||
| 39 | 1 | return @{ $batchs{$batch_name}->{'task_names'} }; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub get_desc { | ||||||||
|
Subroutine
get_desc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 43 | 0 | my $class = shift; | |||||||||
| 44 | 0 | my $batch_name = shift; | |||||||||
| 45 | |||||||||||
| 46 | 0 | return $batchs{$batch_name}->{'desc'}; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub get_batchs { | ||||||||
|
Subroutine
get_batchs: called CC=1 SCAR=0.4
Pod
undocumented
| |||||||||||
| 50 | 1 | my $class = shift; | |||||||||
| 51 | 0 | my @a = sort { $a cmp $b } keys %batchs; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub is_batch { | ||||||||
|
Subroutine
is_batch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 55 | 0 | my $class = shift; | |||||||||
| 56 | 0 | my $batch_name = shift; | |||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | if ( defined $batchs{$batch_name} ) { return 1; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | return 0; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 16 | 1; | |||||||||