• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RexOps / Rex / 1361190055

pending completion
1361190055

Pull #1513

github

GitHub
Merge 518cc26de into 9663d7f15
Pull Request #1513: get cmdb returns hash ref and not hash

6775 of 16627 relevant lines covered (40.75%)

95.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
/lib/Rex/TaskList.pm
1
#
2
# (c) Jan Gehring <jan.gehring@gmail.com>
3
#
4
# vim: set ts=2 sw=2 tw=0:
5
# vim: set expandtab:
6

7
package Rex::TaskList;
8

9
use 5.010001;
134✔
10
use strict;
134✔
11
use warnings;
107✔
12

13
our $VERSION = '9999.99.99_99'; # VERSION
14

15
use Data::Dumper;
107✔
16
use Rex::Config;
107✔
17
use Rex::Logger;
107✔
18
use Rex::Interface::Executor;
107✔
19

20
use vars qw(%tasks);
107✔
21

22
# will be set from Rex::Transaction::transaction()
23
our $task_list = {};
24

25
sub create {
26
  my ($class) = @_;
935✔
27

28
  # create only one object
29
  if ( ref($task_list) =~ m/^Rex::TaskList::/ ) {
935✔
30
    Rex::Logger::debug(
844✔
31
      "Returning existing distribution class of type: " . ref($task_list) );
32
    return $task_list;
844✔
33
  }
34

35
  my $type = Rex::Config->get_distributor;
91✔
36
  Rex::Logger::debug("Creating new distribution class of type: $type");
91✔
37

38
  my $class_name = "Rex::TaskList::$type";
91✔
39

40
  eval "use $class_name";
64✔
41
  if ($@) {
91✔
42
    die("TaskList module not found: $@");
×
43
  }
44

45
  $task_list = $class_name->new;
91✔
46

47
  Rex::Logger::debug(
91✔
48
    "new distribution class of type " . ref($task_list) . " created." );
49

50
  return $task_list;
91✔
51
}
52

53
sub run {
54
  my ( $class, $task_name, %option ) = @_;
230✔
55

56
  $class = ref $class ? $class : $class->create;
230✔
57

58
  my $task = ref $task_name ? $task_name : $class->get_task($task_name);
230✔
59

60
  my $old_task = $class->{__current_task__};
230✔
61
  $class->{__current_task__} = $task;
230✔
62

63
  $_->($task) for @{ $task->{before_task_start} };
230✔
64
  $class->run( $task, %option );
230✔
65
  $_->($task) for @{ $task->{after_task_finished} };
194✔
66

67
  $class->{__current_task__} = $old_task;
194✔
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2024 Coveralls, Inc