Onion/Simple.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 91.1% 31 / 34 CC 2 SCAR 2.4
CC
2
Cov
96%
cfg_obj
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Onion.pm ↑ Summary
1 package Config::Onion::Simple;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = 1.004;
7  
8 2 ▶use Config::Onion;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 our @EXPORT = ();
13 2 our @EXPORT_OK = qw(
14 cfg
15 cfg_obj
16 );
17 2 our %EXPORT_TAGS = (
18 all => [ @EXPORT, @EXPORT_OK ],
19 );
20 }
21  
22 2 my $cfg_obj;
23  
24 1 ▶sub cfg { cfg_obj()->get }
Subroutine cfg: called CC=1 SCAR=0.0
Pod documented
25  
26 2 ▶sub cfg_obj { $cfg_obj ||= Config::Onion->new }
Subroutine cfg_obj: called CC=2 SCAR=7.2
Pod documented
Condition66%2/3
$cfg_obj ||= "Config::Onion"->new
l!l&&r!l&&!r
110
MC/DC0%0/2
$cfg_obj ||= "Config::Onion"->new
$cfg_obj "Config::Onion"->new
Truth table66%2/3
A ||= B
A= $cfg_objB= "Config::Onion"->new
ABresult
1X1
011
000
27  
28 2 1;
29  
30 =pod
31  
32 =encoding UTF-8
33  
34 =head1 NAME
35  
36 Config::Onion::Simple - Simple interface to a Config::Onion singleton
37  
38 =head1 VERSION
39  
40 version 1.007
41  
42 =head1 SYNOPSIS
43  
44 use Config::Onion::Simple qw( cfg cfg_obj );
45  
46 cfg_obj->load('myapp');
47 my $setting = cfg->{setting};
48  
49 =head1 DESCRIPTION
50  
51 It is often useful for a single master configuration to be shared across
52 multiple modules in an application. Config::Onion::Simple provides an
53 interface to do this without requiring any of those modules to know about
54 each other.
55  
56 =head1 EXPORTABLE FUNCTIONS
57  
58 Config::Onion::Simple exports nothing by default. The following functions
59 are exported only on request.
60  
61 =head2 cfg
62  
63 Returns a reference to the complete configuration hash managed by the
64 Config::Onion singleton. This hash should be treated as read-only, as any
65 changes will be lost if the configuration is altered using the underlying
66 Config::Onion instance's methods.
67  
68 Calling C<cfg> is equivalent to calling C<< cfg_obj->get >>.
69  
70 =head2 cfg_obj
71  
72 Returns a reference to the Config::Onion singleton. Use this object's methods
73 to make any changes to the configuration.
74  
75 =head1 SEE ALSO
76  
77 L<Config::Onion>
78  
79 =head1 AUTHOR
80  
81 Dave Sherohman <dsheroh@cpan.org>
82  
83 =head1 COPYRIGHT AND LICENSE
84  
85 This software is copyright (c) 2012 by Lund University Library.
86  
87 This is free software; you can redistribute it and/or modify it under
88 the same terms as the Perl 5 programming language system itself.
89  
90 =cut
91  
92 __END__
« Onion.pm ↑ Summary