File Coverage

blib/lib/OTRS/OPM/Maker/Utils/OTRS3.pm
Criterion Covered Total %
statement 13 14 92.8
branch 2 4 50.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 2 2 100.0
total 23 26 88.4


line stmt bran cond sub pod time code
1             package OTRS::OPM::Maker::Utils::OTRS3;
2              
3             # ABSTRACT: Provide helper functions for OTRS <= 3
4              
5 30     30   254 use strict;
  30         81  
  30         1069  
6 30     30   220 use warnings;
  30         79  
  30         6183  
7              
8             our $VERSION = 1.44;
9              
10             sub packagesetup {
11 8     8 1 45 my ($class, $type, $version, $function, $runtype, $package) = @_;
12              
13 8 50       28 $version = $version ? ' Version="' . $version . '"' : '';
14              
15 8   100     75 $runtype //= 'post';
16              
17 8 50       51 if ( $package ) {
18 0         0 $package = sprintf "'%s'", $package;
19             }
20             else {
21 8         17 $package = '$Param{Structure}->{Name}->{Content}';
22             }
23              
24 8         85 return qq~ <$type Type="$runtype"$version>
25             # define function name
26             my \$FunctionName = '$function';
27              
28             # create the package name
29             my \$CodeModule = 'var::packagesetup::' . $package;
30              
31             # load the module
32             if ( \$Self->{MainObject}->Require(\$CodeModule) ) {
33              
34             # create new instance
35             my \$CodeObject = \$CodeModule->new( %{\$Self} );
36              
37             if (\$CodeObject) {
38              
39             # start methode
40             if ( !\$CodeObject->\$FunctionName(%{\$Self}) ) {
41             \$Self->{LogObject}->Log(
42             Priority => 'error',
43             Message => "Could not call method \$FunctionName() on \$CodeModule.pm."
44             );
45             }
46             }
47              
48             # error handling
49             else {
50             \$Self->{LogObject}->Log(
51             Priority => 'error',
52             Message => "Could not call method new() on \$CodeModule.pm."
53             );
54             }
55             }
56              
57             ]]>~;
58             }
59              
60             sub filecheck {
61 21     21 1 58 return 1;
62             }
63              
64             1;
65              
66             __END__