blib/lib/App/ListCurrencies.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 97.3% 37 / 38 CC 1 SCAR 0.0
CC
1
Cov
97%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package App::ListCurrencies;
2  
3 1 our $DATE = '2019-09-28'; # DATE
4 1 our $VERSION = '0.004'; # VERSION
5  
6 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Perinci::Sub::Gen::AccessTable qw(gen_read_table_func);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our %SPEC;
13 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 our @EXPORT_OK = qw(list_languages);
15  
16 1 our $data;
17 {
18 1 require Locale::Codes::Currency_Codes;
19 1 $data = [];
20 1 my $id2names = $Locale::Codes::Data{'currency'}{'id2names'};
21 1 my $id2alpha = $Locale::Codes::Data{'currency'}{'id2code'}{'alpha'};
22  
23 1 for my $id (keys %$id2names) {
24 175 push @$data, [$id2alpha->{$id}, $id2names->{$id}[0]];
25 }
26  
27 1 $data = [sort {$a->[0] cmp $b->[0]} @$data];
28 }
29  
30 1 my $res = gen_read_table_func(
31 name => 'list_currencies',
32 summary => 'List currencies',
33 table_data => $data,
34 table_spec => {
35 summary => 'List of currencies',
36 fields => {
37 alpha => {
38 summary => 'ISO 4217 alpha code',
39 schema => 'str*',
40 pos => 0,
41 sortable => 1,
42 },
43 en_name => {
44 summary => 'English name',
45 schema => 'str*',
46 pos => 1,
47 sortable => 1,
48 },
49 },
50 pk => 'alpha',
51 },
52 description => <<'_',
53  
54 Source data is generated from `Locale::Codes::Currency_Codes`. so make sure you
55 have a relatively recent version of the module.
56  
57 _
58 extra_props => {
59 examples => [
60 {
61 args => {query=>'rup'},
62 test => 0,
63 },
64 {
65 args => {query=>'rup', detail=>1},
66 test => 0,
67 },
68 ],
69 },
70 );
71 1 ▶die "Can't generate function: $res->[0] - $res->[1]" unless $res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 1 1
72  
73 1 1;
74 # ABSTRACT: List currencies
75  
76 __END__
↑ Summary