line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Colorist::Ruleset; |
2
|
|
|
|
|
|
|
$App::Colorist::Ruleset::VERSION = '0.150460'; |
3
|
1
|
|
|
1
|
|
5
|
use Moose (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
4
|
use Moose::Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Helper syntax for building colorist rulesets |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
9
|
|
|
|
|
|
|
as_is => [ qw( ruleset rule ) ], |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $BUILDING_RULESET; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub ruleset(&) { |
15
|
1
|
|
|
1
|
1
|
12
|
my $code = shift; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
4
|
$BUILDING_RULESET = []; |
18
|
1
|
|
|
|
|
4
|
$code->(); |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
2
|
my $r = $BUILDING_RULESET; |
21
|
1
|
|
|
|
|
3
|
undef $BUILDING_RULESET; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
13
|
return $r; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub rule { |
27
|
9
|
|
|
9
|
1
|
42
|
my ($regex, @names) = @_; |
28
|
9
|
|
|
|
|
25
|
push @$BUILDING_RULESET, $regex, \@names; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding UTF-8 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
App::Colorist::Ruleset - Helper syntax for building colorist rulesets |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 0.150460 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
ruleset { |
50
|
|
|
|
|
|
|
rule qr{Starting (\S+)\.\.\.}, qw( message program ); |
51
|
|
|
|
|
|
|
rule qr{Finished processing (http://([\w.]+)/) \.\.\.}, qw( |
52
|
|
|
|
|
|
|
message url hostname |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This defines a special syntax that may be used in ruleset configuration files for defining a ruleset. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DIRECTIVES |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 ruleset |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
ruleset { |
65
|
|
|
|
|
|
|
# rules go in here ... |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
There may only be exactly one C<ruleset> per ruleset configuration and all L</rule> directives must be placed inside it. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 rule |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
rule qr{Starting (\S+)\.\.\.}, qw( message program ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Within a L</ruleset>, there may be zero or more C<rule> directives. Each is given a regular expression to be used to match against a single line of text. Every match starts with an implicit "^" and ends with an implicit "$", so it must match an entire line. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
After the regular expression, you must include a list of color names to assign each part of the match. This list must have at least one element in it, which is used for the entire line match. There must also be one for each group of parenthesis in the regular expression. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
It is perfectly acceptable to use nested matches. As of this writing, there must be a fixed number of group matches, though. If you need to match groups like C<< (...)* >>, there's no way to name them at this time, so don't do that. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Qubling Software LLC. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
89
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |