blib/lib/Liveman/MinillaPod2Markdown.pm

filter: Statementstmt 55.8% 38 / 68 Branchbran 23.0% 6 / 26 Conditioncond 31.2% 5 / 16 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 80.0% 8 / 10 Podpod 100% 8 / 8 totaltotal 47.7% 65 / 136 CC 21 SCAR 30.7
CC
21
Cov
45%
parse_options
56.0
github_path
30.0
as_markdown
12.0
CRAP 21.6
« blib/lib/Liveman/Project.pm ↑ Summary blib/lib/Liveman/Append.pm »
1 package Liveman::MinillaPod2Markdown;
2 # Обманка для Minilla, чтобы скопировать Module в README.md
3  
4 4 ▶use parent qw/Pod::Markdown/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use File::Slurper qw/read_text write_text/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶sub new { bless {}, __PACKAGE__ }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
9  
10 1 ▶sub parse_from_file {
Subroutine parse_from_file: called CC=1 SCAR=0.0
Pod documented
11 1 my ($self, $path) = @_;
12 1 $self->{pm_path} = $path;
13 1 $self->{md_path} = $path =~ s!\.\w+$!.md!r;
14 1 $self->{name} = ($path =~ s!^lib/(.*)\.\w+$!$1!r) =~ s!/!-!gr;
15 1 $self
16 }
17  
18 1 ▶sub as_markdown {
Subroutine as_markdown: called CC=7 SCAR=24.9
Pod documented
19 1 my ($self) = @_;
20  
21 1 my $md = $self->read_md;
22 1 my $pm = $self->read_pm;
23  
24 1 my $pm_version = $self->pm_version;
25 1 my $v = uc "version";
26 1 my ($md_version) = $md =~ /^#[ \t]+$v\s+([\w.-]{1,32})\s/m;
27 1 my ($hd_version) = $pm =~ /^=head1[ \t]+VERSION\s+([\w.-]{1,32})\s/m;
28  
29 1 ▶ if(defined $pm_version and defined $md_version and $pm_version ne $md_version) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pm_version and defined $md_version and $pm_version ne $md_version) 0 1 1
Condition33%2/6
defined $pm_version and defined $md_version and $pm_version ne $md_version
!ll&&!rl&&r
100
defined $pm_version and defined $md_version
!ll&&!rl&&r
010
MC/DC0%0/3
defined $pm_version and defined $md_version and $pm_version ne $md_version
defined $pm_version defined $md_version $pm_version ne $md_version
Truth table25%1/4
A and B and C
A= defined $pm_versionB= defined $md_versionC= $pm_version ne $md_version
ABCresult
0XX0
10X0
1100
1111
30 0 $md =~ s/(#[ \t]+$v\s+)[\w.-]{1,32}(\s)/$1$pm_version$2/;
31 0 write_text $self->{md_path}, $md;
32 }
33  
34 1 ▶ if(defined $pm_version and defined $hd_version and $pm_version ne $hd_version) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pm_version and defined $hd_version and $pm_version ne $hd_version) 0 1 1
Condition33%2/6
defined $pm_version and defined $hd_version and $pm_version ne $hd_version
!ll&&!rl&&r
100
defined $pm_version and defined $hd_version
!ll&&!rl&&r
010
MC/DC0%0/3
defined $pm_version and defined $hd_version and $pm_version ne $hd_version
defined $pm_version defined $hd_version $pm_version ne $hd_version
Truth table25%1/4
A and B and C
A= defined $pm_versionB= defined $hd_versionC= $pm_version ne $hd_version
ABCresult
0XX0
10X0
1100
1111
35 0 $pm =~ s/^(=head1[ \t]+VERSION\s+)[\w.-]{1,32}(\s)/$1$pm_version$2/m;
36 0 write_text $self->{pm_path}, $pm;
37 }
38  
39 0 $md =~ s/^!\w+:\w+(,\w+)*\s+/$self->parse_options($&)/e;
40  
41 1 $md
42 }
43  
44 4 my @badges = qw/github-actions github-issues metacpan cover/;
45  
46 # parse !options on first line
47 0 ▶sub parse_options {
Subroutine parse_options: not called CC=7 SCAR=40.3
Pod documented
48 0 my ($self, $options) = @_;
49
50 0 $options =~ s/^!//;
51 0 $options =~ s/\s*$//;
52 0 $options =~ s/^\w+:\w+,?//;
53 0 ▶ my @options = map { $_ eq "badges"? @badges: $_ } split /,/, $options;
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'badges' ? : 0 0 0
54
55 $options = join " ", map {
56 0 ▶ if($_ eq 'github-actions') {
Branch: 4 branches
BranchTrueFalseTotal
if ($_ eq 'github-actions') { } 0 0 0
elsif ($_ eq 'github-issues') { } 0 0 0
elsif ($_ eq 'metacpan') { } 0 0 0
elsif ($_ eq 'cover') { } 0 0 0
57 0 my $github = $self->github_path;
58 0 "[![Actions Status](https://github.com/$github/actions/workflows/test.yml/badge.svg)](https://github.com/$github/actions)"
59 }
60 elsif($_ eq 'github-issues') {
61 0 my $github = $self->github_path;
62 0 "[![GitHub Issues](https://img.shields.io/github/issues/$github?logo=perl)](https://github.com/$github/issues)";
63 }
64 elsif($_ eq 'metacpan') {
65 0 my $name = $self->{name};
66 0 "[![MetaCPAN Release](https://badge.fury.io/pl/$name.svg)](https://metacpan.org/release/$name)";
67 }
68 elsif($_ eq 'cover') {
69 0 my $github = $self->github_path;
70 0 my $name = $self->{name};
71 0 my $version = $self->pm_version;
72 0 "[![Coverage](https://raw.githubusercontent.com/$github/master/doc/badges/total.svg)](https://fast2-matrix.cpantesters.org/?dist=$name+$version)";
73 }
74 # elsif ($_ eq 'kwalitee') {
75 # "[![Kwalitee](https://cpants.cpanauthors.org/release/DART/Liveman-3.2.svg)";
76 # }
77 0 else { () }
78 } @options;
79
80 0 ▶ $options? "$options\n": ""
Branch: 1 branch
BranchTrueFalseTotal
$options ? : 0 0 0
81 }
82  
83 # path project on github
84 0 ▶sub github_path {
Subroutine github_path: not called CC=5 SCAR=34.0
Pod documented
85 0 my ($self) = @_;
86 0 ▶ return $self->{github_path} if exists $self->{github_path};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"github_path"} 0 0 0
87 0 for my $r (split /\n/, `git remote -v`) {
88 0 ▶ $self->{github_path} = $1, last if $r =~ m!git\@github\.com:(.*?)\.git!;
Branch: 1 branch
BranchTrueFalseTotal
if $r =~ /git\@github\.com:(.*?)\.git/ 0 0 0
89 }
90 0 ▶ $self->{github_path} //= "???";
Condition0%0/2
$self->{"github_path"} //= "???"
l!l
00
MC/DC0%0/1
$self->{"github_path"} //= "???"
$self->{"github_path"}
Truth table0%0/2
A
A= $self->{"github_path"}
Aresult
11
00
91 }
92  
93 1 ▶sub read_md {
Subroutine read_md: called CC=2 SCAR=7.0
Pod documented
94 1 my ($self) = @_;
95 1 ▶ return $self->{read_md} if exists $self->{read_md};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"read_md"} 0 1 1
96 1 $self->{read_md} = read_text($self->{md_path});
97 $self->{read_md}
98 1 }
99  
100 2 ▶sub read_pm {
Subroutine read_pm: called CC=2 SCAR=6.9
Pod documented
101 2 my ($self) = @_;
102 2 ▶ return $self->{read_pm} if exists $self->{read_pm};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"read_pm"} 1 1 2
103 1 $self->{read_pm} = read_text($self->{pm_path});
104 $self->{read_pm}
105 1 }
106  
107 1 ▶sub pm_version {
Subroutine pm_version: called CC=3 SCAR=11.3
Pod documented
108 1 my ($self) = @_;
109 1 ▶ return $self->{pm_version} if exists $self->{pm_version};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"pm_version"} 0 1 1
110 1 my $v = uc "version";
111 1 ($self->{pm_version}) = $self->read_pm =~ /^our\s+\$$v\s*=\s*["']?([\w.-]{1,32})/m;
112 1 ▶ $self->{pm_version} //= '???';
Condition50%1/2
$self->{"pm_version"} //= "???"
l!l
10
MC/DC0%0/1
$self->{"pm_version"} //= "???"
$self->{"pm_version"}
Truth table50%1/2
A
A= $self->{"pm_version"}
Aresult
11
00
113 }
114  
115  
116 4 1;
117  
118 __END__
« blib/lib/Liveman/Project.pm ↑ Summary blib/lib/Liveman/Append.pm »