line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::SpriteBuilder::SpriteItem; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
59
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
106
|
|
4
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
512
|
|
|
4
|
|
|
|
|
125
|
|
5
|
4
|
|
|
4
|
|
1089
|
use base 'CSS::SpriteBuilder::ImageDriver::Auto'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1670
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
3
|
|
|
3
|
1
|
10
|
my ($class, @args) = @_; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
|
|
24
|
my $self = $class->SUPER::new( |
11
|
|
|
|
|
|
|
source_file => undef, |
12
|
|
|
|
|
|
|
is_background => undef, |
13
|
|
|
|
|
|
|
is_repeat => 0, |
14
|
|
|
|
|
|
|
css_selector => undef, |
15
|
|
|
|
|
|
|
@args, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
3
|
50
|
|
|
|
12
|
my $source_file = $self->{source_file} |
19
|
|
|
|
|
|
|
or die "The 'source_file' parameter is required"; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
21
|
$self->read($source_file); |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
11
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
6
|
0
|
103
|
sub source_file { return $_[0]->{source_file } } |
27
|
3
|
|
|
3
|
0
|
61
|
sub is_background { return $_[0]->{is_background } } |
28
|
0
|
|
|
0
|
0
|
0
|
sub is_repeat { return $_[0]->{is_repeat } } |
29
|
0
|
|
|
0
|
0
|
0
|
sub css_selector { return $_[0]->{css_selector } } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_css_selector { |
32
|
3
|
|
|
3
|
0
|
6
|
my ($self, $css_selector_prefix) = @_; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
5
|
my $selector = $self->{css_selector}; |
35
|
3
|
50
|
|
|
|
9
|
unless ($selector) { |
36
|
|
|
|
|
|
|
# Convert "img/icon/arrow.gif" to ".spr-img-icon-arrow" |
37
|
3
|
|
|
|
|
28
|
my (undef, $dirs, $file) = File::Spec->splitpath( $self->{source_file} ); |
38
|
3
|
|
|
|
|
40
|
my @dirs = grep { $_ } File::Spec->splitdir($dirs); |
|
6
|
|
|
|
|
43
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# remove extension |
41
|
3
|
|
|
|
|
17
|
$file =~ s/\.[^\.]+$//; |
42
|
3
|
|
50
|
|
|
29
|
$selector = lc( ($css_selector_prefix || '') . join('-', @dirs, $file) ); |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
12
|
$selector =~ s/[\s_]+/-/g; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
14
|
return $selector; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |