| 1 | package App::sort_by_sortkey; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Log::ger; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use AppBase::Sort; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use AppBase::Sort::File (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | use Perinci::Sub::Util qw(gen_modified_sub); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||
| 13 | 1 | our $DATE = '2024-05-15'; # DATE | |||||||||||
| 14 | 1 | our $DIST = 'App-sort_by_sortkey'; # DIST | |||||||||||
| 15 | 1 | our $VERSION = '0.002'; # VERSION | |||||||||||
| 16 | |||||||||||||
| 17 | 1 | our %SPEC; | |||||||||||
| 18 | |||||||||||||
| 19 | gen_modified_sub( | ||||||||||||
| 20 | output_name => 'sort_by_sortkey', | ||||||||||||
| 21 | base_name => 'AppBase::Sort::sort_appbase', | ||||||||||||
| 22 | summary => 'Sort lines of text by a SortKey module', | ||||||||||||
| 23 | description => <<'MARKDOWN', | ||||||||||||
| 24 | |||||||||||||
| 25 | This utility lets you sort lines of text using one of the available SortKey::* | ||||||||||||
| 26 | perl modules. | ||||||||||||
| 27 | |||||||||||||
| 28 | MARKDOWN | ||||||||||||
| 29 | add_args => { | ||||||||||||
| 30 | %AppBase::Sort::File::argspecs_files, | ||||||||||||
| 31 | sortkey_module => { | ||||||||||||
| 32 | schema => "perl::sortkey::modname_with_optional_args", | ||||||||||||
| 33 | pos => 0, | ||||||||||||
| 34 | req => 1, | ||||||||||||
| 35 | }, | ||||||||||||
| 36 | }, | ||||||||||||
| 37 | modify_args => { | ||||||||||||
| 38 | 1 | ▶ | files => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 39 | 1 | my $argspec = shift; | |||||||||||
| 40 | #delete $argspec->{pos}; | ||||||||||||
| 41 | #delete $argspec->{slurpy}; | ||||||||||||
| 42 | }, | ||||||||||||
| 43 | }, | ||||||||||||
| 44 | 1 | ▶ | modify_meta => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 45 | 1 | my $meta = shift; | |||||||||||
| 46 | |||||||||||||
| 47 | $meta->{examples} = [ | ||||||||||||
| 48 | { | ||||||||||||
| 49 | 1 | src_plang => 'bash', | |||||||||||
| 50 | src => q[ someprog ... | sort-by-sortkey Num::length], | ||||||||||||
| 51 | test => 0, | ||||||||||||
| 52 | 'x.doc.show_result' => 0, | ||||||||||||
| 53 | }, | ||||||||||||
| 54 | ]; | ||||||||||||
| 55 | 1 | ▶ | $meta->{links} //= []; | ||||||||||
|
Condition50%1/2
$meta->{"links"} //= []
MC/DC0%0/1
$meta->{"links"} //= []
$meta->{"links"}
Truth table50%1/2
A
A= $meta->{"links"}
| |||||||||||||
| 56 | 1 | push @{ $meta->{links} }, {url=>'pm:SortKey'}; | |||||||||||
| 57 | 1 | push @{ $meta->{links} }, {url=>'prog:sort-by-sorter'}; | |||||||||||
| 58 | 1 | push @{ $meta->{links} }, {url=>'prog:sort-by-comparer'}; | |||||||||||
| 59 | }, | ||||||||||||
| 60 | 0 | ▶ | output_code => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 61 | 0 | require Module::Load::Util; | |||||||||||
| 62 | |||||||||||||
| 63 | 0 | my %oc_args = @_; | |||||||||||
| 64 | |||||||||||||
| 65 | 0 | AppBase::Sort::File::set_source_arg(\%oc_args); | |||||||||||
| 66 | 0 | ▶ | $oc_args{_gen_keygen} = sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 67 | 0 | my $gc_args = shift; | |||||||||||
| 68 | ( | ||||||||||||
| 69 | Module::Load::Util::call_module_function_with_optional_args( | ||||||||||||
| 70 | {ns_prefix=>"SortKey", function=>"gen_keygen"}, | ||||||||||||
| 71 | $gc_args->{sortkey_module}), # elem0: keygen | ||||||||||||
| 72 | 0 | ▶ | ($gc_args->{sortkey_module} =~ /\ANum::/ ? 1:0), # elem1: is_numeric? | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | ); | ||||||||||||
| 74 | 0 | }; | |||||||||||
| 75 | 0 | AppBase::Sort::sort_appbase(%oc_args); | |||||||||||
| 76 | }, | ||||||||||||
| 77 | 1 | ); | |||||||||||
| 78 | |||||||||||||
| 79 | 1 | 1; | |||||||||||
| 80 | # ABSTRACT: Sort lines of text by a SortKey module | ||||||||||||
| 81 | |||||||||||||
| 82 | __END__ | ||||||||||||