File Coverage

blib/lib/File/Assets/Asset.pm
Criterion Covered Total %
statement 101 129 78.2
branch 49 78 62.8
condition 35 53 66.0
subroutine 21 29 72.4
pod 10 18 55.5
total 216 307 70.3


line stmt bran cond sub pod time code
1             package File::Assets::Asset;
2              
3 24     24   151 use warnings;
  24         53  
  24         1016  
4 24     24   137 use strict;
  24         67  
  24         790  
5              
6 24     24   13338 use File::Assets::Util;
  24         77  
  24         752  
7 24     24   159 use File::Assets::Carp;
  24         50  
  24         287  
8 24     24   18839 use File::Assets::Asset::Content;
  24         63  
  24         218  
9              
10 24     24   21156 use XML::Tiny;
  24         37713  
  24         1490  
11 24     24   22342 use IO::Scalar;
  24         101445  
  24         1230  
12 24     24   192 use Object::Tiny qw/type rank attributes hidden rsc outside/;
  24         56  
  24         192  
13 24     24   6143 use Scalar::Util qw/blessed/;
  24         53  
  24         40502  
14              
15             =head1 SYNPOSIS
16              
17             my $asset = File::Asset->new(base => $base, path => "/static/assets.css");
18             $asset = $assets->include("/static/assets.css"); # Or, like this, usually.
19              
20             print "The rank for asset at ", $asset->uri, " is ", $asset->rank, "\n";
21             print "The file for the asset is ", $asset->file, "\n";
22              
23             =head1 DESCRIPTION
24              
25             A File::Asset object represents an asset existing in both URI-space and file-space (on disk). The asset is usually a .js (JavaScript) or .css (CSS) file.
26              
27             =head1 METHODS
28              
29             =head2 File::Asset->new( base => , path => , [ rank => , type => ])
30              
31             Creates a new File::Asset. You probably don't want to use this, create a L object and use $assets->include instead.
32              
33             =cut
34              
35             sub _html_parse ($) {
36 2     2   24 XML::Tiny::parsefile(IO::Scalar->new(shift));
37             }
38              
39             sub new {
40 188     188 1 8250 my $self = bless {}, shift;
41 188 50 33     1462 my $asset = @_ == 1 && ref $_[0] eq "HASH" ? shift : { @_ };
42              
43 188         655 my $content = delete $asset->{content};
44 188 100       502 $content = ref $content eq "SCALAR" ? $$content : $content;
45 188 100 100     846 if (defined $content && $content =~ m/^\s* or