File Coverage

blib/lib/Alien/bz2.pm
Criterion Covered Total %
statement 21 53 39.6
branch 0 18 0.0
condition n/a
subroutine 7 15 46.6
pod 5 6 83.3
total 33 92 35.8


line stmt bran cond sub pod time code
1             package Alien::bz2;
2              
3 3     3   38083 use strict;
  3         8  
  3         125  
4 3     3   16 use warnings;
  3         5  
  3         97  
5 3     3   1732 use File::ShareDir ();
  3         19222  
  3         87  
6 3     3   32 use File::Spec;
  3         7  
  3         81  
7 3     3   1590 use Alien::bz2::ConfigData;
  3         8  
  3         135  
8 3     3   17 use constant _share_dir => File::ShareDir::dist_dir('Alien-bz2');
  3         20  
  3         12  
9 3     3   551 use constant _alien_bz2012 => 1;
  3         4  
  3         1607  
10              
11             # ABSTRACT: Build and make available bz2
12             our $VERSION = '0.15'; # VERSION
13              
14             my $cf = 'Alien::bz2::ConfigData';
15              
16             sub _catfile {
17 0     0     my $path = File::Spec->catfile(@_);
18 0 0         $path =~ s{\\}{/}g if $^O eq 'MSWin32';
19 0           $path;
20             }
21              
22             sub _catdir {
23 0     0     my $path = File::Spec->catdir(@_);
24 0 0         $path =~ s{\\}{/}g if $^O eq 'MSWin32';
25 0           $path;
26             }
27              
28              
29             sub new
30             {
31 0     0 0   my($class) = @_;
32 0           bless {}, $class;
33             }
34              
35              
36             sub cflags
37             {
38 0     0 1   my($class) = @_;
39 0           my @cflags = @{ $cf->config("cflags") };
  0            
40 0 0         unshift @cflags, '-I' . _catdir(_share_dir, 'bz2012', 'include' )
41             if $class->install_type eq 'share';
42 0 0         wantarray ? @cflags : "@cflags";
43             }
44              
45              
46             sub libs
47             {
48 0     0 1   my($class) = @_;
49 0           my @libs = @{ $cf->config("libs") };
  0            
50 0 0         if($class->install_type eq 'share')
51             {
52 0 0         if($cf->config('msvc'))
53             {
54 0           unshift @libs, '/libpath:' . _catdir(_share_dir, 'bz2012', 'lib');
55             }
56             else
57             {
58 0           unshift @libs, '-L' . _catdir(_share_dir, 'bz2012', 'lib');
59             }
60             }
61 0 0         wantarray ? @libs : "@libs";
62             }
63              
64              
65             sub dlls
66             {
67 0     0 1   my($class) = @_;
68 0           my @list;
69 0 0         if($class->install_type eq 'system')
70             {
71 0           require Alien::bz2::Installer;
72 0           @list = Alien::bz2::Installer->system_install( type => 'ffi', alien => 0 )->dlls;
73             }
74             else
75             {
76 0           @list = map { _catfile(_share_dir, 'bz2012', 'dll', $_) }
  0            
77 0           @{ $cf->config("dlls") };
78             }
79 0 0         wantarray ? @list : $list[0];
80             }
81              
82              
83             sub version
84             {
85 0     0 1   $cf->config("version");
86             }
87              
88              
89             sub install_type
90             {
91 0     0 1   $cf->config("install_type");
92             }
93              
94              
95             1;
96              
97             __END__