| 1 | package Langertha::Skeid::UsageStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 129 | our $VERSION = '0.005'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Usage event sink - config normalization and backend factory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 129 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 129 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 129 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 181 | ▶ | sub normalize_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_config: called CC=50 SCAR=44.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 181 | my ($class, $cfg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 181 | ▶ | $cfg ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg ||= {}
MC/DC0%0/1
$cfg ||= {}
$cfg
Truth table50%1/2
A
A= $cfg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 181 | ▶ | croak 'usage_store must be a hashref' unless ref($cfg) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 181 | ▶ | my $backend = lc($cfg->{backend} // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"backend"} // ""
MC/DC100%1/1
$cfg->{"backend"} // ""
$cfg->{"backend"}
Truth table100%2/2
A
A= $cfg->{"backend"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 181 | ▶ | $backend = 'sqlite' if !$backend && (defined($cfg->{sqlite_path}) || defined($cfg->{path}) || defined($cfg->{db_path})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not $backend and defined $cfg->{"sqlite_path"} || defined $cfg->{"path"} || defined $cfg->{"db_path"}
defined $cfg->{"sqlite_path"} or defined $cfg->{"path"} or defined $cfg->{"db_path"}
defined $cfg->{"sqlite_path"} or defined $cfg->{"path"}
MC/DC50%2/4
not $backend and defined $cfg->{"sqlite_path"} || defined $cfg->{"path"} || defined $cfg->{"db_path"}
not $backend
defined $cfg->{"sqlite_path"}
defined $cfg->{"path"}
defined $cfg->{"db_path"}
Truth table60%3/5
not(A) and B or C or D
A= not $backendB= defined $cfg->{"sqlite_path"}C= defined $cfg->{"path"}D= defined $cfg->{"db_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 181 | ▶ | $backend = 'postgresql' if !$backend && defined($cfg->{dsn}) && $cfg->{dsn} =~ /^dbi:Pg:/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $backend and defined $cfg->{"dsn"} and $cfg->{"dsn"} =~ /^dbi:Pg:/i
not $backend and defined $cfg->{"dsn"}
MC/DC33%1/3
not $backend and defined $cfg->{"dsn"} and $cfg->{"dsn"} =~ /^dbi:Pg:/i
not $backend
defined $cfg->{"dsn"}
$cfg->{"dsn"} =~ /^dbi:Pg:/i
Truth table50%2/4
not(A) and B and C
A= not $backendB= defined $cfg->{"dsn"}C= $cfg->{"dsn"} =~ /^dbi:Pg:/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 181 | ▶ | $backend = 'jsonlog' if !$backend && defined($cfg->{log_path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $backend and defined $cfg->{"log_path"}
MC/DC0%0/2
not $backend and defined $cfg->{"log_path"}
not $backend
defined $cfg->{"log_path"}
Truth table33%1/3
not(A) and B
A= not $backendB= defined $cfg->{"log_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 181 | ▶ | $backend = 'sqlite' unless length $backend; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 181 | ▶ | $backend = 'postgresql' if $backend =~ /^postgres/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 181 | ▶ | $backend = 'jsonlog' if $backend =~ /^json/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 181 | ▶ | if ($backend eq 'sqlite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 45 | ▶ | my $path = $cfg->{sqlite_path} // $cfg->{path} // $cfg->{db_path} // $opts{default_sqlite_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
(($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}) // $opts{"default_sqlite_path"}
($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}
$cfg->{"sqlite_path"} // $cfg->{"path"}
MC/DC0%0/4
(($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}) // $opts{"default_sqlite_path"}
$cfg->{"sqlite_path"}
$cfg->{"path"}
$cfg->{"db_path"}
$opts{"default_sqlite_path"}
Truth table40%2/5
A // B // C // D
A= $cfg->{"sqlite_path"}B= $cfg->{"path"}C= $cfg->{"db_path"}D= $opts{"default_sqlite_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 45 | ▶ | if (!defined($path) || !length($path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and length $path
MC/DC0%0/2
defined $path and length $path
defined $path
length $path
Truth table33%1/3
A and B
A= defined $pathB= length $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | croak 'usage_store.sqlite_path (or path/db_path) is required for sqlite backend'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | backend => 'sqlite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | dsn => "dbi:SQLite:dbname=$path", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | user => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | password => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | schema_file => ($cfg->{schema_file} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 45 | ▶ | auto_migrate => exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$cfg->{"schema_file"} // ""
MC/DC100%1/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
Truth table100%2/2
A
A= $cfg->{"schema_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | flush_interval_ms => $class->_flush_interval_ms($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | spool_dir => $class->_spool_dir($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $class->_retention($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 136 | ▶ | if ($backend eq 'postgresql') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 76 | my $dsn = $cfg->{dsn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 76 | ▶ | if (!defined($dsn) || !length($dsn)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $dsn and length $dsn
MC/DC50%1/2
defined $dsn and length $dsn
defined $dsn
length $dsn
Truth table66%2/3
A and B
A= defined $dsnB= length $dsn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | my $host = $cfg->{host} // '127.0.0.1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"host"} // "127.0.0.1"
MC/DC0%0/1
$cfg->{"host"} // "127.0.0.1"
$cfg->{"host"}
Truth table50%1/2
A
A= $cfg->{"host"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | my $port = $cfg->{port} // 5432; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"port"} // 5432
MC/DC100%1/1
$cfg->{"port"} // 5432
$cfg->{"port"}
Truth table100%2/2
A
A= $cfg->{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | ▶ | my $name = $cfg->{dbname} // $cfg->{database} // 'skeid'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($cfg->{"dbname"} // $cfg->{"database"}) // "skeid"
$cfg->{"dbname"} // $cfg->{"database"}
MC/DC0%0/2
($cfg->{"dbname"} // $cfg->{"database"}) // "skeid"
$cfg->{"dbname"}
$cfg->{"database"}
Truth table33%1/3
A // B
A= $cfg->{"dbname"}B= $cfg->{"database"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | $dsn = "dbi:Pg:dbname=$name;host=$host;port=$port"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 76 | ▶ | my $password = defined($cfg->{password}) ? $cfg->{password} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 76 | ▶ | if (!length($password) && defined($cfg->{password_env}) && length($cfg->{password_env})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not length $password and defined $cfg->{"password_env"} and length $cfg->{"password_env"}
not length $password and defined $cfg->{"password_env"}
MC/DC66%2/3
not length $password and defined $cfg->{"password_env"} and length $cfg->{"password_env"}
not length $password
defined $cfg->{"password_env"}
length $cfg->{"password_env"}
Truth table75%3/4
not(A) and B and C
A= not length $passwordB= defined $cfg->{"password_env"}C= length $cfg->{"password_env"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | $password = $ENV{$cfg->{password_env}} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ENV{$cfg->{"password_env"}} // ""
MC/DC100%1/1
$ENV{$cfg->{"password_env"}} // ""
$ENV{$cfg->{"password_env"}}
Truth table100%2/2
A
A= $ENV{$cfg->{"password_env"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | backend => 'postgresql', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | path => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | dsn => $dsn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | user => ($cfg->{user} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | password => $password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | schema_file => ($cfg->{schema_file} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 76 | ▶ | auto_migrate => exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition75%3/4
$cfg->{"user"} // ""
$cfg->{"schema_file"} // ""
MC/DC100%1/1
$cfg->{"user"} // ""
$cfg->{"user"}
MC/DC0%0/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
Truth table100%2/2
A
A= $cfg->{"user"}
Truth table50%1/2
A
A= $cfg->{"schema_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | flush_interval_ms => $class->_flush_interval_ms($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | spool_dir => $class->_spool_dir($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $class->_retention($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 60 | ▶ | if ($backend eq 'jsonlog') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 60 | ▶ | my $path = $cfg->{log_path} // $cfg->{path} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($cfg->{"log_path"} // $cfg->{"path"}) // ""
$cfg->{"log_path"} // $cfg->{"path"}
MC/DC0%0/2
($cfg->{"log_path"} // $cfg->{"path"}) // ""
$cfg->{"log_path"}
$cfg->{"path"}
Truth table66%2/3
A // B
A= $cfg->{"log_path"}B= $cfg->{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 60 | ▶ | croak 'usage_store.log_path (or path) is required for jsonlog backend' unless length $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 60 | ▶ | my $mode = $cfg->{mode} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"mode"} // ""
MC/DC100%1/1
$cfg->{"mode"} // ""
$cfg->{"mode"}
Truth table100%2/2
A
A= $cfg->{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 60 | ▶ | if (!length($mode)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 25 | ▶ | $mode = (-d $path || $path =~ m{/$}) ? 'dir' : 'file'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-d $path or $path =~ m[/$]
MC/DC100%2/2
-d $path or $path =~ m[/$]
-d $path
$path =~ m[/$]
Truth table100%3/3
A or B
A= -d $pathB= $path =~ m[/$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | backend => 'jsonlog', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | mode => $mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 60 | ▶ | fsync => ($cfg->{fsync} ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $class->_retention($cfg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | croak "unsupported usage_store backend '$backend'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Write-behind for the DBI backends (skeid k78). 0 -- the default -- is the synchronous write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # every deployment had before; anything else widens the loss window, so it has to be asked for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # with a number that means what it says. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 121 | ▶ | sub _flush_interval_ms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flush_interval_ms: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 121 | my ($class, $cfg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 121 | ▶ | my $ms = $cfg->{flush_interval_ms} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"flush_interval_ms"} // 0
MC/DC100%1/1
$cfg->{"flush_interval_ms"} // 0
$cfg->{"flush_interval_ms"}
Truth table100%2/2
A
A= $cfg->{"flush_interval_ms"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 121 | ▶ | croak 'usage_store.flush_interval_ms must be a whole number of milliseconds (0 = write each event at once)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | unless $ms =~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 118 | return 0 + $ms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # How long usage events are kept (skeid k122): whole days, or absent for "until deleted". Read by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # `skeid usage-purge --retention`, never on the request path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 177 | ▶ | sub _retention { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_retention: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 177 | my ($class, $cfg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 177 | my $days = $cfg->{retention_days}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 177 | ▶ | return () unless defined $days; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 15 | ▶ | croak 'usage_store.retention_days must be a whole number of days, at least 1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not ref $days and $days =~ /\A[0-9]+\z/ and $days >= 1
not ref $days and $days =~ /\A[0-9]+\z/
MC/DC66%2/3
not ref $days and $days =~ /\A[0-9]+\z/ and $days >= 1
not ref $days
$days =~ /\A[0-9]+\z/
$days >= 1
Truth table75%3/4
not(A) and B and C
A= not ref $daysB= $days =~ /\A[0-9]+\z/C= $days >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | unless !ref($days) && $days =~ /\A[0-9]+\z/ && $days >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 13 | return (retention_days => 0 + $days); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 30 | ▶ | sub purge_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
purge_request: called CC=17 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 30 | my ($class, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 30 | ▶ | return (undef, 'a purge needs arguments') unless ref($args) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 30 | my ($ids, $before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 30 | ▶ | if (defined $args->{api_key_ids}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 21 | my $list = $args->{api_key_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | return (undef, 'api_key_ids must be a non-empty list of key ids') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | unless ref($list) eq 'ARRAY' && @$list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 21 | ▶ | && !grep { !defined($_) || ref($_) || !length($_) || length($_) > 256 } @$list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%12/15
ref $list eq "ARRAY" and @$list and not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
ref $list eq "ARRAY" and @$list
!defined($_) || ref $_ || !length($_) || length $_ > 256
not defined $_ or ref $_ or not length $_
not defined $_ or ref $_
MC/DC100%3/3
ref $list eq "ARRAY" and @$list and not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
ref $list eq "ARRAY"
@$list
not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
MC/DC25%1/4
!defined($_) || ref $_ || !length($_) || length $_ > 256
not defined $_
ref $_
not length $_
length $_ > 256
Truth table100%4/4
A and B and not(C)
A= ref $list eq "ARRAY"B= @$listC= not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
Truth table40%2/5
not(A) or B or not(C) || D
A= not defined $_B= ref $_C= not length $_D= length $_ > 256
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 18 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 18 | $ids = [ grep { !$seen{$_}++ } map { "$_" } @$list ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 27 | ▶ | if (defined $args->{before}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | $before = $args->{before}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 6 | ▶ | return (undef, 'before must be an ISO 8601 UTC timestamp (YYYY-MM-DDTHH:MM:SSZ)') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $before or not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
MC/DC50%1/2
ref $before or not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
ref $before
not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
Truth table66%2/3
A or not(B)
A= ref $beforeB= not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if ref($before) || $before !~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 25 | ▶ | return (undef, 'a purge needs api_key_ids, before, or both') unless $ids || defined $before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ids or defined $before
MC/DC100%2/2
$ids or defined $before
$ids
defined $before
Truth table100%3/3
A or B
A= $idsB= defined $before
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | return ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ($ids ? (api_key_ids => $ids) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | (defined($before) ? (before => "$before") : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 22 | ▶ | dry_run => ($args->{dry_run} ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # The usage spool of the DBI backends (skeid k110, ADR 0027). Empty -- the default -- keeps the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # behavior from before: what the database cannot take is reported lost. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 118 | ▶ | sub _spool_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spool_dir: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 118 | my ($class, $cfg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 118 | ▶ | my $dir = $cfg->{spool_dir} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"spool_dir"} // ""
MC/DC100%1/1
$cfg->{"spool_dir"} // ""
$cfg->{"spool_dir"}
Truth table100%2/2
A
A= $cfg->{"spool_dir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 118 | ▶ | croak 'usage_store.spool_dir must be a directory path' if ref $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 117 | return "$dir"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 88 | ▶ | sub for_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_config: called CC=17 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 88 | my ($class, $cfg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 88 | ▶ | return unless ref($cfg) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 88 | ▶ | my $backend = $cfg->{backend} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"backend"} // ""
MC/DC0%0/1
$cfg->{"backend"} // ""
$cfg->{"backend"}
Truth table50%1/2
A
A= $cfg->{"backend"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 88 | ▶ | return unless length $backend; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 88 | ▶ | if ($backend eq 'jsonlog') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 49 | require Langertha::Skeid::UsageStore::JsonLog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | return Langertha::Skeid::UsageStore::JsonLog->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | path => ($cfg->{path} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | mode => ($cfg->{mode} // 'dir'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 49 | ▶ | fsync => ($cfg->{fsync} ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$cfg->{"path"} // ""
$cfg->{"mode"} // "dir"
MC/DC0%0/1
$cfg->{"path"} // ""
$cfg->{"path"}
MC/DC0%0/1
$cfg->{"mode"} // "dir"
$cfg->{"mode"}
Truth table50%1/2
A
A= $cfg->{"path"}
Truth table50%1/2
A
A= $cfg->{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 39 | require Langertha::Skeid::UsageStore::DBI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | return Langertha::Skeid::UsageStore::DBI->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | backend => $backend, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | dsn => ($cfg->{dsn} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | user => ($cfg->{user} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | password => ($cfg->{password} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | path => ($cfg->{path} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | schema_file => ($cfg->{schema_file} // ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | auto_migrate => (exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | flush_interval_ms => ($cfg->{flush_interval_ms} // 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 39 | ▶ | spool_dir => ($cfg->{spool_dir} // q{}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%7/14
$cfg->{"dsn"} // ""
$cfg->{"user"} // ""
$cfg->{"password"} // ""
$cfg->{"path"} // ""
$cfg->{"schema_file"} // ""
$cfg->{"flush_interval_ms"} // 0
$cfg->{"spool_dir"} // ""
MC/DC0%0/1
$cfg->{"dsn"} // ""
$cfg->{"dsn"}
MC/DC0%0/1
$cfg->{"user"} // ""
$cfg->{"user"}
MC/DC0%0/1
$cfg->{"password"} // ""
$cfg->{"password"}
MC/DC0%0/1
$cfg->{"path"} // ""
$cfg->{"path"}
MC/DC0%0/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
MC/DC0%0/1
$cfg->{"flush_interval_ms"} // 0
$cfg->{"flush_interval_ms"}
MC/DC0%0/1
$cfg->{"spool_dir"} // ""
$cfg->{"spool_dir"}
Truth table50%1/2
A
A= $cfg->{"dsn"}
Truth table50%1/2
A
A= $cfg->{"user"}
Truth table50%1/2
A
A= $cfg->{"password"}
Truth table50%1/2
A
A= $cfg->{"path"}
Truth table50%1/2
A
A= $cfg->{"schema_file"}
Truth table50%1/2
A
A= $cfg->{"flush_interval_ms"}
Truth table50%1/2
A
A= $cfg->{"spool_dir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 4819 | ▶ | sub num { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4819 | my ($v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 4819 | ▶ | return 0 unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3819 | return 0 + $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 173 | ▶ | sub read_text_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_text_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 173 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 173 | ▶ | open my $fh, '<', $path or die "Cannot open $path: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 173 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 173 | my $text = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 173 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 173 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 129 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||