File Coverage

lib/Rex/Batch.pm
Criterion Covered Total %
statement 28 37 75.6
branch 1 4 25.0
condition n/a
subroutine 8 10 80.0
pod 0 5 0.0
total 37 56 66.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Batch;
6              
7 16     16   226 use v5.12.5;
  16         53  
8 16     16   92 use warnings;
  16         30  
  16         978  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12 16     16   103 use Rex::Logger;
  16         30  
  16         81  
13 16     16   355 use Rex::TaskList;
  16         31  
  16         190  
14              
15 16     16   572 use vars qw(%batchs);
  16         29  
  16         7906  
16              
17             sub create_batch {
18 1     1 0 2 my $class = shift;
19 1         2 my $batch_name = shift;
20 1         2 my $batch_desc = pop;
21 1         4 my @task_names = @_;
22 1         3 my $task_list = Rex::TaskList->create;
23              
24 1         13 for my $task_name (@task_names) {
25 2 50       8 die "ERROR: no task: $task_name"
26             unless $task_list->is_task($task_name);
27             }
28              
29 1         6 $batchs{$batch_name} = {
30             desc => $batch_desc,
31             task_names => \@task_names
32             };
33             }
34              
35             sub get_batch {
36 1     1 0 16 my $class = shift;
37 1         2 my $batch_name = shift;
38              
39 1         13 return @{ $batchs{$batch_name}->{'task_names'} };
  1         8  
40             }
41              
42             sub get_desc {
43 0     0 0 0 my $class = shift;
44 0         0 my $batch_name = shift;
45              
46 0         0 return $batchs{$batch_name}->{'desc'};
47             }
48              
49             sub get_batchs {
50 1     1 0 5 my $class = shift;
51 1         9 my @a = sort { $a cmp $b } keys %batchs;
  0            
52             }
53              
54             sub is_batch {
55 0     0 0   my $class = shift;
56 0           my $batch_name = shift;
57              
58 0 0         if ( defined $batchs{$batch_name} ) { return 1; }
  0            
59 0           return 0;
60             }
61              
62             1;