| 1 | package Data::Sah::Coerce::perl::To_bool::From_str::common_words; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use 5.010001; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||
| 8 | 3 | our $DATE = '2023-10-24'; # DATE | |||||||||||||||||||
| 9 | 3 | our $DIST = 'Data-Sah-Coerce'; # DIST | |||||||||||||||||||
| 10 | 3 | our $VERSION = '0.054'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 4 | ▶ | sub meta { | ||||||||||||||||||
|
Subroutine
meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 13 | +{ | ||||||||||||||||||||
| 14 | 4 | v => 4, | |||||||||||||||||||
| 15 | summary => 'Convert common true/false words (e.g. "yes","true","on","1" to "1", and "no","false","off","0" to "")', | ||||||||||||||||||||
| 16 | prio => 50, | ||||||||||||||||||||
| 17 | args => { | ||||||||||||||||||||
| 18 | # mostly for testing of args | ||||||||||||||||||||
| 19 | ci => { | ||||||||||||||||||||
| 20 | schema => 'bool*', | ||||||||||||||||||||
| 21 | default => 1, | ||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 4 | ▶ | sub coerce { | ||||||||||||||||||
|
Subroutine
coerce: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||
| 28 | 4 | my %cargs = @_; | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 4 | my $dt = $cargs{data_term}; | |||||||||||||||||||
| 31 | 4 | ▶ | my $gen_args = $cargs{args} // {}; | ||||||||||||||||||
|
Condition100%2/2
$cargs{"args"} // {}
MC/DC100%1/1
$cargs{"args"} // {}
$cargs{"args"}
Truth table100%2/2
A
A= $cargs{"args"}
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 4 | my $res = {}; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 4 | $res->{expr_match} = join( | |||||||||||||||||||
| 36 | " && ", | ||||||||||||||||||||
| 37 | "1", | ||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 4 | ▶ | my $modifier = ($gen_args->{ci} // 1) ? "i" : ""; | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$gen_args->{"ci"} // 1
MC/DC100%1/1
$gen_args->{"ci"} // 1
$gen_args->{"ci"}
Truth table100%2/2
A
A= $gen_args->{"ci"}
| |||||||||||||||||||||
| 41 | 4 | $res->{expr_coerce} = "$dt =~ /\\A(yes|true|on)\\z/$modifier ? 1 : $dt =~ /\\A(no|false|off|0)\\z/$modifier ? '' : $dt"; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 4 | $res; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 3 | 1; | |||||||||||||||||||
| 47 | # ABSTRACT: Convert common true/false words (e.g. "yes","true","on","1" to "1", and "no","false","off","0" to "") | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||