blib/lib/Finance/SE/IDX/Any.pm

filter: Statementstmt 54.0% 27 / 50 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 54.5% 6 / 11 Podpod 100% 4 / 4 totaltotal 47.4% 37 / 78 CC 6 SCAR 28.1
CC
6
Cov
44%
_doit
42.0
list_idx_boards
2.0
list_idx_brokers
2.0
CRAP 16.6
↑ Summary
1 package Finance::SE::IDX::Any;
2  
3 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4 1 our $DATE = '2021-08-01'; # DATE
5 1 our $DIST = 'Finance-SE-IDX-Any'; # DIST
6 1 our $VERSION = '0.004'; # VERSION
7  
8 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use strict 'subs', 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Finance::SE::IDX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 our @ISA = qw(Exporter);
17 1 our @EXPORT_OK = qw(
18 list_idx_boards
19 list_idx_brokers
20 list_idx_firms
21 list_idx_sectors
22 );
23  
24 1 our %SPEC = %Finance::SE::IDX::SPEC;
25  
26 1 our $FALLBACK_PERIOD = 4*3600;
27  
28 1 my $warned_static_age;
29 my $last_fail_time;
30  
31 0 ▶sub _doit {
Subroutine _doit: not called CC=6 SCAR=37.4
32 0 my $which = shift;
33  
34 0 my $now = time();
35 0 ▶ unless ($last_fail_time &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($last_fail_time and $now - $last_fail_time <= $Finance::SE::IDX::Any::FALLBACK_PERIOD) 0 0 0
Condition0%0/3
$last_fail_time and $now - $last_fail_time <= $Finance::SE::IDX::Any::FALLBACK_PERIOD
!ll&&!rl&&r
000
MC/DC0%0/2
$last_fail_time and $now - $last_fail_time <= $Finance::SE::IDX::Any::FALLBACK_PERIOD
$last_fail_time $now - $last_fail_time <= $Finance::SE::IDX::Any::FALLBACK_PERIOD
Truth table0%0/3
A and B
A= $last_fail_timeB= $now - $last_fail_time <= $Finance::SE::IDX::Any::FALLBACK_PERIOD
ABresult
0X0
100
111
36 ($now-$last_fail_time) <= $FALLBACK_PERIOD) {
37 0 my $res = &{"Finance::SE::IDX::$which"}(@_);
38 0 ▶ if ($res->[0] == 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->[0] == 200) { } 0 0 0
39 0 undef $last_fail_time;
40 0 return $res;
41 } else {
42 0 log_warn "Finance::SE::IDX::$which() failed, falling back to ".
43 "Finance::SE::IDX::Static version ...";
44 0 $last_fail_time = $now;
45 }
46 }
47 0 require Finance::SE::IDX::Static;
48 0 ▶ unless ($warned_static_age) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($warned_static_age) 0 0 0
49 0 my $mtime = ${"Finance::SE::IDX::Static::data_mtime"};
50 0 ▶ if (($now - $mtime) > 2*30*86400) {
Branch: 1 branch
BranchTrueFalseTotal
if ($now - $mtime > 5184000) 0 0 0
51 0 log_warn "Finance::SE::IDX::Static version is older than 60 days, ".
52 "data might be out of date, please consider updating to a ".
53 "new version of Finance::SE::IDX::Static";
54 }
55 0 $warned_static_age++;
56 }
57 0 return &{"Finance::SE::IDX::Static::$which"}(@_);
58 }
59  
60 0 ▶sub list_idx_boards { _doit("list_idx_boards", @_) }
Subroutine list_idx_boards: not called CC=1 SCAR=6.9
Pod documented
61  
62 0 ▶sub list_idx_brokers { _doit("list_idx_brokers", @_) }
Subroutine list_idx_brokers: not called CC=1 SCAR=6.9
Pod documented
63  
64 0 ▶sub list_idx_firms { _doit("list_idx_firms", @_) }
Subroutine list_idx_firms: not called CC=1 SCAR=6.9
Pod documented
65  
66 0 ▶sub list_idx_sectors { _doit("list_idx_sectors", @_) }
Subroutine list_idx_sectors: not called CC=1 SCAR=6.9
Pod documented
67  
68 1 1;
69 # ABSTRACT: Get information from Indonesian Stock Exchange
70  
71 __END__
↑ Summary