line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rails::Assets::Base { |
2
|
5
|
|
|
5
|
|
123697
|
use 5.006; |
|
5
|
|
|
|
|
15
|
|
3
|
5
|
|
|
5
|
|
22
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
76
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
93
|
|
5
|
5
|
|
|
5
|
|
25
|
use File::Find; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
291
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
5
|
|
|
5
|
|
25
|
use Exporter qw(import); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
1902
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw( |
10
|
|
|
|
|
|
|
find_files |
11
|
|
|
|
|
|
|
prepare_extensions_refs |
12
|
|
|
|
|
|
|
prepare_assets_refs |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub find_files { |
16
|
6
|
|
|
6
|
1
|
2543
|
my $dirs = shift; |
17
|
6
|
100
|
|
|
|
9
|
die "Invalid reference provided. Expected ARRAY of directories: $!" unless (scalar @{$dirs} > 0); |
|
6
|
|
|
|
|
29
|
|
18
|
5
|
|
|
|
|
10
|
my @found; |
19
|
5
|
100
|
|
97
|
|
21
|
my $wanted = sub { push @found, $File::Find::name if -f }; |
|
97
|
|
|
|
|
3129
|
|
20
|
5
|
|
|
|
|
362
|
find({ wanted => $wanted, no_chdir=> 1}, @$dirs); |
21
|
5
|
|
|
|
|
26
|
return [sort {"\L$a" cmp "\L$b"} @found]; |
|
121
|
|
|
|
|
303
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub prepare_extensions_refs { |
25
|
7
|
|
|
7
|
1
|
527
|
my ($extensions) = @_; |
26
|
7
|
|
|
|
|
14
|
my $extensions_keys = format_extensions_list($extensions); |
27
|
7
|
|
|
|
|
34
|
my ($assets); |
28
|
7
|
|
|
|
|
33
|
$assets->{$_} = [()] foreach (@$extensions_keys); |
29
|
7
|
|
|
|
|
18
|
return $assets; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub prepare_assets_refs { |
33
|
3
|
|
|
3
|
1
|
1973
|
my ($dirs, $extensions) = @_; |
34
|
3
|
|
|
|
|
12
|
my $extensions_keys = format_extensions_list($extensions); |
35
|
3
|
|
|
|
|
12
|
my $assets = prepare_extensions_refs($extensions_keys); |
36
|
3
|
|
|
|
|
8
|
my ($assets_path, $reversed_ext); |
37
|
3
|
|
|
|
|
8
|
foreach my $d (@$dirs){ |
38
|
9
|
100
|
|
|
|
39
|
unless ($d =~ /public/) { |
39
|
6
|
|
|
|
|
39
|
push @$assets_path, "$d$_/" foreach (qw(fonts javascripts stylesheets)); |
40
|
|
|
|
|
|
|
} |
41
|
9
|
|
|
|
|
22
|
push @$assets_path, $d; |
42
|
|
|
|
|
|
|
} |
43
|
3
|
|
|
|
|
8
|
foreach my $key (@$extensions_keys){ |
44
|
12
|
|
|
|
|
19
|
$reversed_ext->{$_} = $key foreach (@{$extensions->{$key}}); |
|
12
|
|
|
|
|
53
|
|
45
|
|
|
|
|
|
|
} |
46
|
3
|
|
|
|
|
14
|
return ($assets, $assets_path, $reversed_ext); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub format_extensions_list { |
50
|
13
|
|
|
13
|
1
|
1461
|
my ($extensions) = @_; |
51
|
13
|
100
|
|
|
|
96
|
return [(sort keys %$extensions)] if (ref($extensions) eq 'HASH'); |
52
|
5
|
100
|
|
|
|
20
|
return $extensions if(ref($extensions) eq 'ARRAY'); |
53
|
1
|
|
|
|
|
8
|
die "Invalid extension argument provided: $!"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Rails::Assets::Base - provides some utilities functions for Assets detection in a Rails project. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Version 0.02 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This module provide some utilities functions |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
use Rails::Assets::Base; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $template_hash = prepare_extensions_refs($assets_extensions); |
73
|
|
|
|
|
|
|
my ($assets_hash, $assets_paths, $reversed_ext) = |
74
|
|
|
|
|
|
|
prepare_assets_refs($assets_directories, $assets_extensions); |
75
|
|
|
|
|
|
|
... |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 EXPORT |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 prepare_extensions_refs |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 prepare_assets_refs |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 find_files |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 format_extensions_list |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Mauro Berlanda, C<< <kupta at cpan.org> >> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 BUGS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through |
96
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll |
97
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SUPPORT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
perldoc Rails::Assets::Base |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
You can also look for information at: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=.> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<http://annocpan.org/dist/.> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * CPAN Ratings |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/.> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * Search CPAN |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/./> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2017 Mauro Berlanda. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
135
|
|
|
|
|
|
|
copy of the full license at: |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
140
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
141
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
142
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
145
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
146
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
149
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
152
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
153
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
154
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
155
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
156
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
157
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
158
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
161
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
162
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
163
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
164
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
165
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
166
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
167
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
172
|
|
|
|
|
|
|
|