line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## CSS Object Oriented - ~/lib/CSS/Object/Parser.pm |
3
|
|
|
|
|
|
|
## Version v0.1.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <@sitael.local> |
6
|
|
|
|
|
|
|
## Created 2020/06/21 |
7
|
|
|
|
|
|
|
## Modified 2020/06/21 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
package CSS::Object::Parser; |
11
|
|
|
|
|
|
|
BEGIN |
12
|
|
|
|
|
|
|
{ |
13
|
4
|
|
|
4
|
|
2217
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
124
|
|
14
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
120
|
|
15
|
4
|
|
|
4
|
|
20
|
use parent qw( Module::Generic ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
23
|
|
16
|
4
|
|
|
4
|
|
268
|
use Devel::Confess; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
28
|
|
17
|
4
|
|
|
4
|
|
891
|
our $VERSION = 'v0.1.0'; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init |
21
|
|
|
|
|
|
|
{ |
22
|
6
|
|
|
6
|
1
|
610
|
my $self = shift( @_ ); |
23
|
6
|
|
50
|
|
|
27
|
my $css = shift( @_ ) || |
24
|
|
|
|
|
|
|
return( $self->error( "No CSS object provided." ) ); |
25
|
6
|
50
|
|
|
|
38
|
return( $self->error( "CSS object provded is actually not a CSS::Object object." ) ) if( !$self->_is_a( $css, 'CSS::Object' ) ); |
26
|
6
|
|
|
|
|
138
|
$self->{_init_strict_use_sub} = 1; |
27
|
6
|
|
|
|
|
38
|
$self->SUPER::init( @_ ); |
28
|
6
|
50
|
|
|
|
279
|
$self->css( $css ) || return; |
29
|
6
|
|
|
|
|
191
|
return( $self ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
24
|
|
|
24
|
1
|
130
|
sub css { return( shift->_set_get_object( 'css', 'CSS::Object', @_ ) ); } |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
sub parse_string { return( shift->error( "You cannot use this class directly. Please use one of the Parser subclasses." ) ); } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding utf-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
CSS::Object::Parser - CSS Object Oriented Parser |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use CSS::Object::Parser; |
49
|
|
|
|
|
|
|
my $parser = CSS::Object::Parser->new( debug => 3 ); |
50
|
|
|
|
|
|
|
my $rules = $parser->parse_string( $css_text_data ) || |
51
|
|
|
|
|
|
|
die( CSS::Object::Parser->error ); |
52
|
|
|
|
|
|
|
printf( "Found %d rules\n", $rules->length ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
v0.1.0 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L<CSS::Object::Parser> is base CSS parser for L<CSS::Object> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 new |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
To instantiate a new L<CSS::Object::Parser> object, pass an hash reference of following parameters: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item I<debug> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is an integer. The bigger it is and the more verbose is the output. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item I<format> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 css |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This sets or gets a L<CSS::Object> object. This object is used to create css elements and store them with the L<CSS::Object/add_element> method. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 format |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 parse_string |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
In this base module, this method does nothing but trigger an error that it should not be called directly, but instead use this module sub classes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L<CSS::Object> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright (c) 2020 DEGUEST Pte. Ltd. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
107
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |