| 1 | package Minilla::Profile::Base; | ||||||||||||||||||||
| 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 | 1 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use File::Spec::Functions qw(catfile); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use File::Path qw(mkpath); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use Data::Section::Simple; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | use Time::Piece; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | use Minilla::Util qw(spew_raw); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use Minilla::Logger; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | has [qw(dist path module)] => ( | |||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||
| 18 | required => 1, | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | has 'version' => ( | ||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||
| 23 | 0 | ▶ | default => sub { '0.01' }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 24 | 1 | ); | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | has suffix => ( | |||||||||||||||||||
| 27 | is => 'lazy', | ||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | has [qw(email author)] => ( | |||||||||||||||||||
| 32 | is => 'lazy', | ||||||||||||||||||||
| 33 | required => 1, | ||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | ▶ | no Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub _build_author { | ||||||||||||||||||
|
Subroutine
_build_author: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | my $name ||= `git config user.name`; | ||||||||||||||||||
|
Condition0%0/3
my $name ||= `git config user.name`
MC/DC0%0/2
my $name ||= `git config user.name`
my $name
`git config user.name`
Truth table0%0/3
A ||= B
A= my $nameB= `git config user.name`
| |||||||||||||||||||||
| 42 | 0 | $name =~ s/\n$//; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | unless ($name) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | errorf("You need to set user.name in git config.\nRun: git config user.name 'Your name'\n"); | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | $name; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub _build_email { | ||||||||||||||||||
|
Subroutine
_build_email: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | my $email ||= `git config user.email`; | ||||||||||||||||||
|
Condition0%0/3
my $email ||= `git config user.email`
MC/DC0%0/2
my $email ||= `git config user.email`
my $email
`git config user.email`
Truth table0%0/3
A ||= B
A= my $emailB= `git config user.email`
| |||||||||||||||||||||
| 55 | 0 | $email =~ s/\n$//; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | ▶ | unless ($email) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 0 | errorf("You need to set user.email in git config.\nRun: git config user.email 'name\@example.com'\n"); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | $email; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | ▶ | sub _build_suffix { | ||||||||||||||||||
|
Subroutine
_build_suffix: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||||||||||
| 66 | 0 | my $suffix = $self->path; | |||||||||||||||||||
| 67 | 0 | $suffix =~ s!^.+/!!; | |||||||||||||||||||
| 68 | 0 | $suffix =~ s!\.pm!!; | |||||||||||||||||||
| 69 | 0 | $suffix; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub new_from_project { | ||||||||||||||||||
|
Subroutine
new_from_project: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 73 | 0 | my ($class, $project) = @_; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | my $path = $project->main_module_path; | |||||||||||||||||||
| 76 | 0 | $path =~ s!^lib/!!; | |||||||||||||||||||
| 77 | 0 | ▶ | my $self = $class->new( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | dist => $project->dist_name, | ||||||||||||||||||||
| 79 | author => $project->authors ? $project->authors->[0] : 'Unknown Author', | ||||||||||||||||||||
| 80 | version => $project->version, | ||||||||||||||||||||
| 81 | path => $path, | ||||||||||||||||||||
| 82 | module => $project->name, | ||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||
| 84 | 0 | return $self; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 0 | ▶ | sub date { | ||||||||||||||||||
|
Subroutine
date: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 88 | 0 | gmtime->strftime('%Y-%m-%dT%H:%M:%SZ'); | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | sub end { '__END__' } | ||||||||||||||||||
|
Subroutine
end: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | sub module_pm_src { '' } | ||||||||||||||||||
|
Subroutine
module_pm_src: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 0 | ▶ | sub render { | ||||||||||||||||||
|
Subroutine
render: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 96 | 0 | my ($self, $tmplname, $dst) = @_; | |||||||||||||||||||
| 97 | 0 | ▶ | my $path = $dst || $tmplname; | ||||||||||||||||||
|
Condition0%0/3
$dst || $tmplname
MC/DC0%0/2
$dst || $tmplname
$dst
$tmplname
Truth table0%0/3
A || B
A= $dstB= $tmplname
| |||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | infof("Writing %s\n", $path); | |||||||||||||||||||
| 100 | 0 | mkpath(dirname($path)); | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | ▶ | for my $pkg (@{mro::get_linear_isa(ref $self || $self)}) { | ||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 103 | 0 | my $content = Data::Section::Simple->new($pkg)->get_data_section($tmplname); | |||||||||||||||||||
| 104 | 0 | ▶ | next unless defined $content; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 0 | $content =~ s!<%\s*\$([a-z_]+)\s*%>! | |||||||||||||||||||
| 106 | 0 | $self->$1() | |||||||||||||||||||
| 107 | !ge; | ||||||||||||||||||||
| 108 | 0 | spew_raw($path, $content); | |||||||||||||||||||
| 109 | 0 | return; | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | 0 | errorf("Cannot find template for %s\n", $tmplname); | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 0 | ▶ | sub write_file { | ||||||||||||||||||
|
Subroutine
write_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 115 | 0 | my ($self, $path, $content) = @_; | |||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 0 | infof("Writing %s\n", $path); | |||||||||||||||||||
| 118 | 0 | mkpath(dirname($path)); | |||||||||||||||||||
| 119 | 0 | spew_raw($path, $content); | |||||||||||||||||||
| 120 | } | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | 1 | 1; | |||||||||||||||||||
| 124 | __DATA__ | ||||||||||||||||||||