Role/ModuleInfo.pm

filter: Statementstmt 100% 31 / 31 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 95.2% 40 / 42 CC 2 SCAR 2.2
CC
2
Cov
97%
get_module_info
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Plugin/VersionFromModule.pm ↑ Summary
1 #---------------------------------------------------------------------
2 package Dist::Zilla::Role::ModuleInfo;
3 #
4 # Copyright 2010 Christopher J. Madsen
5 #
6 # Author: Christopher J. Madsen <perl@cjmweb.net>
7 # Created: 25 Sep 2009
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
15 # GNU General Public License or the Artistic License for more details.
16 #
17 # ABSTRACT: Create Module::Metadata object from Dist::Zilla::File
18 #---------------------------------------------------------------------
19  
20 3 our $VERSION = '6.000';
21 # This file is part of Dist-Zilla-Plugins-CJM 6.000 (December 17, 2017)
22  
23 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 3 ▶use autodie ':io';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 3 ▶use File::Temp 0.19 (); # need newdir
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use Module::Metadata ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28 3 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30  
31 sub get_module_info
32 36 ▶{
Subroutine get_module_info: called CC=2 SCAR=6.9
Pod documented
33 36 my $self = shift;
34 36 my $file = shift;
35 # Any additional parameters get passed to M::Metadata->new_from_file
36  
37 # To be safe, reset the global variables controlling IO to their defaults:
38 36 local ($/, $,, $\) = "\n";
39  
40 # Module::Metadata doesn't have a new_from_string method,
41 # so we'll write the current contents to a temporary file:
42  
43 36 my $tempdirObject = File::Temp->newdir();
44 36 my $dir = Path::Tiny::path("$tempdirObject");
45 36 my $modPath = Path::Tiny::path($file->name);
46  
47 # Module::Metadata only cares about the basename of the file:
48 36 my $tempname = $dir->child($modPath->basename);
49  
50 36 open(my $temp, '>:raw', $tempname);
51 36 print $temp $file->encoded_content;
52 36 close $temp;
53  
54 36 ▶ return(Module::Metadata->new_from_file("$tempname", @_)
Condition50%1/2
'Module::Metadata'->new_from_file("$tempname", @_) || die('Unable to get module info from ' . $file->name . "\n")
l!l
360
MC/DC0%0/1
'Module::Metadata'->new_from_file("$tempname", @_) || die('Unable to get module info from ' . $file->name . "\n")
'Module::Metadata'->new_from_file("$tempname", @_)
Truth table50%1/2
A
A= 'Module::Metadata'->new_from_file("$tempname", @_)
Aresult
11
00
55 or die "Unable to get module info from " . $file->name . "\n");
56 } # end get_module_info
57  
58 3 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 3 1;
60  
61 __END__
« Plugin/VersionFromModule.pm ↑ Summary