line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sah::Coerce::perl::str::str_to_fiat_or_cryptocurrency_code; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-07-26'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4354
|
use 5.010001; |
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
175
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub meta { |
11
|
|
|
|
|
|
|
+{ |
12
|
1
|
|
|
1
|
0
|
13
|
v => 4, |
13
|
|
|
|
|
|
|
might_fail => 1, |
14
|
|
|
|
|
|
|
prio => 50, |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub coerce { |
19
|
1
|
|
|
1
|
0
|
16
|
my %args = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
my $dt = $args{data_term}; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my $res = {}; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
3
|
$res->{expr_match} = "!ref($dt)"; |
26
|
1
|
|
50
|
|
|
7
|
$res->{modules}{"CryptoCurrency::Catalog"} //= 0; |
27
|
1
|
|
50
|
|
|
5
|
$res->{modules}{"Locale::Codes::Currency_Codes"} //= 0; |
28
|
1
|
|
|
|
|
6
|
$res->{expr_coerce} = join( |
29
|
|
|
|
|
|
|
"", |
30
|
|
|
|
|
|
|
"do { my \$res; ", |
31
|
|
|
|
|
|
|
" my \$uc = uc($dt); ", |
32
|
|
|
|
|
|
|
" if (\$Locale::Codes::Data{currency}{code2id}{alpha}{\$uc}) { \$res = [undef, \$uc]; goto RETURN_RES } ", |
33
|
|
|
|
|
|
|
" 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 (\$@) { \$res = ['Unknown fiat/cryptocurrency code/name/safename: ' . $dt] } else { \$res = [undef, \$rec->{code}] } ", |
36
|
|
|
|
|
|
|
" RETURN_RES: \$res; ", |
37
|
|
|
|
|
|
|
"}", |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
4
|
$res; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
# ABSTRACT: Coerce string containing fiat/cryptocurrency code/name/safename to uppercase code |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding UTF-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Data::Sah::Coerce::perl::str::str_to_fiat_or_cryptocurrency_code - Coerce string containing fiat/cryptocurrency code/name/safename to uppercase code |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 VERSION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This document describes version 0.003 of Data::Sah::Coerce::perl::str::str_to_fiat_or_cryptocurrency_code (from Perl distribution Data-Sah-Coerce-perl-str-str_to_fiat_or_cryptocurrency_code), released on 2019-07-26. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The rule is not enabled by default. You can enable it in a schema using e.g.: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
["str", "x.perl.coerce_rules"=>["str_to_cryptocurrency_code"]] |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=for Pod::Coverage ^(meta|coerce)$ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 HOMEPAGE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-Coerce-perl-str-str_to_fiat_or_cryptocurrency_code>. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SOURCE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-str-str_to_fiat_or_cryptocurrency_code>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 BUGS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah-Coerce-perl-str-str_to_fiat_or_cryptocurrency_code> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
81
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
82
|
|
|
|
|
|
|
feature. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2018 by perlancar@cpan.org. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
93
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |