Labyrinth/DIUtils.pm

filter: Statementstmt 56.2% 18 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 46.3% 25 / 54 CC 6 SCAR 26.3
CC
6
Cov
42%
new
30.0
Tool
6.0
BEGIN
1.0
CRAP 13.9
« Labyrinth/Variables.pm ↑ Summary Labyrinth/MLUtils.pm »
1 package Labyrinth::DIUtils;
2  
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 $VERSION = '5.32';
8  
9 =head1 NAME
10  
11 Labyrinth::DIUtils - Digital Image Utilities for Labyrinth
12  
13 =head1 SYNOPSIS
14  
15 use Labyrinth::DIUtils;
16  
17 Labyrinth::DIUtils::Tool('GD'); # switch to GD
18 Labyrinth::DIUtils::Tool('ImageMagick'); # switch to ImageMagick
19 my $tool = Labyrinth::DIUtils::Tool; # returns current tool setting
20  
21 my $hook = Labyrinth::DIUtils->new($file);
22 my $hook = $hook->rotate($degrees); # 0 - 360
23 my $hook = $hook->reduce($xmax,$ymax);
24 my $hook = $hook->thumb($thumbnail,$square);
25  
26 =head1 DESCRIPTION
27  
28 Handles the driver software for image manipulation;
29  
30 =cut
31  
32 #############################################################################
33 #Modules/External Subroutines #
34 #############################################################################
35  
36 12 ▶use Labyrinth::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 12 ▶use Labyrinth::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 #############################################################################
40 #Variables
41 #############################################################################
42  
43 12 my $tool = 'Base'; # defaults to no processing
44  
45 #############################################################################
46 #Subroutines
47 #############################################################################
48  
49 =head1 FUNCTIONS
50  
51 =over 4
52  
53 =item Tool
54  
55 Configuration function to determine which image package to load.
56  
57 =back
58  
59 =cut
60  
61 0 ▶sub Tool {
Subroutine Tool: not called CC=2 SCAR=17.9
Pod documented
62 0 ▶ @_ ? $tool = shift : $tool;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
63 }
64  
65 =head2 Contructor
66  
67 =over 4
68  
69 =item new()
70  
71 Constructs the interface between Labyrinth and the image package.
72  
73 =back
74  
75 =cut
76  
77 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
78 0 my $self = shift;
79 0 my $file = shift;
80 0 my $hook;
81  
82 0 ▶ if(!defined $file) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $file) { } 0 0 0
elsif (not defined $tool) { } 0 0 0
83 0 Croak("No image file specified to $self->new().");
84 } elsif(!defined $tool) {
85 0 Croak("No image tool specified for $self.");
86 } else {
87 0 my $class = "Labyrinth::DIUtils::$tool";
88 0 eval {
89 0 eval "require $class";
90 0 $hook = $class->new($file);
91 };
92 0 ▶ if($@ || !$hook) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $hook) 0 0 0
Condition0%0/3
$@ or not $hook
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not $hook
$@ not $hook
Truth table0%0/3
A or not(B)
A= $@B= not $hook
ABresult
1X1
011
000
93 0 Croak("Invalid image tool [$tool] specified for $self. [$@]");
94 }
95 }
96  
97 0 return $hook; # a cheat, but does the job :)
98 }
99  
100 12 1;
101  
102 __END__
« Labyrinth/Variables.pm ↑ Summary Labyrinth/MLUtils.pm »