line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Watcher::ParserLess; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Path::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
7
|
1
|
|
|
1
|
|
748
|
use File::Which; |
|
1
|
|
|
|
|
964
|
|
|
1
|
|
|
|
|
64
|
|
8
|
1
|
|
|
1
|
|
839
|
use IPC::Run3; |
|
1
|
|
|
|
|
25413
|
|
|
1
|
|
|
|
|
61
|
|
9
|
1
|
|
|
1
|
|
10
|
use Log::Log4perl qw(:easy); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
706
|
use CSS::Watcher::Parser; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
478
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
5
|
|
|
5
|
0
|
9
|
my $class = shift; |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
30
|
return bless ({}, $class); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub parse_less { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $filename = shift; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $cmd = [ $self->executable, |
24
|
|
|
|
|
|
|
'--no-color', |
25
|
|
|
|
|
|
|
$filename |
26
|
|
|
|
|
|
|
]; |
27
|
0
|
|
|
|
|
|
my $err; |
28
|
|
|
|
|
|
|
my $out; |
29
|
0
|
|
|
|
|
|
local ($!, $?) = (0, -1); |
30
|
0
|
|
|
|
|
|
IPC::Run3::run3($cmd, undef, \$out, \$err, {return_if_system_error => 1}); |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (!$?) { |
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$err = ''; |
34
|
|
|
|
|
|
|
} elsif ($! == 2) { |
35
|
0
|
|
|
|
|
|
ERROR sprintf "Cannot execute '%s'. See http://lesscss.org/#usage", $cmd->[0]; |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
|
DEBUG sprintf "Failed to run \"%s\":\n %s\n%s", join(' ', @$cmd), $err, $out; |
38
|
0
|
|
|
|
|
|
$out = ''; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my ($classes, $ids) = ({}, {}); |
42
|
0
|
0
|
|
|
|
|
if ($out ne '') { |
43
|
0
|
|
|
|
|
|
INFO sprintf '%s: lessc done, parsing generated CSS', path($filename)->basename; |
44
|
0
|
|
|
|
|
|
($classes, $ids) = CSS::Watcher::Parser->new->parse_css($out); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Find dependencies for this less file. |
48
|
0
|
|
|
|
|
|
my @requiries; |
49
|
0
|
|
|
|
|
|
foreach (path($filename)->lines_utf8()) { |
50
|
0
|
0
|
|
|
|
|
(m/^\s*?\@import\s+"(.*?.less)"/) ? push @requiries, $1 : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
|
|
|
|
|
|
(m/^\s*?\@import\s+"(.*?.css)"/) ? push @requiries, $1 : |
52
|
|
|
|
|
|
|
(m/^\s*?\@import\s+"(.*?)"/) ? push @requiries, $1 . '.less' : 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
INFO sprintf "%s: imports: %s", path($filename)->basename, join(', ', @requiries) if (@requiries); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return ($classes, $ids, \@requiries); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub executable { |
61
|
0
|
0
|
|
0
|
0
|
|
File::Which::which('lessc') || 'lessc' ; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |