blib/lib/Text/MicroMason/ApacheHandler.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran n/a Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 65 CC 1 SCAR 6.9
CC
1
Cov
0%
handler
2.0
configure
2.0
translate_params
2.0
CRAP 2.0
1 package Text::MicroMason::ApacheHandler;
2  
3 use Apache::Constants;
4 use Apache::Request;
5  
6 use Text::MicroMason::Base;
7  
8 ######################################################################
9  
10 my %configs;
11  
12 sub handler ($$) {
13 my ($package, $r) = @_;
14  
15 my $apache = Apache::Request->instance( $r );
16
17 my $file = $apache->filename;
18
19 # $apache->document_root;
20 my $syntax = $apache->dir_config('MicroMasonSyntax') || 'HTMLMason';
21 my @mixins = $apache->dir_config->get('MicroMasonMixins');
22 my @attrs = $apache->dir_config->get('MicroMasonAttribs');
23  
24 my %seen;
25 unshift @attrs, ( map "-$_", grep { ! $seen{$_} ++ } ( @mixins, $syntax ) );
26  
27 my $config = join ' ', @attrs;
28  
29 my $mason = ( $configs{$config} ||= Text::MicroMason::Base->new( @attrs ) );
30
31 my $template = $mason->compile( file => $file );
32
33 $apache->content_type( 'text/html' );
34 # $apache->header_out();
35
36 local $Text::MicroMason::Commands::r = $apache;
37 print $template->( $apache->param() );
38
39 return Apache::Constants::OK();
40 }
41  
42 sub configure {
43 my $apache = Apache::Request->instance( shift );
44
45 my $file = $apache->filename;
46
47 # $apache->document_root;
48 my $syntax = $apache->dir_config('MicroMasonSyntax') || 'HTMLMason';
49 my @mixins = $apache->dir_config->get('MicroMasonMixins');
50 my @attrs = $apache->dir_config->get('MicroMasonAttribs');
51  
52 my %seen;
53 unshift @attrs, ( map "-$_", grep { ! $seen{$_} ++ } ( @mixins, $syntax ) );
54  
55 my $config = join ' ', @attrs;
56  
57 my $mason = ( $configs{$config} ||= Text::MicroMason::Base->new( @attrs ) );
58 }
59  
60 ######################################################################
61  
62 sub translate_params {
63 MasonAllowGlobals => [ -AllowGlobals, allow_globals => \$1 ],
64 MasonCompRoot => [ -TemplateDir, template_root => \$1 ],
65 }
66  
67 ######################################################################
68  
69 1;
70  
71 __END__