File Coverage

blib/lib/Web/AssetLib.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Web::AssetLib;
2             our $VERSION = '0.042';
3              
4 1     1   4412 use Method::Signatures;
  1         48408  
  1         11  
5 1     1   780 use Moose;
  1         304426  
  1         6  
6              
7 1     1   5079 no Moose;
  1         2  
  1         3  
8             1;
9             __END__
10              
11             =pod
12            
13             =encoding UTF-8
14            
15             =head1 NAME
16              
17             Web::AssetLib - Moose-based pluggable library manager for compiling and serving static assets
18              
19             =head1 VERSION
20            
21             version 0.042
22              
23             =head1 SYNOPSIS
24              
25             Create a library for your project:
26              
27             package My::Library;
28              
29             use Moose;
30              
31             extends 'Web::AssetLib::Library';
32              
33             sub jQuery{
34             return Web::AssetLib::Asset->new(
35             type => 'javascript',
36             input_engine => 'LocalFile',
37             rank => -100,
38             input_args => { path => "your/local/path/jquery.min.js", }
39             );
40             }
41              
42             1;
43              
44             Compile assets from that library:
45              
46             use My::Library;
47              
48             # configure at least one input and one output plugin
49             # (and optionally, a minifier plugin)
50             my $lib = My::Library->new(
51             input_engines => [
52             Web::AssetLib::InputEngine::LocalFile->new(
53             search_paths => ['/my/assets/root/']
54             )
55             ],
56             output_engines => [
57             Web::AssetLib::OutputEngine::LocalFile->new(
58             output_path => '/my/webserver/path/assets/'
59             )
60             ]
61             );
62              
63             # create an asset bundle to represent a group of assets
64             # that should be compiled together:
65              
66             my $homepage_javascript = Web::AssetLib::Bundle->new();
67             $hompage_javascript->addAsset($lib->jQuery);
68              
69              
70             # compile your bundle
71             my $html_tag = $lib->compile( bundle => $homepage_javascript )->as_html;
72              
73             =head1 DESCRIPTION
74              
75             Web::AssetLib allows you to build an easy-to-tweak input -> (minfiy) -> output
76             pipeline for web assets, as well as a framework for managing those assets.
77              
78             You have the option to compile groups of assets, or individual
79             ones. Out of the box, Web::AssetLib supports L<local file|Web::AssetLib::InputEngine::LocalFile>,
80             L<remote file|Web::AssetLib::InputEngine::RemoteFile>, and L<string|Web::AssetLib::InputEngine::Content>
81             inputs, minification with L<CSS::Minifier> and L<JavaScript::Minifier>, and
82             L<local file|Web::AssetLib::OutputEngine::LocalFile> output.
83              
84             Possibilities for future plugins: Amazon S3 output, other CDN outputs, SASS input, etc.
85              
86             This documentation uses method signature notation as defined by L<Method::Signatures>.
87              
88             =head1 USAGE
89            
90             Basic usage is covered in L<Web::AssetLib::Library>.
91              
92             The following base classes are provided for extendability:
93              
94             =over 4
95            
96             =item *
97            
98             L<Web::AssetLib::Library> — a base class for writing your own asset library, and configuring the various pipeline plugins
99            
100             =item *
101            
102             L<Web::AssetLib::InputEngine> — a base class for writing your own Input Engine
103            
104             =item *
105            
106             L<Web::AssetLib::OutputEngine> — a base class for writing your own Output Engine
107            
108             =item *
109            
110             L<Web::AssetLib::MinifierEngine> — a base class for writing your own Minifier Engine
111              
112             =back
113              
114             The following objects are used to define assets or groups of assets:
115              
116             =over 4
117              
118             =item *
119            
120             L<Web::AssetLib::Asset> — a representation of a particular asset in your library
121            
122             =item *
123            
124             L<Web::AssetLib::Bundle> — an indexed grouping of L<Web::AssetLib::Asset> objects
125            
126             =back
127              
128             Plugins provided by default:
129              
130             =over 4
131              
132             =item *
133            
134             L<Web::AssetLib::InputEngine::LocalFile> — allows importing an asset from your local filesystem
135            
136             =item *
137            
138             L<Web::AssetLib::InputEngine::RemoteFile> — allows importing an asset via a URL
139              
140             =item *
141            
142             L<Web::AssetLib::InputEngine::Content> — allows importing an asset as a raw string
143              
144             =item *
145            
146             L<Web::AssetLib::MinifierEngine::Standard> — basic CSS/Javascript minification utilizing
147             either L<CSS::Minifier> and L<JavaScript::Minifier> or L<CSS::Minifier::XS> and L<JavaScript::Minifier::XS>
148             depending on availability
149              
150             =item *
151            
152             L<Web::AssetLib::OutputEngine::LocalFile> — allows exporting an asset or bundle to your local filesystem
153            
154             =back
155              
156             =head1 SUPPORT
157            
158             =head2 Bugs / Feature Requests
159            
160             Please report any bugs or feature requests through the issue tracker
161             at L<https://github.com/ryan-lang/Web-AssetLib/issues>.
162             You will be notified automatically of any progress on your issue.
163            
164             =head2 Source Code
165            
166             This is open source software. The code repository is available for
167             public review and contribution under the terms of the license.
168            
169             L<https://github.com/ryan-lang/Web-AssetLib>
170            
171             git clone https://github.com/ryan-lang/Web-AssetLib.git
172            
173             =head1 AUTHOR
174            
175             Ryan Lang <rlang@cpan.org>
176              
177             =cut