File Coverage

blib/lib/Config/Singleton.pm
Criterion Covered Total %
statement 94 100 94.0
branch 26 26 100.0
condition 13 23 56.5
subroutine 26 28 92.8
pod n/a
total 159 177 89.8


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