| 1 | package CSS::Struct::Output::Raw; | ||||||||||
| 2 | |||||||||||
| 3 | 14 | ▶ | use base qw(CSS::Struct::Output); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 14 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | # Constants. | ||||||||||
| 10 | 14 | Readonly::Scalar my $EMPTY_STR => q{}; | |||||||||
| 11 | |||||||||||
| 12 | 14 | our $VERSION = 0.02; | |||||||||
| 13 | |||||||||||
| 14 | # Resets internal variables. | ||||||||||
| 15 | sub reset { | ||||||||||
| 16 | 35 | ▶ | my $self = shift; | ||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 17 | |||||||||||
| 18 | # Reset internal variables from main class. | ||||||||||
| 19 | 35 | $self->SUPER::reset; | |||||||||
| 20 | |||||||||||
| 21 | # Comment after selector. | ||||||||||
| 22 | 35 | $self->{'comment_after_selector'} = 0; | |||||||||
| 23 | |||||||||||
| 24 | 35 | return; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | # Flush $self->{'tmp_code'}. | ||||||||||
| 28 | sub _flush_tmp { | ||||||||||
| 29 | 42 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_flush_tmp: called CC=3 SCAR=11.0
| |||||||||||
| 30 | 42 | ▶ | if (@{$self->{'tmp_code'}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 26 | my @comment; | |||||||||
| 32 | 26 | ▶ | if ($self->{'comment_after_selector'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 2 | @comment = splice @{$self->{'tmp_code'}}, | |||||||||
| 34 | 2 | -$self->{'comment_after_selector'}; | |||||||||
| 35 | } | ||||||||||
| 36 | 26 | pop @{$self->{'tmp_code'}}; | |||||||||
| 37 | $self->{'flush_code'} .= | ||||||||||
| 38 | 26 | (join $EMPTY_STR, @{$self->{'tmp_code'}}).'{'. | |||||||||
| 39 | (join $EMPTY_STR, @comment); | ||||||||||
| 40 | 26 | $self->{'tmp_code'} = []; | |||||||||
| 41 | } | ||||||||||
| 42 | 42 | return; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | # At-rules. | ||||||||||
| 46 | sub _put_at_rules { | ||||||||||
| 47 | 1 | ▶ | my ($self, $at_rule, $file) = @_; | ||||||||
|
Subroutine
_put_at_rules: called CC=1 SCAR=0.0
| |||||||||||
| 48 | 1 | $self->{'flush_code'} .= $at_rule.' "'.$file.'";'; | |||||||||
| 49 | 1 | return; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | # Comment. | ||||||||||
| 53 | sub _put_comment { | ||||||||||
| 54 | 21 | ▶ | my ($self, @comments) = @_; | ||||||||
|
Subroutine
_put_comment: called CC=3 SCAR=11.0
| |||||||||||
| 55 | 21 | ▶ | if (! $self->{'skip_comments'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 11 | push @comments, $self->{'comment_delimeters'}->[1]; | |||||||||
| 57 | 11 | unshift @comments, $self->{'comment_delimeters'}->[0]; | |||||||||
| 58 | 11 | my $comment = join $EMPTY_STR, @comments; | |||||||||
| 59 | 11 | ▶ | if (@{$self->{'tmp_code'}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 4 | push @{$self->{'tmp_code'}}, $comment; | |||||||||
| 61 | 4 | $self->{'comment_after_selector'}++; | |||||||||
| 62 | } else { | ||||||||||
| 63 | 7 | $self->{'flush_code'} .= $comment; | |||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | 21 | return; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | # Definition. | ||||||||||
| 70 | sub _put_definition { | ||||||||||
| 71 | 16 | ▶ | my ($self, $key, $value) = @_; | ||||||||
|
Subroutine
_put_definition: called CC=1 SCAR=0.0
| |||||||||||
| 72 | 16 | $self->_check_opened_selector; | |||||||||
| 73 | 16 | $self->_flush_tmp; | |||||||||
| 74 | 16 | $self->{'flush_code'} .= $key.':'.$value.';'; | |||||||||
| 75 | 16 | return; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | # End of selector. | ||||||||||
| 79 | sub _put_end_of_selector { | ||||||||||
| 80 | 27 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_put_end_of_selector: called CC=1 SCAR=0.0
| |||||||||||
| 81 | 27 | $self->_check_opened_selector; | |||||||||
| 82 | 26 | $self->_flush_tmp; | |||||||||
| 83 | 26 | $self->{'flush_code'} .= '}'; | |||||||||
| 84 | 26 | $self->{'open_selector'} = 0; | |||||||||
| 85 | 26 | return; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | # Instruction. | ||||||||||
| 89 | sub _put_instruction { | ||||||||||
| 90 | 2 | ▶ | my ($self, $target, $code) = @_; | ||||||||
|
Subroutine
_put_instruction: called CC=1 SCAR=0.0
| |||||||||||
| 91 | 2 | $self->_put_comment($target, $code); | |||||||||
| 92 | 2 | return; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | # Raw data. | ||||||||||
| 96 | sub _put_raw { | ||||||||||
| 97 | 1 | ▶ | my ($self, @raw_data) = @_; | ||||||||
|
Subroutine
_put_raw: called CC=1 SCAR=0.0
| |||||||||||
| 98 | |||||||||||
| 99 | # To flush code. | ||||||||||
| 100 | 1 | $self->{'flush_code'} .= join $EMPTY_STR, @raw_data; | |||||||||
| 101 | |||||||||||
| 102 | 1 | return; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | # Selectors. | ||||||||||
| 106 | sub _put_selector { | ||||||||||
| 107 | 31 | ▶ | my ($self, $selector) = @_; | ||||||||
|
Subroutine
_put_selector: called CC=1 SCAR=0.0
| |||||||||||
| 108 | 31 | push @{$self->{'tmp_code'}}, $selector, ','; | |||||||||
| 109 | 31 | $self->{'comment_after_selector'} = 0; | |||||||||
| 110 | 31 | $self->{'open_selector'} = 1; | |||||||||
| 111 | 31 | return; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | # Reset flush code. | ||||||||||
| 115 | sub _reset_flush_code { | ||||||||||
| 116 | 36 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_reset_flush_code: called CC=1 SCAR=0.0
| |||||||||||
| 117 | 36 | $self->{'flush_code'} = $EMPTY_STR; | |||||||||
| 118 | 36 | return; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | 14 | 1; | |||||||||
| 122 | |||||||||||
| 123 | __END__ | ||||||||||