MenuGrinder/Plugin/YAMLLoader.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 27 CC 1 SCAR 6.9
CC
1
Cov
0%
load
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package WWW::MenuGrinder::Plugin::YAMLLoader;
2 our $VERSION = '0.01_01';
3  
4  
5 # ABSTRACT: WWW::MenuGrinder plugin that loads menus with YAML::XS.
6  
7 use Moose;
8  
9 use YAML::XS;
10  
11 with 'WWW::MenuGrinder::Role::Loader';
12  
13 has 'filename' => (
14 is => 'rw',
15 );
16  
17 sub load {
18 my ($self) = @_;
19  
20 open my $menufh, '<:encoding(UTF-8)', $self->filename or die $!;
21 my $menu_yaml = do { local $/; <$menufh> };
22  
23 my $menu = Load $menu_yaml;
24  
25 return $menu;
26 }
27  
28 no Moose;
29  
30 1;
31  
32  
33 __END__
34 =head1 NAME
35  
36 WWW::MenuGrinder::Plugin::YAMLLoader - WWW::MenuGrinder plugin that loads menus with YAML::XS.
37  
38 =head1 VERSION
39  
40 version 0.01_01
41  
42 =head1 DESCRIPTION
43  
44 C<WWW::MenuGrinder::Plugin::YAMLLoader> is a plugin for C<WWW::MenuGrinder>. You
45 should not use it directly, but include it in the C<plugins> section of a
46 C<WWW::MenuGrinder> config.
47  
48 This is an input plugin that uses L<YAML::Simple> to load a menu structure.
49  
50 TODO example file.
51  
52 =head2 Configuration
53  
54 The key C<filename> in the global configuration holds the name of the file to be
55 read.
56  
57 =head1 AUTHOR
58  
59 Andrew Rodland <andrew@hbslabs.com>
60  
61 =head1 COPYRIGHT AND LICENSE
62  
63 This software is copyright (c) 2009 by HBS Labs, LLC..
64  
65 This is free software; you can redistribute it and/or modify it under
66 the same terms as perl itself.
67