| 1 | package Data::Sah::Coerce::perl::To_str::From_str::to_cryptoexchange_safename; | ||||||||||||
| 2 | |||||||||||||
| 3 | # AUTHOR | ||||||||||||
| 4 | 2 | our $DATE = '2019-11-28'; # DATE | |||||||||||
| 5 | 2 | our $DIST = 'Data-Sah-Coerce-perl-To_str-From_str-to_cryptoexchange_safename'; # DIST | |||||||||||
| 6 | 2 | our $VERSION = '0.007'; # VERSION | |||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use 5.010001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 1 | ▶ | sub meta { | ||||||||||
|
Subroutine
meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 13 | +{ | ||||||||||||
| 14 | 1 | v => 4, | |||||||||||
| 15 | summary => 'Coerce string containing cryptoexchange code/name/safename to safename', | ||||||||||||
| 16 | might_fail => 1, | ||||||||||||
| 17 | prio => 50, | ||||||||||||
| 18 | precludes => [qr/\AFrom_str::to_cryptoexchange_(.+)?\z/], | ||||||||||||
| 19 | }; | ||||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | 1 | ▶ | sub coerce { | ||||||||||
|
Subroutine
coerce: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 23 | 1 | my %args = @_; | |||||||||||
| 24 | |||||||||||||
| 25 | 1 | my $dt = $args{data_term}; | |||||||||||
| 26 | |||||||||||||
| 27 | 1 | my $res = {}; | |||||||||||
| 28 | |||||||||||||
| 29 | 1 | $res->{expr_match} = "!ref($dt)"; | |||||||||||
| 30 | 1 | ▶ | $res->{modules}{"CryptoExchange::Catalog"} //= 0; | ||||||||||
|
Condition50%1/2
$res->{"modules"}{"CryptoExchange::Catalog"} //= 0
MC/DC0%0/1
$res->{"modules"}{"CryptoExchange::Catalog"} //= 0
$res->{"modules"}{"CryptoExchange::Catalog"}
Truth table50%1/2
A
A= $res->{"modules"}{"CryptoExchange::Catalog"}
| |||||||||||||
| 31 | 1 | $res->{expr_coerce} = join( | |||||||||||
| 32 | "", | ||||||||||||
| 33 | "do { my \$cat = CryptoExchange::Catalog->new; my \@data = \$cat->all_data; ", | ||||||||||||
| 34 | "my \$lc = lc($dt); my \$rec; for (\@data) { if (defined(\$_->{code}) && \$lc eq lc(\$_->{code}) || \$lc eq lc(\$_->{name}) || \$lc eq \$_->{safename}) { \$rec = \$_; last } } ", | ||||||||||||
| 35 | "if (!\$rec) { ['Unknown cryptoexchange code/name/safename: ' . \$lc] } else { [undef, \$rec->{safename}] } ", | ||||||||||||
| 36 | "}", | ||||||||||||
| 37 | ); | ||||||||||||
| 38 | |||||||||||||
| 39 | 1 | $res; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 2 | 1; | |||||||||||
| 43 | # ABSTRACT: Coerce string containing cryptoexchange code/name/safename to safename | ||||||||||||
| 44 | |||||||||||||
| 45 | __END__ | ||||||||||||