| 1 | package CSS::SpriteBuilder::SpriteItem; | ||||||||||||
| 2 | |||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 4 | ▶ | use base 'CSS::SpriteBuilder::ImageDriver::Auto'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 3 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 8 | 3 | my ($class, @args) = @_; | |||||||||||
| 9 | |||||||||||||
| 10 | 3 | 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 | my $source_file = $self->{source_file} | ||||||||||||
| 19 | 3 | ▶ | or die "The 'source_file' parameter is required"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | |||||||||||||
| 21 | 3 | $self->read($source_file); | |||||||||||
| 22 | |||||||||||||
| 23 | 3 | return $self; | |||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 6 | ▶ | sub source_file { return $_[0]->{source_file } } | ||||||||||
|
Subroutine
source_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 27 | 3 | ▶ | sub is_background { return $_[0]->{is_background } } | ||||||||||
|
Subroutine
is_background: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 28 | 0 | ▶ | sub is_repeat { return $_[0]->{is_repeat } } | ||||||||||
|
Subroutine
is_repeat: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 29 | 0 | ▶ | sub css_selector { return $_[0]->{css_selector } } | ||||||||||
|
Subroutine
css_selector: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 30 | |||||||||||||
| 31 | 3 | ▶ | sub get_css_selector { | ||||||||||
|
Subroutine
get_css_selector: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||
| 32 | 3 | my ($self, $css_selector_prefix) = @_; | |||||||||||
| 33 | |||||||||||||
| 34 | 3 | my $selector = $self->{css_selector}; | |||||||||||
| 35 | 3 | ▶ | unless ($selector) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | # Convert "img/icon/arrow.gif" to ".spr-img-icon-arrow" | ||||||||||||
| 37 | 3 | my (undef, $dirs, $file) = File::Spec->splitpath( $self->{source_file} ); | |||||||||||
| 38 | 3 | my @dirs = grep { $_ } File::Spec->splitdir($dirs); | |||||||||||
| 39 | |||||||||||||
| 40 | # remove extension | ||||||||||||
| 41 | 3 | $file =~ s/\.[^\.]+$//; | |||||||||||
| 42 | 3 | ▶ | $selector = lc( ($css_selector_prefix || '') . join('-', @dirs, $file) ); | ||||||||||
|
Condition50%1/2
$css_selector_prefix || ''
MC/DC0%0/1
$css_selector_prefix || ''
$css_selector_prefix
Truth table50%1/2
A
A= $css_selector_prefix
| |||||||||||||
| 43 | |||||||||||||
| 44 | 3 | $selector =~ s/[\s_]+/-/g; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 3 | return $selector; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 4 | 1; | |||||||||||