File Coverage

blib/lib/Bryar/Config/YAML.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 4 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 32 53.1


line stmt bran cond sub pod time code
1 1     1   18754 use strict;
  1         2  
  1         31  
2 1     1   4 use warnings;
  1         1  
  1         34  
3              
4             package Bryar::Config::YAML;
5 1     1   4 use base qw(Bryar::Config);
  1         31  
  1         544  
6              
7 1     1   736 use YAML::Syck qw(LoadFile);
  1         1876  
  1         152  
8              
9             =head1 NAME
10              
11             Bryar::Config::YAML - Bryar configuration stored in YAML
12              
13             =head1 VERSION
14              
15             version 0.103
16              
17             =cut
18              
19             our $VERSION = '0.103';
20              
21             =head1 SYNOPSIS
22              
23             Bryar::Config::YAML->new(...);
24             Bryar::Config::YAML->load(...);
25              
26             =head1 DESCRIPTION
27              
28             This encapsulates a Bryar configuration. It can be used to load a new
29             configuration from a file, or provide a reasonable set of defaults.
30              
31             It loads Bryar configuration from a YAML file.
32              
33             =head1 METHODS
34              
35             =head2 load
36              
37             $self->load($file)
38              
39             Load the configuration file from somewhere and return the arguments as a
40             hash.
41              
42             =cut
43              
44             sub load {
45 0     0 1   my ($self, $file) = @_;
46 0           my %args;
47 0           my $datadir = $self->{datadir};
48 0 0         if (!-r $file) {
49 0 0         if (-r "$datadir/$file") {
50 0           $file = "$datadir/$file";
51             } else {
52 0           return;
53             }
54             }
55 0           %args = %{ (LoadFile($file))[0] };
  0            
56 0           return %args;
57             }
58              
59             =head1 AUTHOR
60              
61             Ricardo SIGNES, C<< >>
62              
63             =head1 BUGS
64              
65             Please report any bugs or feature requests to
66             C, or through the web interface at
67             L. I will be notified, and then you'll automatically be
68             notified of progress on your bug as I make changes.
69              
70             =head1 COPYRIGHT
71              
72             Copyright 2004-2006 Ricardo SIGNES, All Rights Reserved.
73              
74             This program is free software; you can redistribute it and/or modify it
75             under the same terms as Perl itself.
76              
77             =cut
78              
79             1;