File Coverage

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