read_file( params )
Opens and reads a CSS file, then subsequently performs the parsing of the CSS file necessary for
later manipulation.
This method requires you to pass in a params hash that contains a filename argument. For example:
$self->read_file({ filename => 'myfile.css' });
read( params )
Reads css data and parses it. The intermediate data is stored in class variables.
Compound selectors (i.e. "a, span") are split apart during parsing and stored separately, so the
output of any given stylesheet may not match the output 100%, but the rules themselves should apply
as expected.
This method requires you to pass in a params hash that contains scalar css data. For example:
$self->read({ css => $css });
write_file()
Write the parsed and manipulated CSS out to a file parameter
This method requires you to pass in a params hash that contains a filename argument. For example:
$self->write_file({ filename => 'myfile.css' });
write()
Write the parsed and manipulated CSS out to a scalar and return it
This code makes some assumptions about the nature of the prelude and data portions of the stored css
rules and possibly is insufficient.
content_warnings()
Return back any warnings thrown while parsing a given block of css
Note: content warnings are initialized at read time. In order to receive back content feedback you
must perform read() first.
get_rules( params )
Get an array of rules representing the composition of the stylesheet. These rules are returned in the
exact order that they were discovered. Both qualified and at rules are returned by this method. It is
left to the caller to pull out the kinds of rules your application needs to accomplish your goals.
The structures returned match up with the fields set while adding the rules via the add_x_rule
collection methods.
Specifically at-rules will contain a type, prelude and block while qualified rules will contain a
selector and declarations.
add_qualified_rule( params )
Add a qualified CSS rule to the ruleset store.
The most common type of CSS rule is a qualified rule. This term became more prominent with the rise
of CSS3, but is still relevant when handling earlier versions of the standard. These rules have a
prelude consisting of a CSS selector, along with a data block consisting of various rule
declarations.
Adding a qualified rule is trivial, for example: $self->add_qualified_rule({ selector => 'p > a',
block => 'color: blue;' });
add_at_rule( params )
Add an at-rule to the ruleset store.
The less common variants of CSS rules are know as at-rules. These rules implement various behaviours
through various expressions containing a rule type, prelude and associated data block. The standard
is evolving here, so it is not easy to enumerate such examples, but these rules always start with @.
At rules are a little more complex, an example: $self->add_at_rule({ type => '@media', prelude =>
'print', block => 'body { font-size: 10pt; }' });