File Coverage

blib/lib/Sort/Sub/defhash_props.pm
Criterion Covered Total %
statement 8 14 57.1
branch n/a
condition n/a
subroutine 3 7 42.8
pod 0 2 0.0
total 11 23 47.8


line stmt bran cond sub pod time code
1             package Sort::Sub::defhash_props;
2              
3 1     1   409915 use 5.010001;
  1         4  
4 1     1   6 use strict;
  1         2  
  1         60  
5 1     1   10 use warnings;
  1         2  
  1         374  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-01-10'; # DATE
9             our $DIST = 'Sort-SubBundle-DefHash'; # DIST
10             our $VERSION = '0.001'; # VERSION
11              
12             sub meta {
13             return {
14 0     0 0   v => 1,
15             summary => 'Sort DefHash properties and attributes',
16             description => <<'MARKDOWN',
17              
18             Known (standard) properties and attributes are put first, in order of mention in the spec.
19             Then unknown properties/attributes are sorted asciibetically.
20              
21             MARKDOWN
22             };
23             }
24              
25             sub gen_sorter {
26 0     0 0   require Sort::BySpec;
27              
28 0           my ($is_reverse, $is_ci) = @_;
29              
30             Sort::BySpec::cmp_by_spec(
31             spec => [
32             'v',
33              
34             'defhash_v',
35              
36             'name',
37             qr/\Aname\./,
38              
39             'caption',
40             qr/\Acaption\./,
41              
42             # not in spec, but very common
43             'summary',
44             qr/\Asummary\./,
45              
46             'description',
47             qr/\Adescription\./,
48              
49             'tags',
50              
51             'default_lang',
52              
53             'x',
54 0     0     qr/\Ax\./ => sub { $_[0] cmp $_[1] },
55              
56 0     0     qr// => sub { $_[0] cmp $_[1] },
57 0           ],
58             reverse => $is_reverse,
59             );
60             }
61              
62             1;
63             # ABSTRACT: Sort DefHash properties and attributes
64              
65             __END__