blib/lib/Object/HashBase/Inline.pm

filter: Statementstmt 100% 60 / 60 Branchbran 76.6% 23 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 91.7% 89 / 97 CC 17 SCAR 26.1
CC
17
Cov
92%
inline
17.3
BEGIN
1.0
BEGIN
1.0
CRAP 13.6
« blib/lib/Object/HashBase.pm ↑ Summary blib/script/hashbase_inc.pl »
1 package Object::HashBase::Inline;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.017';
6  
7 1 ▶BEGIN { $Object::HashBase::Test::NO_RUN = 1 }
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Object::HashBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Object::HashBase::Test;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 my $hb_file = $INC{'Object/HashBase.pm'};
12 1 my $t_file = $INC{'Object/HashBase/Test.pm'};
13  
14 sub inline {
15 1 ▶ my ($prefix, $version) = @_;
Subroutine inline: called CC=17 SCAR=28.5
Pod undocumented
16 1 ▶ $version = $VERSION unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 1 1
17  
18 1 my $path = $prefix;
19 1 $path =~ s{::}{/}g;
20 1 $path = "lib/$path";
21 1 my $partial = '';
22  
23 1 for my $part (split /\//, "$path") {
24 3 $partial = join '/', grep { $_ } $partial, $part;
25 3 ▶ mkdir($partial) unless -d $partial;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $partial 3 0 3
26 }
27  
28 1 $path .= "/HashBase.pm";
29  
30 1 ▶ mkdir('t') unless -d 't';
Branch: 1 branch
BranchTrueFalseTotal
unless -d "t" 1 0 1
31  
32 1 ▶ open(my $hbf, '>', $path) or die "Could not create '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $hbf, ">", $path or die "Could not create '${path}': $!" 0 1 1
33 1 ▶ open(my $tf, '>', 't/HashBase.t') or die "Could not create 't/HashBase.t': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $tf, ">", "t/HashBase.t" or die "Could not create 't/HashBase.t': $!" 0 1 1
34  
35 1 ▶ open(my $hin, '<', $hb_file) or die "Could not open '$hb_file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $hin, "<", $hb_file or die "Could not open '${hb_file}': $!" 0 1 1
36 1 ▶ open(my $tin, '<', $t_file) or die "Could not open '$t_file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $tin, "<", $t_file or die "Could not open '${t_file}': $!" 0 1 1
37  
38  
39 1 print $hbf <<" EOT";
40 package $prefix\::HashBase;
41 use strict;
42 use warnings;
43  
44 our \$VERSION = '$version';
45  
46 #################################################################
47 # #
48 # This is a generated file! Do not modify this file directly! #
49 # Use hashbase_inc.pl script to regenerate this file. #
50 # The script is part of the Object::HashBase distribution. #
51 # Note: You can modify the version number above this comment #
52 # if needed, that is fine. #
53 # #
54 #################################################################
55  
56 {
57 no warnings 'once';
58 \$$prefix\::HashBase::HB_VERSION = '$Object::HashBase::VERSION';
59 \*$prefix\::HashBase::ATTR_SUBS = \\\%Object::HashBase::ATTR_SUBS;
60 \*$prefix\::HashBase::ATTR_LIST = \\\%Object::HashBase::ATTR_LIST;
61 \*$prefix\::HashBase::VERSION = \\\%Object::HashBase::VERSION;
62 \*$prefix\::HashBase::CAN_CACHE = \\\%Object::HashBase::CAN_CACHE;
63 }
64  
65 EOT
66  
67 1 print $tf <<" EOT";
68 use strict;
69 use warnings;
70  
71 use Test::More;
72  
73 EOT
74  
75 1 my $writing = 0;
76 1 ▶ while (my $line = <$hin>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $hin)) 865 1 866
77 865 ▶ if ($line =~ m/<-- START -->/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /<-- START -->/) 1 864 865
78 1 $writing = 1;
79 1 next;
80 }
81  
82 864 ▶ if ($line =~ m/^=head1 INCLUDING IN YOUR DIST$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^=head1 INCLUDING IN YOUR DIST$/) 1 863 864
83 1 $writing = 0;
84 1 print $hbf <<" EOT";
85 \=head1 THIS IS A BUNDLED COPY OF HASHBASE
86  
87 This is a bundled copy of L<Object::HashBase>. This file was generated using
88 the
89 C<$0>
90 script.
91  
92 EOT
93 1 next;
94 }
95 863 ▶ if ($line =~ m/^=head1 /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^=head1 /) 14 849 863
96 14 $writing = 1;
97 }
98  
99 863 ▶ next unless $writing;
Branch: 1 branch
BranchTrueFalseTotal
unless $writing 26 837 863
100  
101 837 $line =~ s/\QObject::\E/$prefix\::/g;
102  
103 837 print $hbf $line;
104 }
105  
106 1 $writing = 0;
107 1 ▶ while (my $line = <$tin>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $tin)) 337 1 338
108 337 ▶ if ($line =~ m/<-- START -->/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /<-- START -->/) 1 336 337
109 1 $writing = 1;
110 1 next;
111 }
112  
113 336 ▶ next unless $writing;
Branch: 1 branch
BranchTrueFalseTotal
unless $writing 23 313 336
114  
115 313 $line =~ s/\QObject::HashBase::Test::\E/main\::/g;
116 313 $line =~ s/\QObject::\E/$prefix\::/g;
117 313 print $tf $line;
118 }
119  
120 1 close($hbf);
121 1 close($tf);
122 }
123  
124 1 1;
« blib/lib/Object/HashBase.pm ↑ Summary blib/script/hashbase_inc.pl »