blib/lib/XAS/Lib/Mixins/Configs.pm

filter: Statementstmt 61.5% 8 / 13 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 57.8% 11 / 19 CC 2 SCAR 12.5
CC
2
Cov
53%
load_config
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« blib/lib/XAS/Lib/App/Service/Win32.pm ↑ Summary blib/lib/XAS/Lib/App/Service.pm »
1 package XAS::Lib::Mixins::Configs;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use Config::IniFiles;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use XAS::Class
8 1 debug => 0,
9 version => $VERSION,
10 base => 'XAS::Base',
11 utils => 'dotid compress',
12 mixins => 'load_config',
13 1 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # ----------------------------------------------------------------------
16 # Public Methods
17 # ----------------------------------------------------------------------
18  
19 sub load_config {
20 0 ▶ my $self = shift;
Subroutine load_config: not called CC=2 SCAR=17.9
Pod documented
21 0 my ($filename, $handle) = $self->validate_params(\@_, [
22 { optional => 1, isa => 'Badger::Filesystem::File', default => $self->env->cfgfile },
23 { optional => 1, default => 'cfg' },
24 ]);
25  
26 $self->{$handle} = Config::IniFiles->new(
27 -file => $filename->path,
28 0 ▶ ) or do {
Branch: 1 branch
BranchTrueFalseTotal
$self->{$handle} = "Config::IniFiles"->new("-file", $filename->path) or do { $self->log->warn(compress(join("", @Config::IniFiles::errors))); $self->throw_msg(dotid($self->class) . '.load_config.badini', "config_badini", $filename->path) } 0 0 0
29 0 $self->log->warn(compress(join('', @Config::IniFiles::errors)));
30 0 $self->throw_msg(
31 dotid($self->class) . '.load_config.badini',
32 'config_badini',
33 $filename->path
34 );
35 };
36  
37 }
38  
39 # ----------------------------------------------------------------------
40 # Private Methods
41 # ----------------------------------------------------------------------
42  
43 1 1;
44  
45 __END__
46  
47 =head1 NAME
48  
49 XAS::Lib::Mixins::Configs - A mixin for handling config files
50  
51 =head1 SYNOPSIS
52  
53 use XAS::Class;
54 version => '0.01',
55 base => 'XAS::Base',
56 mixin => 'XAS::Lib::Mixins::Configs',
57 accessors => 'cfg',
58 ;
59  
60 =head1 DESCRIPTION
61  
62 This mixin provides a standardized way to load .ini files.
63  
64 =head1 METHODS
65  
66 =head2 load_config($filename, $handle)
67  
68 This method will load a .ini style configuration file. It uses the following
69 parameters:
70  
71 =over 4
72  
73 =item B<$filename>
74  
75 The file name for the configuration file.
76  
77 =item B<$handle>
78  
79 An optional name to the accessor that will access the
80 L<Config::IniFiles|https://metacpan.org/pod/Config::IniFiles>
81 object in the current self. This name defaults to 'cfg'.
82  
83 =back
84  
85 =head1 SEE ALSO
86  
87 =over 4
88  
89 =item L<XAS|XAS>
90  
91 =back
92  
93 =head1 AUTHOR
94  
95 Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
96  
97 =head1 COPYRIGHT AND LICENSE
98  
99 Copyright (C) 2014 Kevin L. Esteb
100  
101 This is free software; you can redistribute it and/or modify it under
102 the terms of the Artistic License 2.0. For details, see the full text
103 of the license at http://www.perlfoundation.org/artistic_license_2_0.
104  
105 =cut
« blib/lib/XAS/Lib/App/Service/Win32.pm ↑ Summary blib/lib/XAS/Lib/App/Service.pm »