File Coverage

blib/lib/XML/Essex/Constants.pm
Criterion Covered Total %
statement 10 10 100.0
branch 5 10 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 20 25 80.0


line stmt bran cond sub pod time code
1             package XML::Essex::Constants;
2              
3             $VERSION = 0.000_1;
4              
5             =head1 NAME
6              
7             XML::Essex::Constants - Export a few constants used within Essex
8              
9             =head1 SYNOPSIS
10              
11             use XML::Essex::Constants;
12              
13             =head1 DESCRIPTION
14              
15             This is really for internal use only and is not needed by outside
16             callers. Subclasses of XML::Filter::Handler may also need this.
17              
18             Hacker's note: see the source for some minor magic used in debugging
19             and testing.
20              
21             =over
22              
23             =cut
24              
25 11     11   47623 use Carp qw( croak );
  11         23  
  11         2754  
26              
27             my %exports = map {
28             ( $_ => undef );
29             } qw( BOD EOD debugging SEPPUKU threaded_essex );
30              
31             sub import {
32 22     22   107 my $class = shift;
33 22         62 my $caller = caller;
34 16 50       122 *{"${caller}::$_"} = \&$_
  46         9088  
35 22 100       112 for ! @_
36             ? keys %exports
37             : grep {
38             exists $exports{$_} || croak "$_ not exported by $class";
39             } @_;
40             }
41              
42             =item debugging
43              
44             Returns 1 if $ENV{ESSEXDEBUG}, for now.
45              
46             =cut
47              
48             BEGIN {
49 11 0   11   993 eval join
    50          
    50          
50             $ENV{ESSEXDEBUG}
51             ? $ENV{ESSEXDEBUG} eq "VARY"
52             ? '$ENV{ESSEXDEBUG}'
53             : 1
54             : 0,
55             "sub debugging() {",
56             "} 1"
57             or die $@;
58             }
59              
60             =item BOD
61              
62             BOD is an event sent before the first event (a set_document_locator or
63             start_document) in a document. It is used to sync up the slave
64             thread. Right now, this means that any events before the first
65             set_document_locator or start_document are lost.
66              
67             =cut
68              
69             sub BOD() { "start of XML document" }
70              
71             =item EOD
72              
73             EOD is sent after the end_document to flag the fact that there
74             are no more events coming. This is not necessary, as the child
75             could trigger off the end_document, but it is convenient because
76             the child does not need to maintain any EndDocumentSeen state.
77             It also opens up the door for a "reset" method on the parent to force
78             the child's main() to exit, if we ever need that.
79              
80             =cut
81              
82             sub EOD() { "end of XML document" }
83              
84             =item SEPPUKU
85              
86             SEPPUKU is sent if the parent is DESTROYed so the child thread may
87             follow it in to oblivion, with honor.
88              
89             =cut
90              
91             sub SEPPUKU() { "end of parent life" }
92              
93             =item threaded_essex
94              
95             Returns 1 if Essex should use threads.
96              
97             =cut
98              
99             our $threading; ## Used only by t/XML-Handler-Essex-Threaded.t
100              
101 2     2 1 1680 eval join
102             exists $threads::{VERSION}
103             && defined $threads::VERSION
104             && $threads::VERSION >= 0.99
105             ? defined $threading
106             ? '$threading'
107             : 1
108             : 0,
109              
110             "sub threaded_essex() {",
111             "} 1"
112             or die $@;
113              
114             =back
115              
116             =head1 LIMITATIONS
117              
118             Does not pay attention to the parameter list passed with use(). This
119             is speedy and light, but not kind. It's for internal use only, however,
120             and this should be sufficient.
121              
122             =head1 COPYRIGHT
123              
124             Copyright 2002, R. Barrie Slaymaker, Jr., All Rights Reserved
125              
126             =head1 LICENSE
127              
128             You may use this module under the terms of the BSD, Artistic, oir GPL licenses,
129             any version.
130              
131             =head1 AUTHOR
132              
133             Barrie Slaymaker
134              
135             =cut
136              
137             1;