| 1 | package Liveman::Append; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use File::Spec qw//; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use File::Slurper qw/read_text write_text/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use File::Find::Wanted qw/find_wanted/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Term::ANSIColor qw/colored/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Text::Trim qw/trim/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Конструктор | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | my $cls = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | my $self = bless {@_}, $cls; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | delete $self->{files} if $self->{files} && !scalar @{$self->{files}}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"files"} and not scalar @{$self->{"files"};}
MC/DC0%0/2
$self->{"files"} and not scalar @{$self->{"files"};}
$self->{"files"}
not scalar @{$self->{"files"};}
Truth table33%1/3
A and not(B)
A= $self->{"files"}B= not scalar @{$self->{"files"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | $self | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Пакет из пути | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | sub _pkg($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pkg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | my ($pkg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | my @pkg = File::Spec->splitdir($pkg); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | shift @pkg; # Удаляем lib/ | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | $pkg[$#pkg] =~ s!\.\w+$!!; # Удаляем расширение | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | join "::", @pkg | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Переменная из пакета | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub _var($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_var: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | '$' . lcfirst( shift =~ /(::|^)(\w+)$/? $2: () ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Добавляет точку в конец комментария | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | sub _add_dot_in_remark($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_dot_in_remark: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $_[0] =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | $_[0] =~ s/$/./ if $_[0] !~ /[.?!…]$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Для метода для вставки | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub _md_method(@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_md_method: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my ($pkg, $sub, $args, $remark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my $sub_args = "$sub ($args)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $args = "($args)" if $args; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | _add_dot_in_remark $remark; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my $var = _var $pkg; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | << "END"; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | ## $sub_args | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $remark | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ```perl | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | my $var = $pkg->new; | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $var\->$sub$args # -> .3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # Для фичи для вставки | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _md_feature(@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_md_feature: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my ($pkg, $has, $remark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | _add_dot_in_remark $remark; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $var = _var $pkg; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | << "END"; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | ## $has | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | $remark | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Добавить разделы функций в *.md из *.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub appends { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
appends: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my $files = $self->{files} // [ find_wanted(sub { /\.pm$/ && -f }, "lib") ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
Condition0%0/2
$self->{"files"} // [find_wanted(sub {
/\.pm$/u and -f $_;
}
, "lib")]
MC/DC0%0/1
$self->{"files"} // [find_wanted(sub {
/\.pm$/u and -f $_;
}
, "lib")]
$self->{"files"}
Truth table0%0/2
A
A= $self->{"files"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $self->append($_) for @$files; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # Добавить разделы функций в *.md из *.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | sub append { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append: called CC=21 SCAR=37.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my ($self, $pm) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $md = $pm =~ s!(\.\w+)?$!.md!r; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | die "Not file $pm!" if !-f $pm; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | $self->mkmd($md) if !-f $md; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | local $_ = read_text $pm; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | my %sub; my %has; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | while(m! (^\# [\ \t]* (?<remark> .*?) [\ \t]* )? \n ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sub \s+ (?<sub> (\w+|::)+ ) .* | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ( \s* my \s* \( \s* (\$self,? \s* )? (?<args>.*?) \s* \) \s* = \s* \@_; )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | | has \s+ (?<has> (\w+|'\w+'|"\w+"|\[ \s* ([^\[\]]*?) \s* \])+ ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ) !mgxn) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | for my $key (qw/has sub/) { | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | ($key eq "has"? \%has: \%sub)->{$+{$key}} = {%+, pos => length $`} | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 12 | ▶ | if exists $+{$key} and "_" ne substr $+{$key}, 0, 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
exists $+{$key} and "_" ne substr($+{$key}, 0, 1)
MC/DC100%2/2
exists $+{$key} and "_" ne substr($+{$key}, 0, 1)
exists $+{$key}
"_" ne substr($+{$key}, 0, 1)
Truth table100%3/3
A and B
A= exists $+{$key}B= "_" ne substr($+{$key}, 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | return $self if !keys %sub && !keys %has; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
keys %sub or keys %has
MC/DC0%0/2
keys %sub or keys %has
keys %sub
keys %has
Truth table33%1/3
A or B
A= keys %subB= keys %has
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $_ = read_text $md; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | my $pkg = _pkg $md; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | my $added = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | my $add = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | $added += keys %sub; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | join "", @_, map { _md_method $pkg, $_, $sub{$_}{args}, $sub{$_}{remark} } sort { $sub{$a}{pos} <=> $sub{$b}{pos} } keys %sub | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | s{^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) }{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
keys %sub && (s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsux || s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u || die("\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"))
s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsux or s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u or die "\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"
s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsux or s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u
MC/DC0%0/3
keys %sub && (s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsux || s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u || die("\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"))
keys %sub
s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsux
s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u
Truth table0%0/4
A && B or C
A= keys %subB= s[^\#[\ \t]+ (METHODS|SUBROUTINES) (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $sub{$1};
};
&$add($x);]emsuxC= s[^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) ][\n\t\t$add->($&, "# SUBROUTINES/METHODS\n\n")\n\t]u
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | my $x = $&; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | while($x =~ /^##[ \t]+(\w+)/gm) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | delete $sub{$1}; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | $add->($x) | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | }emsx | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | or s{^#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) }{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | $add->($&, "# SUBROUTINES/METHODS\n\n") | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } or die "Нет секции DESCRIPTION!" if keys %sub; | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $add = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $added += keys %has; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | join "", @_, map { _md_feature $pkg, $_, $has{$_}{remark} } sort { $has{$a}{pos} <=> $has{$b}{pos} } keys %has | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | s{^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) }{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition12%1/8
keys %has && (s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsux || s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux || die("\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"))
s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsux or s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux or die "\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"
s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsux or s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux
MC/DC0%0/3
keys %has && (s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsux || s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux || die("\x{41d}\x{435}\x{442} \x{441}\x{435}\x{43a}\x{446}\x{438}\x{438} DESCRIPTION!"))
keys %has
s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsux
s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux
Truth table0%0/4
A && B or C
A= keys %hasB= s[^\#[\ \t]+ FEATURES (^```.*?^```|.)*? (?= ^\#\s) ][my $x = $&;
while ($x =~ /^##[ \t]+(\w+)/gmu) {
delete $has{$1};
};
&$add($x);]emsuxC= s/^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) /&$add($&, "# FEATURES\n\n");/emsux
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $x = $&; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | while($x =~ /^##[ \t]+(\w+)/gm) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | delete $has{$1}; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $add->($x) | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | }emsx | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | or s{^\#[\ \t]+ DESCRIPTION (^```.*?^```|.)*? (?= ^\#\s) }{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $add->($&, "# FEATURES\n\n") | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | }emsx or die "Нет секции DESCRIPTION!" if keys %has; | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | if ($added) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | write_text $md, $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | print "🔖 $pm ", colored("⊂", "BRIGHT_GREEN"), " $md ", "\n", | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | " ", scalar keys %has? (colored("FEATURES ", "BRIGHT_WHITE"), join(colored(", ", "red"), sort keys %has), "\n"): (), | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | " ", scalar keys %sub? (colored("SUBROUTINES ", "BRIGHT_WHITE"), join(colored(", ", "red"), sort keys %sub), "\n"): (), | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ; | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | print "🔖 $pm\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | $self->{count}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | $self->{added} = $added; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $self | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub _git_user_name { shift->{_git_user_name} //= trim(`git config user.name`) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_user_name: not called CC=2 SCAR=17.9
Condition0%0/3
+(shift())->{"_git_user_name"} //= trim(`git config user.name`)
MC/DC0%0/2
+(shift())->{"_git_user_name"} //= trim(`git config user.name`)
+(shift())->{"_git_user_name"}
trim(`git config user.name`)
Truth table0%0/3
A //= B
A= +(shift())->{"_git_user_name"}B= trim(`git config user.name`)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub _git_user_email { shift->{_git_user_email} //= trim(`git config user.email`) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_user_email: not called CC=2 SCAR=17.9
Condition0%0/3
+(shift())->{"_git_user_email"} //= trim(`git config user.email`)
MC/DC0%0/2
+(shift())->{"_git_user_email"} //= trim(`git config user.email`)
+(shift())->{"_git_user_email"}
trim(`git config user.email`)
Truth table0%0/3
A //= B
A= +(shift())->{"_git_user_email"}B= trim(`git config user.email`)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub _year { shift->{_year} //= trim(`date +%Y`) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_year: not called CC=2 SCAR=17.9
Condition0%0/3
+(shift())->{"_year"} //= trim(`date +%Y`)
MC/DC0%0/2
+(shift())->{"_year"} //= trim(`date +%Y`)
+(shift())->{"_year"}
trim(`date +%Y`)
Truth table0%0/3
A //= B
A= +(shift())->{"_year"}B= trim(`date +%Y`)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub _license { shift->{_license} //= -r "minil.toml" && read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/m ? ($1 eq "perl_5"? "Perl5": uc($1) =~ s/_/v/r): "Perl5" } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_license: not called CC=5 SCAR=34.0
Branch: 2 branches
Condition0%0/6
+(shift())->{"_license"} //= -r "minil.toml" && read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/mu ? $1 eq "perl_5" ? "Perl5" : uc($1) =~ s/_/v/ru : "Perl5"
-r "minil.toml" and read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/mu
MC/DC0%0/3
+(shift())->{"_license"} //= -r "minil.toml" && read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/mu ? $1 eq "perl_5" ? "Perl5" : uc($1) =~ s/_/v/ru : "Perl5"
+(shift())->{"_license"}
-r "minil.toml"
read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/mu
Truth table0%0/4
A //= B and C
A= +(shift())->{"_license"}B= -r "minil.toml"C= read_text("minil.toml") =~ /^\s*license\s*=\s*"([^"\n]*)"/mu
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub _land { shift->{_land} //= `curl "https://ipapi.co/\$(curl https://2ip.ru --connect-timeout 3 --max-time 3 -Ss)/json/" --connect-timeout 3 --max-time 3 -Ss` =~ /country_name": "([^"\n]*)"/ ? ($1 eq "Russia" ? "Rusland" : $1) : 'Rusland' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_land: not called CC=4 SCAR=30.0
Branch: 2 branches
Condition0%0/3
+(shift())->{"_land"} //= `curl "https://ipapi.co/\$(curl https://2ip.ru --connect-timeout 3 --max-time 3 -Ss)/json/" --connect-timeout 3 --max-time 3 -Ss` =~ /country_name": "([^"\n]*)"/u ? $1 eq "Russia" ? "Rusland" : $1 : "Rusland"
MC/DC0%0/2
+(shift())->{"_land"} //= `curl "https://ipapi.co/\$(curl https://2ip.ru --connect-timeout 3 --max-time 3 -Ss)/json/" --connect-timeout 3 --max-time 3 -Ss` =~ /country_name": "([^"\n]*)"/u ? $1 eq "Russia" ? "Rusland" : $1 : "Rusland"
+(shift())->{"_land"}
`curl "https://ipapi.co/\$(curl https://2ip.ru --connect-timeout 3 --max-time 3 -Ss)/json/" --connect-timeout 3 --max-time 3 -Ss` =~ /country_name": "([^"\n]*)"/u ? $1 eq "Russia" ? "Rusland" : $1 : "Rusland"
Truth table0%0/3
A //= B
A= +(shift())->{"_land"}B= `curl "https://ipapi.co/\$(curl https://2ip.ru --connect-timeout 3 --max-time 3 -Ss)/json/" --connect-timeout 3 --max-time 3 -Ss` =~ /country_name": "([^"\n]*)"/u ? $1 eq "Russia" ? "Rusland" : $1 : "Rusland"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # Добавить разделы функций в *.md из *.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | sub mkmd { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkmd: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | my ($self, $md) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | my $pkg = _pkg $md; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | my $author = $self->_git_user_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my $email = $self->_git_user_email; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | my $year = $self->_year; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | my $license = $self->_license; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | my $land = $self->_land; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | write_text $md, << "END"; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | # NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $pkg - | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ```perl | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | use $pkg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | my ${\_var $pkg} = $pkg->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | . | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # SUBROUTINES | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $author <$email> | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ⚖ **$license** | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | The $pkg module is copyright © $year $author. $land. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||