File Coverage

blib/lib/Config/Singleton.pm
Criterion Covered Total %
statement 91 97 93.8
branch 26 26 100.0
condition 13 23 56.5
subroutine 25 27 92.5
pod n/a
total 155 173 89.6


line stmt bran cond sub pod time code
1 10     10   241762 use warnings;
  10         45  
  10         323  
2 10     10   47 use strict;
  10         18  
  10         285  
3             package Config::Singleton 0.006;
4             # ABSTRACT: one place for your app's configuration
5              
6 10     10   41 use Cwd ();
  10         19  
  10         130  
7 10     10   52 use File::Basename ();
  10         17  
  10         144  
8 10     10   4401 use File::HomeDir ();
  10         48760  
  10         202  
9 10     10   65 use File::Spec ();
  10         18  
  10         120  
10 10     10   3732 use YAML::XS ();
  10         24707  
  10         335  
11              
12 10         72 use Sub::Exporter -setup => {
13             groups => [ setup => \'_build_config_methods' ],
14 10     10   6211 };
  10         110401  
15              
16             #pod =head1 SYNOPSIS
17             #pod
18             #pod package YourApplication::Config;
19             #pod
20             #pod use Config::Singleton -setup => {
21             #pod filename => 'something.yaml',
22             #pod template => {
23             #pod foo => undef,
24             #pod bar => 1024,
25             #pod qux => [ 1, 2, 3],
26             #pod },
27             #pod };
28             #pod
29             #pod Elsewhere...
30             #pod
31             #pod use YourApplication::Config 'my_instance_config.yml';
32             #pod
33             #pod my $foo = YourApplication::Config->foo;
34             #pod
35             #pod =head1 DESCRIPTION
36             #pod
37             #pod Config::Singleton provides a base class for access to configuration data for
38             #pod your app. The basic implementation stores its configuration in YAML in a text
39             #pod file found in all the usual places. By default, Config::Singleton looks for
40             #pod myapp.yml, but an alternate filename may be passed when using the module.
41             #pod
42             #pod This module was derived from L.
43             #pod
44             #pod =head1 USING APP::CONFIG
45             #pod
46             #pod The L section, above, demonstrates an example of almost every
47             #pod feature of Config::Singleton It's a very simple module with a very small
48             #pod interface.
49             #pod
50             #pod It is not a base class. It is a utility for setting up a class that stores
51             #pod loaded configuration data. You just need to C the module like this:
52             #pod
53             #pod package Your::Config;
54             #pod
55             #pod use Config::Singleton -setup => {
56             #pod filename => 'your_program.yaml',
57             #pod template => {
58             #pod username => undef,
59             #pod hostname => undef,
60             #pod logfile => undef,
61             #pod facility => 'local1',
62             #pod path => [ qw(/var/spool /tmp/jobs) ],
63             #pod },
64             #pod };
65             #pod
66             #pod When another module uses Your::Config, F will be loaded and
67             #pod its contents will be merged over the defaults given by the C