blib/lib/Sort/Sub/by_example.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 82.5% 33 / 40 CC 4 SCAR 9.2
CC
4
Cov
88%
gen_sorter
4.1
meta
2.0
BEGIN
1.0
CRAP 2.5
↑ Summary
1 package Sort::Sub::by_example;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 2 our $DATE = '2025-01-12'; # DATE
10 2 our $DIST = 'Sort-Sub-by_example'; # DIST
11 2 our $VERSION = '0.005'; # VERSION
12  
13 0 ▶sub meta {
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
14 return {
15 0 v => 1,
16 summary => 'Sort by example',
17 args => {
18 example => {
19 summary => 'Either an arrayref or comma-separated string',
20 schema => ['any' => {of=>['array*', 'str*']}],
21 req => 1,
22 pos => 0,
23 },
24 },
25 };
26 }
27  
28 2 ▶sub gen_sorter {
Subroutine gen_sorter: called CC=4 SCAR=14.2
Pod undocumented
29 2 require Sort::ByExample;
30  
31 2 my ($is_reverse, $is_ci, $args) = @_;
32  
33 my $example = ref $args->{example} eq 'ARRAY' ?
34 0 ▶ [@{$args->{example}}] : [split /\s*,\s*/, $args->{example}];
Branch: 1 branch
BranchTrueFalseTotal
ref $args->{'example'} eq 'ARRAY' ? : 0 2 2
35 2 ▶ $example = [map {lc} @$example] if $is_ci;
Branch: 1 branch
BranchTrueFalseTotal
if $is_ci 1 1 2
36 2 ▶ $example = [reverse @$example] if $is_reverse;
Branch: 1 branch
BranchTrueFalseTotal
if $is_reverse 0 2 2
37  
38 2 log_trace "example=%s", $example;
39  
40 2 my $cmp = Sort::ByExample->cmp($example);
41 #use Data::Dmp; dd $cmp
42 }
43  
44 2 1;
45 # ABSTRACT: Sort by example
46  
47 __END__
↑ Summary