| 1 | package CSS::Struct::Output::Structure; | ||||||||||
| 2 | |||||||||||
| 3 | 11 | ▶ | use base qw(CSS::Struct::Output); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 11 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 11 | our $VERSION = 0.02; | |||||||||
| 10 | |||||||||||
| 11 | sub flush { | ||||||||||
| 12 | 19 | ▶ | my ($self, $reset_flag) = @_; | ||||||||
|
Subroutine
flush: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 13 | |||||||||||
| 14 | 19 | my $ouf = $self->{'output_handler'}; | |||||||||
| 15 | |||||||||||
| 16 | # Text output. | ||||||||||
| 17 | 19 | my $ret_ar; | |||||||||
| 18 | 19 | ▶ | if ($ouf) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 7 | foreach my $line_ar (@{$self->{'flush_code'}}) { | |||||||||
| 20 | 10 | my $line = "['"; | |||||||||
| 21 | 10 | $line .= join "', '", @{$line_ar}; | |||||||||
| 22 | 10 | $line .= "']".$self->{'output_sep'}; | |||||||||
| 23 | 11 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 10 | ▶ | print {$ouf} $line | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | or err 'Cannot write to output handler.'; | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # Structure. | ||||||||||
| 29 | } else { | ||||||||||
| 30 | 12 | $ret_ar = $self->{'flush_code'}; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | # Reset. | ||||||||||
| 34 | 19 | ▶ | if ($reset_flag) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | $self->reset; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 19 | return $ret_ar; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | # At-rules. | ||||||||||
| 42 | sub _put_at_rules { | ||||||||||
| 43 | 2 | ▶ | my ($self, $at_rule, $value) = @_; | ||||||||
|
Subroutine
_put_at_rules: called CC=1 SCAR=0.0
| |||||||||||
| 44 | |||||||||||
| 45 | 2 | $self->_put_structure('a', $at_rule, $value); | |||||||||
| 46 | |||||||||||
| 47 | 2 | return; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | # Comment. | ||||||||||
| 51 | sub _put_comment { | ||||||||||
| 52 | 4 | ▶ | my ($self, @comments) = @_; | ||||||||
|
Subroutine
_put_comment: called CC=1 SCAR=0.0
| |||||||||||
| 53 | |||||||||||
| 54 | 4 | $self->_put_structure('c', @comments); | |||||||||
| 55 | |||||||||||
| 56 | 4 | return; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | # Definition. | ||||||||||
| 60 | sub _put_definition { | ||||||||||
| 61 | 2 | ▶ | my ($self, $key, $value) = @_; | ||||||||
|
Subroutine
_put_definition: called CC=1 SCAR=0.0
| |||||||||||
| 62 | |||||||||||
| 63 | 2 | $self->_put_structure('d', $key, $value); | |||||||||
| 64 | |||||||||||
| 65 | 2 | return; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | # End of selector. | ||||||||||
| 69 | sub _put_end_of_selector { | ||||||||||
| 70 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_put_end_of_selector: called CC=1 SCAR=0.0
| |||||||||||
| 71 | |||||||||||
| 72 | 2 | $self->_put_structure('e'); | |||||||||
| 73 | |||||||||||
| 74 | 2 | return; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | # Instruction. | ||||||||||
| 78 | sub _put_instruction { | ||||||||||
| 79 | 2 | ▶ | my ($self, $target, $code) = @_; | ||||||||
|
Subroutine
_put_instruction: called CC=1 SCAR=0.0
| |||||||||||
| 80 | |||||||||||
| 81 | 2 | $self->_put_structure('i', $target, $code); | |||||||||
| 82 | |||||||||||
| 83 | 2 | return; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | # Raw data. | ||||||||||
| 87 | sub _put_raw { | ||||||||||
| 88 | 2 | ▶ | my ($self, @raw_data) = @_; | ||||||||
|
Subroutine
_put_raw: called CC=1 SCAR=0.0
| |||||||||||
| 89 | |||||||||||
| 90 | 2 | $self->_put_structure('r', @raw_data); | |||||||||
| 91 | |||||||||||
| 92 | 2 | return; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | # Selectors. | ||||||||||
| 96 | sub _put_selector { | ||||||||||
| 97 | 8 | ▶ | my ($self, $selector) = @_; | ||||||||
|
Subroutine
_put_selector: called CC=1 SCAR=0.0
| |||||||||||
| 98 | |||||||||||
| 99 | 8 | $self->_put_structure('s', $selector); | |||||||||
| 100 | |||||||||||
| 101 | 8 | return; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | # Put common structure. | ||||||||||
| 105 | sub _put_structure { | ||||||||||
| 106 | 22 | ▶ | my ($self, @struct) = @_; | ||||||||
|
Subroutine
_put_structure: called CC=1 SCAR=0.0
| |||||||||||
| 107 | |||||||||||
| 108 | 22 | push @{$self->{'flush_code'}}, \@struct; | |||||||||
| 109 | |||||||||||
| 110 | 22 | return; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | # Reset flush code. | ||||||||||
| 114 | sub _reset_flush_code { | ||||||||||
| 115 | 19 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_reset_flush_code: called CC=1 SCAR=0.0
| |||||||||||
| 116 | |||||||||||
| 117 | 19 | $self->{'flush_code'} = undef; | |||||||||
| 118 | |||||||||||
| 119 | 19 | return; | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 11 | 1; | |||||||||
| 123 | |||||||||||
| 124 | __END__ | ||||||||||