File Coverage

lib/Templer/Site/Asset.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition 1 3 33.3
subroutine 4 4 100.0
pod 2 2 100.0
total 22 24 91.6


line stmt bran cond sub pod time code
1              
2             =head1 NAME
3              
4             Templer::Site::Asset - An interface to a site asset.
5              
6             =cut
7              
8             =head1 SYNOPSIS
9              
10             use strict;
11             use warnings;
12              
13             use Templer::Site::Asset;
14              
15             my $page = Templer::Site::Asset->new( file => "./input/robots.txt" );
16              
17             =cut
18              
19             =head1 DESCRIPTION
20              
21             An asset is anything beneath the input directory which is *not* a page.
22              
23             Assuming we're not running in "in-place" mode then assets are copied
24             over to a suitable filename in the output tree.
25              
26             In C the page objects are created by the L module.
27              
28             =cut
29              
30             =head1 LICENSE
31              
32             This module is free software; you can redistribute it and/or modify it
33             under the terms of either:
34              
35             a) the GNU General Public License as published by the Free Software
36             Foundation; either version 2, or (at your option) any later version,
37             or
38              
39             b) the Perl "Artistic License".
40              
41             =cut
42              
43             =head1 AUTHOR
44              
45             Steve Kemp
46              
47             =cut
48              
49             =head1 COPYRIGHT AND LICENSE
50              
51             Copyright (C) 2012-2015 Steve Kemp .
52              
53             This library is free software. You can modify and or distribute it under
54             the same terms as Perl itself.
55              
56             =cut
57              
58             =head1 METHODS
59              
60             =cut
61              
62              
63              
64 11     11   61 use strict;
  11         16  
  11         277  
65 11     11   51 use warnings;
  11         13  
  11         1334  
66              
67              
68             package Templer::Site::Asset;
69              
70              
71              
72             =head2 new
73              
74             The constructor.
75              
76             The single appropriate argument is the hash-key "file", pointing to the
77             file on-disk.
78              
79             =cut
80              
81             sub new
82             {
83 15     15 1 32 my ( $proto, %supplied ) = (@_);
84 15   33     35 my $class = ref($proto) || $proto;
85              
86 15         21 my $self = {};
87              
88             #
89             # Allow user supplied values to override our defaults
90             #
91 15         24 foreach my $key ( keys %supplied )
92             {
93 15         44 $self->{ lc $key } = $supplied{ $key };
94             }
95              
96 15         19 bless( $self, $class );
97 15         33 return $self;
98             }
99              
100              
101             =head2 source
102              
103             Return the filename we were built from. This is the value passed
104             in the constructor.
105              
106             =cut
107              
108             sub source
109             {
110 25     25 1 29 my ($self) = (@_);
111 25         48 $self->{ "file" };
112             }
113              
114              
115              
116             1;