blib/lib/Data/Sah/Coerce/perl/To_str/From_str/to_cryptocurrency_safename.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_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_cryptocurrency_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 cryptocurrency code/name/safename to safename',
16 might_fail => 1,
17 prio => 50,
18 precludes => [qr/\Astr_to_cryptocurrency_(.+)?\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}{"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
31 1 $res->{expr_coerce} = join(
32 "",
33 "do { my \$cat = CryptoCurrency::Catalog->new; ",
34 "my \$rec; eval { \$rec = \$cat->by_code($dt) }; if (\$@) { eval { \$rec = \$cat->by_name($dt) } } if (\$@) { eval { \$rec = \$cat->by_safename($dt) } } ",
35 "if (\$@) { ['Unknown cryptocurrency code/name/safename: ' . $dt] } else { [undef, \$rec->{safename}] } ",
36 "}",
37 );
38  
39 1 $res;
40 }
41  
42 2 1;
43 # ABSTRACT: Coerce string containing cryptocurrency code/name/safename to safename
44  
45 __END__
↑ Summary