Memoir44/DB/Params.pm

filter: Statementstmt 66.6% 24 / 36 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 70.0% 7 / 10 Podpod 100% 2 / 2 totaltotal 62.2% 33 / 53 CC 2 SCAR 7.4
CC
2
Cov
62%
_build__params
6.0
get
2.0
set
2.0
CRAP 2.1
« Memoir44/Types.pm ↑ Summary Memoir44/App/Command/list.pm »
1 #
2 # This file is part of WWW-DaysOfWonder-Memoir44
3 #
4 # This software is copyright (c) 2009 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 4 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package WWW::DaysOfWonder::Memoir44::DB::Params;
14 # ABSTRACT: various runtime params
15 4 $WWW::DaysOfWonder::Memoir44::DB::Params::VERSION = '3.000';
16 4 ▶use Config::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use MooseX::Singleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use MooseX::Has::Sugar;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 ▶use WWW::DaysOfWonder::Memoir44::Utils qw{ $DATADIR };
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 4 my $params_file = $DATADIR->file( "params.ini" );
24  
25 4 has _params => ( ro, isa => "Config::Tiny", lazy_build );
26  
27 0 ▶sub _build__params {
Subroutine _build__params: not called CC=2 SCAR=17.9
28 0 my $self = shift;
29 0 my $params = Config::Tiny->read( $params_file );
30 0 ▶ $params //= Config::Tiny->new;
Condition0%0/3
$params //= "Config::Tiny"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$params //= "Config::Tiny"->new
$params "Config::Tiny"->new
Truth table0%0/3
A //= B
A= $paramsB= "Config::Tiny"->new
ABresult
1X1
011
000
31 0 return $params;
32 }
33  
34 # -- public methods
35  
36  
37 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
38 0 my ($self, $key) = @_;
39 0 my $section = scalar caller;
40 0 return $self->_params->{ $section }->{ $key };
41 }
42  
43  
44  
45 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
46 0 my ($self, $key, $value) = @_;
47 0 my $section = scalar caller;
48 0 my $params = $self->_params;
49 0 $params->{ $section }->{ $key } = $value;
50 0 $params->write( $params_file );
51 }
52  
53  
54 4 1;
55  
56 __END__
« Memoir44/Types.pm ↑ Summary Memoir44/App/Command/list.pm »