File Coverage

blib/lib/Rails/Assets/Formatter.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1             package Rails::Assets::Formatter {
2              
3 5     5   52295   use 5.006;
  5         14  
4 5     5   19   use strict;
  5         8  
  5         82  
5 5     5   17   use warnings;
  5         8  
  5         188  
6              
7               our $VERSION = '0.01';
8 5     5   21   use Exporter qw(import);
  5         7  
  5         754  
9               our @EXPORT = qw(
10             format_asset_elem
11             format_referral_elem
12             format_template_elem
13             );
14              
15               sub format_asset_elem {
16 27     27 1 1231     my ($asset_file, $ext, $assets_paths) = @_;
17 27         37     my $asset_name = $asset_file;
18 27         1066     $asset_name =~ s/$_// foreach (@$assets_paths);
19                 return {
20 27         108       name => $asset_name,
21                   full_path => $asset_file,
22                   ext => $ext,
23                 };
24               }
25              
26               sub format_referral_elem {
27 21     21 1 569     my ($asset_name, $ext, $referral) = @_;
28                 return {
29 21         72       name => $asset_name,
30                   referral => $referral,
31                   ext => $ext,
32                 };
33               }
34              
35               sub format_template_elem {
36 22     22 1 484     my ($template_file, $asset_name) = @_;
37                 return {
38 22         83       name => $asset_name,
39                   full_path => $template_file,
40                 }
41               }
42             }
43              
44             =head1 NAME
45            
46             Rails::Assets::Formatter - provide utility functions for formatting assets refs
47            
48             =head1 VERSION
49            
50             Version 0.02
51            
52             =head1 SYNOPSIS
53            
54             This module provide some utility functions for formatting data structures while parsing assets.
55            
56             use Rails::Assets::Formatter;
57            
58             my $a = format_asset_elem($asset_file, $ext, $assets_paths);
59             my $b = format_referral_elem($asset_file, $ext, $referral);
60             my $c = format_template_elem($template_file, $asset_name);
61             ...
62            
63             =head1 EXPORT
64            
65             A list of functions that can be exported. You can delete this section
66             if you don't export anything, such as for a purely object-oriented module.
67            
68             =head1 SUBROUTINES/METHODS
69            
70             =head2 format_asset_elem
71            
72             =head2 format_referral_elem
73            
74             =head2 format_template_elem
75            
76             =head1 AUTHOR
77            
78             Mauro Berlanda, C<< <kupta at cpan.org> >>
79            
80             =head1 BUGS
81            
82             Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through
83             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll
84             automatically be notified of progress on your bug as I make changes.
85            
86             =head1 SUPPORT
87            
88             You can find documentation for this module with the perldoc command.
89            
90             perldoc Rails::Assets::Formatter
91            
92             You can also look for information at:
93            
94             =over 4
95            
96             =item * RT: CPAN's request tracker (report bugs here)
97            
98             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=.>
99            
100             =item * AnnoCPAN: Annotated CPAN documentation
101            
102             L<http://annocpan.org/dist/.>
103            
104             =item * CPAN Ratings
105            
106             L<http://cpanratings.perl.org/d/.>
107            
108             =item * Search CPAN
109            
110             L<http://search.cpan.org/dist/./>
111            
112             =back
113            
114             =head1 ACKNOWLEDGEMENTS
115            
116             =head1 LICENSE AND COPYRIGHT
117            
118             Copyright 2017 Mauro Berlanda.
119            
120             This program is free software; you can redistribute it and/or modify it
121             under the terms of the the Artistic License (2.0). You may obtain a
122             copy of the full license at:
123            
124             L<http://www.perlfoundation.org/artistic_license_2_0>
125            
126             Any use, modification, and distribution of the Standard or Modified
127             Versions is governed by this Artistic License. By using, modifying or
128             distributing the Package, you accept this license. Do not use, modify,
129             or distribute the Package, if you do not accept this license.
130            
131             If your Modified Version has been derived from a Modified Version made
132             by someone other than you, you are nevertheless required to ensure that
133             your Modified Version complies with the requirements of this license.
134            
135             This license does not grant you the right to use any trademark, service
136             mark, tradename, or logo of the Copyright Holder.
137            
138             This license includes the non-exclusive, worldwide, free-of-charge
139             patent license to make, have made, use, offer to sell, sell, import and
140             otherwise transfer the Package with respect to any patent claims
141             licensable by the Copyright Holder that are necessarily infringed by the
142             Package. If you institute patent litigation (including a cross-claim or
143             counterclaim) against any party alleging that the Package constitutes
144             direct or contributory patent infringement, then this Artistic License
145             to you shall terminate on the date that such litigation is filed.
146            
147             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
148             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
149             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
150             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
151             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
152             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
153             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
154             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
155            
156             =cut
157              
158             1; # End of Rails::Assets::Formatter
159