File Coverage

blib/lib/Alien/FreeImage.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 33 35 94.2


line stmt bran cond sub pod time code
1             package Alien::FreeImage;
2            
3 2     2   36488 use warnings;
  2         7  
  2         86  
4 2     2   12 use strict;
  2         3  
  2         115  
5            
6 2     2   795 use Alien::FreeImage::ConfigData;
  2         7  
  2         75  
7 2     2   1002 use File::ShareDir qw(dist_dir);
  2         11321  
  2         162  
8 2     2   1004 use File::Spec::Functions qw(catdir);
  2         1345  
  2         390  
9            
10             =head1 NAME
11            
12             Alien::FreeImage - Building freeimage library L
13            
14             =cut
15            
16             our $VERSION = '1.000_3';
17            
18             =head1 SYNOPSIS
19            
20             This module is not a perl binding for I library; it is just a helper module that makes dev files (*.h, *.a)
21             available for linking by other modules.
22            
23             Alien::FreeImage installation comprise of these steps:
24            
25             =over
26            
27             =item * Build B static library (*.a) from source codes (that are bundled with this module)
28            
29             =item * Install dev files (*.h, *.a) into I directory of Alien::FreeImage distribution
30            
31             =back
32            
33             Later on you can use Alien::FreeImage in your module that needs to link with I like this:
34            
35             # Sample Makefile.PL
36             use ExtUtils::MakeMaker;
37             use Alien::FreeImage;
38            
39             WriteMakefile(
40             NAME => 'Any::FreeImage::Module',
41             VERSION_FROM => 'lib/Any/FreeImage/Module.pm',
42             LIBS => Alien::FreeImage->config('LIBS'),
43             INC => Alien::FreeImage->config('INC'),
44             # + additional params
45             );
46            
47             =head1 METHODS
48            
49             =head2 config()
50            
51             This function is the main public interface to this module.
52            
53             Alien::FreeImage->config('LIBS');
54            
55             Returns a string like: '-L/path/to/freeimage/dir -lfreeimage'
56            
57             Alien::FreeImage->config('INC');
58            
59             Returns a string like: '-I/path/to/freeimage/dir'
60            
61             Alien::FreeImage->config('PREFIX');
62            
63             Returns a string like: '/path/to/freeimage/dir'
64            
65             =head1 LICENSE
66            
67             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
68            
69             =head1 COPYRIGHT
70            
71             2014+ KMX Ekmx@cpan.orgE
72            
73             =cut
74            
75             sub config
76             {
77 8     8 1 660 my ($package, $param) = @_;
78 8 50       37 return unless ($param =~ /[a-z0-9_]*/i);
79 8         28 my $subdir = Alien::FreeImage::ConfigData->config('share_subdir');
80 8         24 my $share_dir = dist_dir('Alien-FreeImage');
81 8         587 my $real_prefix = catdir($share_dir, $subdir);
82 8         24 my $val = Alien::FreeImage::ConfigData->config('config')->{$param};
83 8 50       23 return unless $val;
84 8         30 $val =~ s/\@PrEfIx\@/$real_prefix/g; # handle @PrEfIx@ replacement
85 8         66 return $val;
86             }
87            
88             1;