lib/VIM/Packager/MakeMaker.pm

filter: Statementstmt 14.3% 55 / 384 Branchbran 5.0% 4 / 80 Conditioncond 0.0% 0 / 92 MC/DCmcdc 0.0% 0 / 50 Subroutinesub 36.5% 15 / 41 Podpod 61.5% 16 / 26 totaltotal 13.3% 90 / 673 CC 91 SCAR 54.3
CC
91
Cov
11%
config_section
870.0
prompt
182.0
check_dependency
90.0
CRAP 229.2
↑ Summary blib/lib/VIM/Packager/Manifest.pm »
1 package VIM::Packager::MakeMaker;
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use VIM::Packager;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use VIM::Packager::MetaReader;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use VIM::Packager::Utils qw(vim_rtp_home vim_inst_record_dir findbin);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use DateTime::Format::DateParse;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use VIM::Packager::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our $VERSION = 0.0.1;
16 1 my $VERBOSE = 1;
17  
18 =head1 SYNOPSIS
19  
20 $ vim-packager build
21 $ make -f Makefile.vimp
22  
23 # auto install dependency
24 $ make install -f Makefile.vimp
25  
26 =head1 Constants
27  
28 LIBPATH: F<vimlib/>
29  
30 =cut
31  
32 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 LIBPATH => 'vimlib',
34 1 };
35  
36 =head1 Makefile Helper Functions
37  
38 =head2 multi_line Array:Lines
39  
40 =head2 add_macro ArrayRef:Makefile Lines , String: Macro Name , String: Macro
41  
42 =head2 new_section ArrayRef:Makefile Lines , String: Section Name , Array: Depended macro names
43  
44 =head2 add_st ArrayRef:Makefile Lines , String: Statement , Array: Statement Arguments
45  
46 Statement Arguments is for Statement string, which is in sprintf format.
47  
48 =head2 add_noop_st ArrayRef:Makefile Lines
49  
50 =cut
51  
52 0 ▶sub multi_line {
Subroutine multi_line: not called CC=1 SCAR=6.9
Pod documented
53 0 my @items = @_;
54 0 return join " \\\n\t", @items ;
55 }
56  
57 0 ▶sub add_macro {
Subroutine add_macro: not called CC=1 SCAR=6.9
Pod documented
58 0 my $ref = shift;
59 0 my ( $name, $content ) = @_;
60 0 push @{ $ref } , qq|$name = $content|;
61 }
62  
63 0 ▶sub new_section {
Subroutine new_section: not called CC=1 SCAR=6.9
Pod documented
64 0 my $ref = shift;
65 0 my ( $name , @deps ) = @_;
66 0 push @{ $ref } , qq|| , qq|$name : | . join( " ", @deps );
67 }
68  
69 0 ▶sub add_st {
Subroutine add_st: not called CC=1 SCAR=6.9
Pod documented
70 0 my ($ref, $st , @args ) = @_;
71 0 push @{ $ref } , qq|\t\t| . sprintf($st , @args);
72 }
73  
74 0 ▶sub add_noop_st {
Subroutine add_noop_st: not called CC=1 SCAR=6.9
Pod documented
75 0 add_st $_[0] => q|$(NOECHO) $(NOOP)|;
76 }
77  
78 =head1 Main Functions
79  
80 =head2 new
81  
82 =cut
83  
84 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
85 0 my $class = shift;
86 0 my $cmd = shift; # command object
87  
88 0 my $self = bless {}, $class;
89 0 my $meta = VIM::Packager::MetaReader->new->read_metafile();
90  
91 0 $self->{cmd} = $cmd;
92  
93 0 YAML::DumpFile( "VIMMETA.yml" , $meta );
94  
95 0 $self->meta( $meta ); # save meta object
96  
97 0 my $makefile = {};
98 0 $makefile->{meta} = $meta;
99  
100 {
101 0 my $info = vim_version_info();
102  
103 0 my $op = $meta->{vim_version}->{op} ;
104 0 my $version = $meta->{vim_version}->{version} ;
105  
106 0 my $installed_vim_version = $info->{version};
107  
108 0 print STDOUT "Found installed VIM, version $installed_vim_version\n";
109  
110 0 ▶ unless( eval "$installed_vim_version $op $version" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "$installed_vim_version $op $version") 0 0 0
111 0 print STDOUT "This distrubution needs a newer vim ( $version )\n";
112 0 die;
113 }
114 }
115  
116 0 ▶ print STDOUT "VIM::Packager::MakeMaker (v$VERSION)\n" if $VERBOSE;
Branch: 1 branch
BranchTrueFalseTotal
if $VERBOSE 0 0 0
117 0 ▶ if (-f "MANIFEST" && ! -f "Makefile"){
Branch: 1 branch
BranchTrueFalseTotal
if (-f "MANIFEST" and not -f "Makefile") 0 0 0
Condition0%0/3
-f "MANIFEST" and not -f "Makefile"
!ll&&!rl&&r
000
MC/DC0%0/2
-f "MANIFEST" and not -f "Makefile"
-f "MANIFEST" not -f "Makefile"
Truth table0%0/3
A and not(B)
A= -f "MANIFEST"B= not -f "Makefile"
ABresult
0X0
100
111
118 0 check_manifest();
119 }
120  
121 0 my $main = [ ];
122  
123 0 push @$main, q|.PHONY: all install clean uninstall help upload link|;
124
125 0 ▶ my $filelist = $self->make_filelist( $meta->{libpath} || LIBPATH );
Condition0%0/2
$meta->{'libpath'} || 'vimlib'
l!l
00
MC/DC0%0/1
$meta->{'libpath'} || 'vimlib'
$meta->{'libpath'}
Truth table0%0/2
A
A= $meta->{'libpath'}
Aresult
11
00
126  
127 0 $makefile->{filelist} = $filelist;
128  
129 0 my @meta_section = $self->meta_section( $meta );
130 0 my @config_section = $self->config_section();
131 0 my @file_section = $self->file_section( $filelist );
132  
133 0 $self->section_all( $main );
134 0 $self->section_install( $main );
135  
136 # main install section
137 0 $self->section_pure_install( $main , $makefile );
138  
139 # dependency section
140 0 $self->section_deps( $main );
141 0 $self->section_link( $main , $filelist );
142  
143 0 new_section $main => 'manifest';
144 0 add_st $main => q|$(NOECHO) $(ECHO) ".git" > MANIFEST.SKIP|;
145 0 add_st $main => q|$(NOECHO) $(ECHO) ".svn" >> MANIFEST.SKIP|;
146 0 add_st $main => q|$(NOECHO) $(ECHO) ".*.tar.gz" >> MANIFEST.SKIP|;
147 0 add_st $main => q|$(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Manifest=mkmanifest -e 'mkmanifest'|;
148  
149 0 new_section $main => 'dist' , qw(manifest);
150 0 add_st $main => q|$(TAR) $(TARFLAGS) $(DISTNAME).tar.gz $(TO_INST_VIMS) $(META_FILE) $(README) `cat MANIFEST`|;
151 0 add_noop_st $main;
152  
153 0 new_section $main => 'help';
154 0 add_st $main => q|perldoc VIM::Packager|;
155  
156 0 new_section $main => 'uninstall';
157 0 add_st $main => q|$(NOECHO) $(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Installer=uninstall |
158 . q| -e 'uninstall()' $(NAME)|;
159  
160 # XXX: prompt user to uninstall depedencies
161 0 new_section $main => 'reinstall' , qw(uninstall install);
162 0 add_noop_st $main;
163  
164 0 new_section $main => 'upload' , qw(dist);
165 0 add_st $main => q|$(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Uploader=upload -e 'upload()' |
166 . multi_line qw|$(PWD)/$(DISTNAME).tar.gz $(VIM_VERSION) $(VERSION) $(SCRIPT_ID)|;
167  
168 0 new_section $main => 'clean';
169 0 add_st $main => q|$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)|;
170 0 add_st $main => q|$(RM) *.tar.gz|;
171  
172 0 new_section $main => 'bump';
173 0 add_st $main => q|$(NOECHO) $(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Installer=bump_version -e 'bump_version()' |;
174 0 add_st $main => q|sh -c 'vim-packager build'|; # rebuild
175 0 add_st $main => q|sh -c 'make upload -f Makefile.vimp'|;
176  
177 0 new_section $main => 'release' , qw(bump);
178 0 add_noop_st $main;
179  
180 0 $self->generate_makefile( [
181 { meta => \@meta_section },
182 { config => \@config_section },
183 { file => \@file_section },
184 { main => $main } ] );
185 }
186  
187 =head2 meta
188  
189 return current meta object.
190  
191 =cut
192  
193 0 ▶sub meta {
Subroutine meta: not called CC=2 SCAR=17.9
Pod documented
194 0 my $self = shift;
195 0 ▶ $self->{meta} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
196 0 return $self->{meta};
197 }
198  
199  
200  
201  
202  
203 =head2 section_all
204  
205  
206  
207 =cut
208  
209 0 ▶sub section_all {
Subroutine section_all: not called CC=1 SCAR=6.9
Pod documented
210 0 my $self = shift;
211 0 my $main = shift;
212 0 new_section $main => "all" => qw(install-deps);
213 0 add_noop_st $main;
214 }
215  
216 =head2 section_install
217  
218  
219  
220 =cut
221  
222 0 ▶sub section_install {
Subroutine section_install: not called CC=1 SCAR=6.9
Pod documented
223 0 my $self = shift;
224 0 my $main = shift;
225 0 new_section $main => "install" => qw(pure_install install-deps) ;
226 0 add_noop_st $main;
227 }
228  
229 =head2 section_pure_install
230  
231  
232  
233 =cut
234  
235 0 ▶sub section_pure_install {
Subroutine section_pure_install: not called CC=3 SCAR=24.8
Pod documented
236 0 my ($self,$main,$makefile) = @_;
237  
238 0 new_section $main => "pure_install";
239  
240 # pure makefile option let
241 # makefile doesnt depend on perl module.
242 0 ▶ if ( $self->{cmd}->{pure} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'cmd'}{'pure'}) { } 0 0 0
243 0 print "Making pure makefile (not to depend on perl module)\n";
244  
245 0 my %files = %{ $makefile->{filelist} };
246
247 0 ▶ while ( my ($from,$to) = each %files ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %files) 0 0 0
248 0 add_st $main => sprintf( q|$(CP) %s %s| , $from , $to );
249 }
250 }
251 else {
252 0 add_st $main =>
253 q|$(NOECHO) $(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Installer=install|
254 . q| -e 'install()' $(NAME) $(VIMS_TO_RUNT) $(BIN_TO_RUNT)|;
255 }
256 }
257  
258 =head2 section_deps
259  
260  
261  
262 =cut
263  
264 0 ▶sub section_deps {
Subroutine section_deps: not called CC=6 SCAR=37.4
Pod documented
265 0 my $self = shift;
266 0 my $main = shift;
267  
268 0 new_section $main => "install-deps";
269  
270 0 ▶ if( $self->{cmd}->{pure} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cmd"}{"pure"}) 0 0 0
271 0 print "You are making a pure makefile that doesn't depend on perl module.\n";
272 0 print "We are going to skip dependency section.\n";
273 0 add_noop_st $main;
274 0 return;
275 }
276  
277 0 my $requires = $self->check_dependency( $self->meta );
278 0 my %unsatisfied = %{ $requires->{unsat} };
279 0 my %nonversion_unsat = %{ $requires->{nonversion_unsat} };
280  
281 # grep out the non-version package requires from those unsatisfied infomation
282 # which is an array ref because it's a file list.
283 0 my @pkgs_nonversion = keys %nonversion_unsat;
284 0 for my $pkgname ( @pkgs_nonversion ) {
285 0 my @nonversion_params = map { ( $_->{target} , $_->{from} ) }
286 0 map { @{ $nonversion_unsat{ $_ } } } $pkgname ;
287  
288 0 add_st $main => multi_line q|$(NOECHO) $(FULLPERL) $(PERLFLAGS)|
289 . qq| -MVIM::Packager::Installer=install_deps_remote |
290 . qq| -e 'install_deps_remote()' $pkgname |
291 , @nonversion_params ;
292  
293 }
294  
295 # XXX: grep git repo deps from upstream ... zzz
296 # packages with version specified.
297 0 my @pkgs_version = keys %unsatisfied;
298 0 ▶ if( @pkgs_version > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pkgs_version > 0) 0 0 0
299 0 my @pkgs_git_repo = grep { $unsatisfied{ $_ }->{git_repo} } @pkgs_version;
300 0 for my $pkg ( @pkgs_git_repo ) {
301 0 my $dep = $unsatisfied{ $pkg };
302
303 0 my $v = $dep->{version};
304 0 add_st $main => q|$(NOECHO) $(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Installer=install_deps_from_git |
305 0 . qq| -e 'install_deps_from_git()' @{[ $dep->{git_repo} ]} $v|;
306 }
307  
308 0 my @pkgs_version = grep { ! $unsatisfied{ $_ }->{git_repo} } @pkgs_version;
309
310 0 ▶ add_st $main => q|$(NOECHO) $(FULLPERL) $(PERLFLAGS) -MVIM::Packager::Installer=install_deps |
Branch: 1 branch
BranchTrueFalseTotal
if @pkgs_version > 0 0 0 0
311 0 . qq| -e 'install_deps()' '@{[ join ",",@pkgs_version ]}' |
312 if @pkgs_version > 0;
313 }
314 }
315  
316 =head2 section_link
317  
318  
319 =cut
320  
321 0 ▶sub section_link {
Subroutine section_link: not called CC=4 SCAR=30.0
Pod documented
322 0 my ($self,$main , $filelist) = @_;
323 0 new_section $main => 'link';
324 0 ▶ while( my ($src,$target) = each %$filelist ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$filelist) 0 0 0
325 0 add_st $main => q|$(NOECHO) $(LN_S) | . File::Spec->join( '$(PWD)' , $src ) . " " . $target;
326 }
327 0 new_section $main => 'link-force';
328 0 ▶ while( my ($src,$target) = each %$filelist ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$filelist) 0 0 0
329 0 add_st $main => q|$(NOECHO) $(LN_SF) | . File::Spec->join( '$(PWD)' , $src ) . " " . $target;
330 }
331  
332 0 new_section $main => 'unlink';
333 0 ▶ while( my ($src,$target) = each %$filelist ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$filelist) 0 0 0
334 0 add_st $main => q|$(NOECHO) $(RM) | . $target;
335 }
336 }
337  
338  
339 0 ▶sub generate_makefile {
Subroutine generate_makefile: not called CC=4 SCAR=30.0
Pod undocumented
340 0 my $self = shift;
341 0 my $sections = shift;
342
343  
344 0 print "Write to Makefile.vimp\n";
345  
346 0 open my $fh , ">" , 'Makefile.vimp';
347 0 print $fh <<'END';
348 # VIM::Packager::MakeMaker
349 #
350 # This Makefile is generated by VIM::Packager::MakeMaker version $VERSION from
351 # the contents of META . don't edit this file, edit META file instead.
352 #
353 # Author: Cornelius
354 # Email : cornelius.howl@gmail.com
355 #
356  
357 END
358 0 for my $s ( @$sections ) {
359 0 my $n = (keys %$s)[0];
360 0 my $list = $s->{$n};
361 0 print $fh "\n" for ( 1 .. 3 );
362 0 print $fh sprintf("# -------- %s section ------\n" , $n );
363 0 print $fh join("\n", @$list );
364 0 print $fh "\n" for ( 1 .. 2 );
365 }
366 0 close $fh;
367 0 print "DONE\n";
368 }
369  
370 0 ▶sub meta_section {
Subroutine meta_section: not called CC=1 SCAR=6.9
Pod undocumented
371 0 my $self = shift;
372 0 my $meta = shift;
373 0 my @section = ();
374 0 map { add_macro \@section, uc($_) => $meta->{$_} } grep { ! ref $meta->{$_} } keys %$meta;
375  
376 0 my $distname = $meta->{name};
377 0 $distname =~ tr/._/--/;
378 0 $distname .= '-' . $meta->{version};
379 0 add_macro \@section , DISTNAME => $distname;
380  
381 # XXX: op skipeed
382 0 add_macro \@section , VIM_VERSION => $meta->{vim_version}->{version};
383  
384 0 return @section;
385 }
386  
387 0 ▶sub config_section {
Subroutine config_section: not called CC=29 SCAR=67.7
Pod undocumented
388 0 my $self = shift;
389  
390 0 my @section = ();
391  
392 0 my %configs = ();
393 0 my %dir_configs = $self->init_vim_dir_macro();
394  
395 0 my $perl = find_perl();
396 0 ▶ die "Can not found perl." unless $perl;
Branch: 1 branch
BranchTrueFalseTotal
unless $perl 0 0 0
397  
398 0 ▶ $configs{FULLPERL} ||= $perl;
Condition0%0/3
$configs{"FULLPERL"} ||= $perl
l!l&&r!l&&!r
000
MC/DC0%0/2
$configs{"FULLPERL"} ||= $perl
$configs{"FULLPERL"} $perl
Truth table0%0/3
A ||= B
A= $configs{"FULLPERL"}B= $perl
ABresult
1X1
011
000
399 0 ▶ $configs{NOECHO} ||= '@';
Condition0%0/2
$configs{"NOECHO"} ||= "\@"
l!l
00
MC/DC0%0/1
$configs{"NOECHO"} ||= "\@"
$configs{"NOECHO"}
Truth table0%0/2
A
A= $configs{"NOECHO"}
Aresult
11
00
400 0 ▶ $configs{TOUCH} ||= 'touch';
Condition0%0/2
$configs{"TOUCH"} ||= "touch"
l!l
00
MC/DC0%0/1
$configs{"TOUCH"} ||= "touch"
$configs{"TOUCH"}
Truth table0%0/2
A
A= $configs{"TOUCH"}
Aresult
11
00
401 0 ▶ $configs{ECHO} ||= 'echo';
Condition0%0/2
$configs{"ECHO"} ||= "echo"
l!l
00
MC/DC0%0/1
$configs{"ECHO"} ||= "echo"
$configs{"ECHO"}
Truth table0%0/2
A
A= $configs{"ECHO"}
Aresult
11
00
402 0 ▶ $configs{ECHO_N} ||= 'echo -n';
Condition0%0/2
$configs{"ECHO_N"} ||= "echo -n"
l!l
00
MC/DC0%0/1
$configs{"ECHO_N"} ||= "echo -n"
$configs{"ECHO_N"}
Truth table0%0/2
A
A= $configs{"ECHO_N"}
Aresult
11
00
403 0 ▶ $configs{RM_F} ||= "rm -vf";
Condition0%0/2
$configs{"RM_F"} ||= "rm -vf"
l!l
00
MC/DC0%0/1
$configs{"RM_F"} ||= "rm -vf"
$configs{"RM_F"}
Truth table0%0/2
A
A= $configs{"RM_F"}
Aresult
11
00
404 0 ▶ $configs{RM_RF} ||= "rm -rf";
Condition0%0/2
$configs{"RM_RF"} ||= "rm -rf"
l!l
00
MC/DC0%0/1
$configs{"RM_RF"} ||= "rm -rf"
$configs{"RM_RF"}
Truth table0%0/2
A
A= $configs{"RM_RF"}
Aresult
11
00
405 0 ▶ $configs{TEST_F} ||= "test -f";
Condition0%0/2
$configs{"TEST_F"} ||= "test -f"
l!l
00
MC/DC0%0/1
$configs{"TEST_F"} ||= "test -f"
$configs{"TEST_F"}
Truth table0%0/2
A
A= $configs{"TEST_F"}
Aresult
11
00
406 0 ▶ $configs{CP} ||= "cp";
Condition0%0/2
$configs{"CP"} ||= "cp"
l!l
00
MC/DC0%0/1
$configs{"CP"} ||= "cp"
$configs{"CP"}
Truth table0%0/2
A
A= $configs{"CP"}
Aresult
11
00
407 0 ▶ $configs{MV} ||= "mv";
Condition0%0/2
$configs{"MV"} ||= "mv"
l!l
00
MC/DC0%0/1
$configs{"MV"} ||= "mv"
$configs{"MV"}
Truth table0%0/2
A
A= $configs{"MV"}
Aresult
11
00
408 0 ▶ $configs{CHMOD} ||= "chmod";
Condition0%0/2
$configs{"CHMOD"} ||= "chmod"
l!l
00
MC/DC0%0/1
$configs{"CHMOD"} ||= "chmod"
$configs{"CHMOD"}
Truth table0%0/2
A
A= $configs{"CHMOD"}
Aresult
11
00
409 0 ▶ $configs{FALSE} ||= 'false';
Condition0%0/2
$configs{"FALSE"} ||= "false"
l!l
00
MC/DC0%0/1
$configs{"FALSE"} ||= "false"
$configs{"FALSE"}
Truth table0%0/2
A
A= $configs{"FALSE"}
Aresult
11
00
410 0 ▶ $configs{TRUE} ||= 'true';
Condition0%0/2
$configs{"TRUE"} ||= "true"
l!l
00
MC/DC0%0/1
$configs{"TRUE"} ||= "true"
$configs{"TRUE"}
Truth table0%0/2
A
A= $configs{"TRUE"}
Aresult
11
00
411 0 ▶ $configs{NOOP} ||= '$(TRUE)';
Condition0%0/2
$configs{"NOOP"} ||= "\$(TRUE)"
l!l
00
MC/DC0%0/1
$configs{"NOOP"} ||= "\$(TRUE)"
$configs{"NOOP"}
Truth table0%0/2
A
A= $configs{"NOOP"}
Aresult
11
00
412 0 ▶ $configs{LN_S} ||= 'ln -sv';
Condition0%0/2
$configs{"LN_S"} ||= "ln -sv"
l!l
00
MC/DC0%0/1
$configs{"LN_S"} ||= "ln -sv"
$configs{"LN_S"}
Truth table0%0/2
A
A= $configs{"LN_S"}
Aresult
11
00
413 0 ▶ $configs{LN_SF} ||= 'ln -svf';
Condition0%0/2
$configs{"LN_SF"} ||= "ln -svf"
l!l
00
MC/DC0%0/1
$configs{"LN_SF"} ||= "ln -svf"
$configs{"LN_SF"}
Truth table0%0/2
A
A= $configs{"LN_SF"}
Aresult
11
00
414 0 ▶ $configs{PWD} ||= '`pwd`';
Condition0%0/2
$configs{"PWD"} ||= "`pwd`"
l!l
00
MC/DC0%0/1
$configs{"PWD"} ||= "`pwd`"
$configs{"PWD"}
Truth table0%0/2
A
A= $configs{"PWD"}
Aresult
11
00
415 0 ▶ $configs{CP} ||= 'cp -v';
Condition0%0/2
$configs{"CP"} ||= "cp -v"
l!l
00
MC/DC0%0/1
$configs{"CP"} ||= "cp -v"
$configs{"CP"}
Truth table0%0/2
A
A= $configs{"CP"}
Aresult
11
00
416  
417 0 ▶ $configs{README} ||= '';
Condition0%0/2
$configs{"README"} ||= ""
l!l
00
MC/DC0%0/1
$configs{"README"} ||= ""
$configs{"README"}
Truth table0%0/2
A
A= $configs{"README"}
Aresult
11
00
418 0 ▶ $configs{README} .= ' README' if -e 'README';
Branch: 1 branch
BranchTrueFalseTotal
if -e "README" 0 0 0
419 0 ▶ $configs{README} .= ' README.mkd' if -e 'README.mkd';
Branch: 1 branch
BranchTrueFalseTotal
if -e "README.mkd" 0 0 0
420  
421 0 ▶ $configs{META_FILE} ||= VIM::Packager::MetaReader->find_meta_file();
Condition0%0/3
$configs{"META_FILE"} ||= "VIM::Packager::MetaReader"->find_meta_file
l!l&&r!l&&!r
000
MC/DC0%0/2
$configs{"META_FILE"} ||= "VIM::Packager::MetaReader"->find_meta_file
$configs{"META_FILE"} "VIM::Packager::MetaReader"->find_meta_file
Truth table0%0/3
A ||= B
A= $configs{"META_FILE"}B= "VIM::Packager::MetaReader"->find_meta_file
ABresult
1X1
011
000
422  
423 0 ▶ $configs{FIRST_MAKEFILE} ||= 'Makefile';
Condition0%0/2
$configs{"FIRST_MAKEFILE"} ||= "Makefile"
l!l
00
MC/DC0%0/1
$configs{"FIRST_MAKEFILE"} ||= "Makefile"
$configs{"FIRST_MAKEFILE"}
Truth table0%0/2
A
A= $configs{"FIRST_MAKEFILE"}
Aresult
11
00
424 0 ▶ $configs{MAKEFILE_OLD} ||= 'Makefile.old';
Condition0%0/2
$configs{"MAKEFILE_OLD"} ||= "Makefile.old"
l!l
00
MC/DC0%0/1
$configs{"MAKEFILE_OLD"} ||= "Makefile.old"
$configs{"MAKEFILE_OLD"}
Truth table0%0/2
A
A= $configs{"MAKEFILE_OLD"}
Aresult
11
00
425  
426 0 ▶ $configs{TAR} ||= 'COPY_EXTENDED_ATTRIBUTES_DISABLE=1 COPYFILE_DISABLE=1 tar';
Condition0%0/2
$configs{"TAR"} ||= "COPY_EXTENDED_ATTRIBUTES_DISABLE=1 COPYFILE_DISABLE=1 tar"
l!l
00
MC/DC0%0/1
$configs{"TAR"} ||= "COPY_EXTENDED_ATTRIBUTES_DISABLE=1 COPYFILE_DISABLE=1 tar"
$configs{"TAR"}
Truth table0%0/2
A
A= $configs{"TAR"}
Aresult
11
00
427 0 ▶ $configs{TARFLAGS} ||= 'cvzf';
Condition0%0/2
$configs{"TARFLAGS"} ||= "cvzf"
l!l
00
MC/DC0%0/1
$configs{"TARFLAGS"} ||= "cvzf"
$configs{"TARFLAGS"}
Truth table0%0/2
A
A= $configs{"TARFLAGS"}
Aresult
11
00
428  
429 0 ▶ $configs{PERLFLAGS} ||= ' -Ilib ';
Condition0%0/2
$configs{"PERLFLAGS"} ||= " -Ilib "
l!l
00
MC/DC0%0/1
$configs{"PERLFLAGS"} ||= " -Ilib "
$configs{"PERLFLAGS"}
Truth table0%0/2
A
A= $configs{"PERLFLAGS"}
Aresult
11
00
430  
431 0 map { add_macro \@section, $_ => $configs{$_} } sort keys %configs;
432 0 map { add_macro \@section, $_ => $dir_configs{$_} } sort keys %dir_configs;
433 0 return @section;
434 }
435  
436 0 ▶sub file_section {
Subroutine file_section: not called CC=4 SCAR=30.0
Pod undocumented
437 0 my $self = shift;
438 0 my $filelist = shift;
439 0 my $meta = $self->meta;
440  
441 0 my @section = ();
442  
443 0 my @to_install = keys %$filelist;
444  
445 0 ▶ add_macro \@section , VIMLIB => $meta->{libpath} || LIBPATH;
Condition0%0/2
$meta->{'libpath'} || 'vimlib'
l!l
00
MC/DC0%0/1
$meta->{'libpath'} || 'vimlib'
$meta->{'libpath'}
Truth table0%0/2
A
A= $meta->{'libpath'}
Aresult
11
00
446  
447 0 add_macro \@section , VIMMETA => VIM::Packager::MetaReader::find_meta_file();
448  
449 0 add_macro \@section , TO_INST_VIMS => multi_line @to_install ;
450  
451 0 my @vims_to_runtime = %$filelist;
452 0 add_macro \@section , VIMS_TO_RUNT => multi_line @vims_to_runtime ;
453  
454 0 my %bin_to_runtime = ();
455  
456 0 ▶ if( $meta->{script} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"script"}) 0 0 0
457 0 my @bin = @{ $meta->{script} };
458 0 for (@bin) {
459 0 my ( $v, $d, $f ) = File::Spec->splitpath($_);
460 # $bin_to_runtime{ $_ } = File::Spec->join( vim_rtp_home() , 'bin' , $f );
461 0 $bin_to_runtime{$_} = File::Spec->join( '$(VIM_BASEDIR)', 'bin', $f );
462 }
463 0 add_macro \@section , TO_INST_BIN => multi_line keys %bin_to_runtime ;
464 0 add_macro \@section , BIN_TO_RUNT => multi_line %bin_to_runtime ;
465 }
466 0 return @section;
467 }
468  
469 =head2 get_installed_pkgs
470  
471 =cut
472  
473 2 ▶sub get_installed_pkgs {
Subroutine get_installed_pkgs: called CC=2 SCAR=6.9
Pod documented
474 2 my ($self, $dir ) = @_;
475  
476 2 ▶ unless( -e $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $dir) 1 1 2
477 1 File::Path::mkpath [ $dir ];
478 1 return ();
479 }
480  
481 1 my @pkg_record_files = ();
482 3 ▶ my $closure = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
483 3 my $file = $_;
484 3 my $dir = $File::Find::dir;
485  
486 3 ▶ return unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 1 2 3
487  
488 2 my $path = File::Spec->join($dir , $file );
489 2 push @pkg_record_files , $path;
490 1 };
491  
492 1 File::Find::find( \&$closure ,$dir );
493 1 return @pkg_record_files;
494 }
495  
496  
497  
498 =head2 check_dependency
499  
500 pass meta object and check dependency.
501  
502 =cut
503  
504 0 ▶sub check_dependency {
Subroutine check_dependency: not called CC=9 SCAR=45.0
Pod documented
505 0 my $self = shift;
506 0 my $meta = shift;
507  
508 0 my $record_dir = $self->vim_inst_record_dir();
509 0 my @pkg_records = $self->get_installed_pkgs($record_dir);
510  
511 0 my %unsatisfied = ();
512 0 my %nonversion_unsat = ();
513  
514 0 for my $dep ( @{ $meta->{dependency} } ) {
515  
516 0 ▶ if ( defined $dep->{version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dep->{'version'}) { } 0 0 0
517 my ( $prereq, $required_version, $version_op , $git_repo )
518 0 = @$dep{qw(name version op git_repo)};
519  
520 # XXX: check if prerequire plugin is installed.
521 # try to get installed package record
522 # or just look into file and parse the version
523 0 my $pr_version = undef ;
524  
525 0 my $found = VIM::Packager::Record->find( $prereq );
526 0 ▶ if( $found ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found) { } 0 0 0
527 0 my $r = VIM::Packager::Record->read( $found );
528 0 $pr_version = $r->{meta}->{version};
529 0 print "Found Installed Package: $prereq \n";
530 0 print "Version: $pr_version\n";
531 }
532 else {
533 0 my $installed_files; # get installed files here
534 0 ▶ $pr_version = parse_version( $installed_files ) if( $installed_files );
Branch: 1 branch
BranchTrueFalseTotal
if $installed_files 0 0 0
535 }
536  
537 0 ▶ if( ! $pr_version ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $pr_version) { } 0 0 0
elsif (eval "$pr_version $version_op $required_version") { } 0 0 0
538 0 warn sprintf "Warning: prerequisite %s - %s not found.\n",
539 $prereq, $required_version;
540 0 $unsatisfied{ $prereq } = $dep;
541 }
542 elsif ( eval "$pr_version $version_op $required_version" ) {
543 0 warn sprintf "Warning: prerequisite %s - %s not found. We have %s.\n",
544 $prereq, $required_version, $pr_version;
545  
546 0 $unsatisfied{ $prereq } = $dep;
547 }
548  
549 }
550 else {
551 # if we can not detect installed package version
552 # here is the other way to install dependencies.
553 0 my ( $prereq , $require_files ) = ( $dep->{name} , $dep->{required_files} );
554 0 $nonversion_unsat{ $prereq } = $require_files;
555  
556 # XXX: grep out ?
557 0 for ( @$require_files ) {
558 # XXX: expand Makefile variable to support such things like:
559 # $(VIM_BASEDIR)/path/to/
560 0 my $target_path = File::Spec->join( vim_rtp_home() , $_->{target} ) ;
561  
562 0 ▶ unless( -e $target_path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $target_path) { } 0 0 0
563 warn sprintf "Warning: prerequisite %s - %s not found.\n\tWill be retreived from %s\n",
564 0 $prereq , $target_path , $_->{from} ;
565 }
566 else {
567 0 printf "[ %s : %s ] .... OK\n" , $prereq , $_->{target} ;
568 }
569 }
570 }
571  
572 }
573  
574 return {
575 0 unsat => \%unsatisfied,
576 nonversion_unsat => \%nonversion_unsat,
577 };
578 }
579  
580 0 ▶sub possible_runtime_dir { qw(autoload after syntax ftplugin ftdetect compiler plugin macros colors doc) }
Subroutine possible_runtime_dir: not called CC=1 SCAR=6.9
Pod undocumented
581  
582 =head2 init_vim_dir_macro
583  
584 init vim dir macro
585  
586 =cut
587  
588 0 ▶sub init_vim_dir_macro {
Subroutine init_vim_dir_macro: not called CC=6 SCAR=37.4
Pod documented
589 0 my $self = shift;
590 0 my %dir_configs = ();
591 0 ▶ $dir_configs{ VIM_BASEDIR } = $ENV{VIM_BASEDIR} || vim_rtp_home();
Condition0%0/3
$ENV{'VIM_BASEDIR'} || vim_rtp_home()
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'VIM_BASEDIR'} || vim_rtp_home()
$ENV{'VIM_BASEDIR'} vim_rtp_home()
Truth table0%0/3
A || B
A= $ENV{'VIM_BASEDIR'}B= vim_rtp_home()
ABresult
1X1
011
000
592 0 ▶ $dir_configs{ VIM_AFTERBASE_DIR} = $ENV{VIM_AFTERBASE_DIR} || File::Spec->join( $dir_configs{VIM_BASEDIR} , 'after' );
Condition0%0/3
$ENV{'VIM_AFTERBASE_DIR'} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, 'after')
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'VIM_AFTERBASE_DIR'} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, 'after')
$ENV{'VIM_AFTERBASE_DIR'} 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, 'after')
Truth table0%0/3
A || B
A= $ENV{'VIM_AFTERBASE_DIR'}B= 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, 'after')
ABresult
1X1
011
000
593  
594 0 for my $sub ( possible_runtime_dir() ) {
595 0 my $path_name = 'VIM_' . uc($sub) . '_DIR';
596 0 my $after_path_name = 'VIM_AFTER_' . uc($sub) . '_DIR';
597 $dir_configs{$path_name} = $ENV{$path_name}
598 0 ▶ || File::Spec->join( $dir_configs{VIM_BASEDIR}, $sub );
Condition0%0/3
$ENV{$path_name} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{$path_name} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
$ENV{$path_name} 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
Truth table0%0/3
A || B
A= $ENV{$path_name}B= 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
ABresult
1X1
011
000
599  
600 $dir_configs{$after_path_name} = $ENV{$after_path_name}
601 0 ▶ || File::Spec->join( $dir_configs{VIM_BASEDIR}, $sub );
Condition0%0/3
$ENV{$after_path_name} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{$after_path_name} || 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
$ENV{$after_path_name} 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
Truth table0%0/3
A || B
A= $ENV{$after_path_name}B= 'File::Spec'->join($dir_configs{'VIM_BASEDIR'}, $sub)
ABresult
1X1
011
000
602 }
603 0 return %dir_configs;
604 }
605  
606  
607 =head2 make_filelist
608  
609 if install_dirs is given , then we should record:
610  
611 autoload/zzz.vim
612 plugin/xxx.vim
613  
614 if not , then we should find files from F<vimlib/>
615  
616 TO_INSTALL=$(VIM_BASEDIR)/plugin/xxx.vim
617 \ $(VIM_BASEDIR)/autoload/zzz.vim
618  
619 =cut
620  
621 0 ▶sub make_filelist {
Subroutine make_filelist: not called CC=3 SCAR=24.8
Pod documented
622 0 my ( $self, $base_prefix ) = @_;
623  
624 0 my %install = ();
625  
626 # my $prefix = File::Spec->join($ENV{HOME} , '.vim');
627 0 my $prefix = '$(VIM_BASEDIR)';
628  
629 0 ▶ my @search_dir = ( ( $base_prefix eq '.' or $base_prefix eq './' )
Branch: 1 branch
BranchTrueFalseTotal
$base_prefix eq '.' || $base_prefix eq './' ? : 0 0 0
Condition0%0/3
$base_prefix eq "." or $base_prefix eq "./"
l!l&&r!l&&!r
000
MC/DC0%0/2
$base_prefix eq "." or $base_prefix eq "./"
$base_prefix eq "." $base_prefix eq "./"
Truth table0%0/3
A or B
A= $base_prefix eq "."B= $base_prefix eq "./"
ABresult
1X1
011
000
630 ? possible_runtime_dir()
631 : $base_prefix );
632
633  
634 0 ▶ File::Find::find( sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
635 0 ▶ return unless -f $_;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $_ 0 0 0
636 0 ▶ return if /\#/;
Branch: 1 branch
BranchTrueFalseTotal
if /\#/ 0 0 0
637 0 ▶ return if /~$/; # emacs temp files
Branch: 1 branch
BranchTrueFalseTotal
if /~$/ 0 0 0
638 0 ▶ return if /,v$/; # RCS files
Branch: 1 branch
BranchTrueFalseTotal
if /,v$/ 0 0 0
639 0 ▶ return if /\.(git|svn)/; # skip .git
Branch: 1 branch
BranchTrueFalseTotal
if /\.(git|svn)/ 0 0 0
640 0 ▶ return if m{\.swp$}; # vim swap files
Branch: 1 branch
BranchTrueFalseTotal
if /\.swp$/ 0 0 0
641  
642 0 my $src = File::Spec->catfile( $File::Find::dir , $_ );
643  
644 0 my $target;
645 0 ( $target = $src ) =~ s{^$base_prefix/}{};
646 0 $target = File::Spec->catfile( $prefix , $target );
647  
648 0 $install{ $src } = $target;
649 0 print "Added $src to file list\n";
650 0 } , grep { -e $_ } @search_dir );
651 0 return \%install;
652 }
653  
654  
655 # XXX:
656 # parse version from vim runtime path files
657 # neeed to find a way to do it
658 0 ▶sub parse_version {
Subroutine parse_version: not called CC=1 SCAR=0.0
Pod undocumented
659  
660 }
661  
662 0 ▶sub vim_version_info {
Subroutine vim_version_info: not called CC=2 SCAR=17.9
Pod undocumented
663  
664 # check_vim_version
665 0 my $where_is_vim = findbin('vim');
666 0 ▶ unless( $where_is_vim ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($where_is_vim) 0 0 0
667 0 print STDOUT "It seems you dont have vim installed.";
668 0 die;
669 }
670  
671 0 my $version_output = qx{$where_is_vim --version};
672 0 my @lines = split /\n/, $version_output;
673  
674 0 my ( $version, $date_string )
675 = $lines[ 0 ] =~ /^VIM - Vi IMproved ([0-9.]+) \((.*?)\)/;
676  
677 0 my ( $revision_date, $compiled_time ) = split /,/, $date_string;
678  
679 0 $compiled_time =~ s/\s*compiled\s*//;
680 0 $compiled_time = DateTime::Format::DateParse->parse_datetime($compiled_time);
681  
682 0 my ($platform) = $lines[ 1 ] =~ /^(.*?) version/;
683  
684 # Included patches: 1-264
685 0 my ( $patch_from, $patch_to )
686 = $lines[ 2 ] =~ /^Included patches: (\d+)-(\d+)$/;
687  
688 # Compiled by [who]
689 0 my ($compiled_by) = $lines[ 3 ] =~ /^Compiled by (.*?)$/;
690  
691 return {
692 0 version => $version,
693 platform => $platform,
694 compiled_on => $compiled_time,
695 patch_from => $patch_from,
696 patch_to => $patch_to,
697 compiled_by => $compiled_by
698 };
699 }
700  
701 0 ▶sub check_manifest {
Subroutine check_manifest: not called CC=2 SCAR=17.9
Pod undocumented
702 0 print STDOUT "Checking if your kit is complete...\n";
703 0 require ExtUtils::Manifest;
704 # avoid warning
705 0 $ExtUtils::Manifest::Quiet = $ExtUtils::Manifest::Quiet = 1;
706 0 my(@missed) = ExtUtils::Manifest::manicheck();
707 0 ▶ if (@missed) {
Branch: 1 branch
BranchTrueFalseTotal
if (@missed) { } 0 0 0
708 0 print STDOUT "Warning: the following files are missing in your kit:\n";
709 0 print "\t", join "\n\t", @missed;
710 0 print STDOUT "\n";
711 0 print STDOUT "Please inform the author.\n";
712 } else {
713 0 print STDOUT "Looks good\n";
714 }
715 }
716  
717 0 ▶sub prompt ($;$) { ## no critic
Subroutine prompt: not called CC=13 SCAR=52.0
Pod undocumented
718 0 my($mess, $def) = @_;
719 0 ▶ Carp::confess("prompt function called without an argument")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mess 0 0 0
720 unless defined $mess;
721  
722 0 ▶ my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;
Condition0%0/9
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
!ll&&!rl&&r
000
-t STDOUT or not -f STDOUT || -c STDOUT
l!l&&r!l&&!r
000
-f STDOUT || -c STDOUT
l!l&&r!l&&!r
000
MC/DC0%0/4
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDIN -t STDOUT -f STDOUT -c STDOUT
Truth table0%0/5
A && B or not(C || D)
A= -t STDINB= -t STDOUTC= -f STDOUTD= -c STDOUT
ABCDresult
0XXX0
101X0
10010
11XX1
10001
723  
724 0 ▶ my $dispdef = defined $def ? "[$def] " : " ";
Branch: 1 branch
BranchTrueFalseTotal
defined $def ? : 0 0 0
725 0 ▶ $def = defined $def ? $def : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $def ? : 0 0 0
726  
727 0 local $|=1;
728 0 local $\;
729 0 print "$mess $dispdef";
730  
731 0 my $ans;
732 0 ▶ if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERL_MM_USE_DEFAULT'} or not $isa_tty and eof STDIN) { } 0 0 0
Condition0%0/6
$ENV{"PERL_MM_USE_DEFAULT"} or not $isa_tty and eof STDIN
l!l&&r!l&&!r
000
not $isa_tty and eof STDIN
!ll&&!rl&&r
000
MC/DC0%0/3
$ENV{"PERL_MM_USE_DEFAULT"} or not $isa_tty and eof STDIN
$ENV{"PERL_MM_USE_DEFAULT"} not $isa_tty eof STDIN
Truth table0%0/4
A or not(B) and C
A= $ENV{"PERL_MM_USE_DEFAULT"}B= not $isa_ttyC= eof STDIN
ABCresult
1XX1
0111
00X0
0100
733 0 print "$def\n";
734 }
735 else {
736 0 $ans = <STDIN>;
737 0 ▶ if( defined $ans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ans) { } 0 0 0
738 0 chomp $ans;
739 }
740 else { # user hit ctrl-D
741 0 print "\n";
742 }
743 }
744  
745 0 ▶ return (!defined $ans || $ans eq '') ? $def : $ans;
Branch: 1 branch
BranchTrueFalseTotal
!defined($ans) || $ans eq '' ? : 0 0 0
Condition0%0/3
not defined $ans or $ans eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $ans or $ans eq ""
not defined $ans $ans eq ""
Truth table0%0/3
not(A) or B
A= not defined $ansB= $ans eq ""
ABresult
1X1
011
000
746 }
747  
748 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
749 0 ▶sub find_perl {
Subroutine find_perl: not called CC=4 SCAR=30.0
Pod undocumented
750 0 my @paths = split /:/,$ENV{PATH};
751 0 my @names = qw(perl);
752 0 for my $path ( @paths ) {
753 0 for my $name ( @names ) {
754 0 my $abspath = File::Spec->join( $path , $name );
755 0 ▶ return $abspath if -e $abspath;
Branch: 1 branch
BranchTrueFalseTotal
if -e $abspath 0 0 0
756 }
757 }
758 0 return undef;
759 }
760  
761  
762 1 1;
↑ Summary blib/lib/VIM/Packager/Manifest.pm »