blib/lib/Data/Sah/Coerce/perl/To_str/From_str/to_cryptocurrency_code.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 86.6% 26 / 30 CC 2 SCAR 2.9
CC
2
Cov
95%
coerce
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Data::Sah::Coerce::perl::To_str::From_str::to_cryptocurrency_code;
2  
3 # AUTHOR
4 2 our $DATE = '2019-11-28'; # DATE
5 2 our $DIST = 'Data-Sah-Coerce-perl-To_str-From_str-to_cryptocurrency_code'; # 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 cryptocurrency code/name/safename to code',
16 might_fail => 1,
17 prio => 50,
18 };
19 }
20  
21 1 ▶sub coerce {
Subroutine coerce: called CC=2 SCAR=7.0
Pod undocumented
22 1 my %args = @_;
23  
24 1 my $dt = $args{data_term};
25  
26 1 my $res = {};
27  
28 1 $res->{expr_match} = "!ref($dt)";
29 1 ▶ $res->{modules}{"CryptoCurrency::Catalog"} //= 0;
Condition50%1/2
$res->{"modules"}{"CryptoCurrency::Catalog"} //= 0
l!l
01
MC/DC0%0/1
$res->{"modules"}{"CryptoCurrency::Catalog"} //= 0
$res->{"modules"}{"CryptoCurrency::Catalog"}
Truth table50%1/2
A
A= $res->{"modules"}{"CryptoCurrency::Catalog"}
Aresult
11
00
30 1 $res->{expr_coerce} = join(
31 "",
32 "do { my \$cat = CryptoCurrency::Catalog->new; ",
33 "my \$rec; eval { \$rec = \$cat->by_code($dt) }; if (\$@) { eval { \$rec = \$cat->by_name($dt) } } if (\$@) { eval { \$rec = \$cat->by_safename($dt) } } ",
34 "if (\$@) { ['Unknown cryptocurrency code/name/safename: ' . $dt] } else { [undef, \$rec->{code}] } ",
35 "}",
36 );
37  
38 1 $res;
39 }
40  
41 2 1;
42 # ABSTRACT: Coerce string containing cryptocurrency code/name/safename to code
43  
44 __END__
↑ Summary