lib/Gitalist/Model/ContentMangler.pm

filter: Statementstmt 69.7% 23 / 33 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 6 / 9 Podpod 100% 1 / 1 totaltotal 62.5% 30 / 48 CC 3 SCAR 14.3
CC
3
Cov
62%
process
12.0
__ANON__
2.0
__ANON__
2.0
CRAP 4.2
« lib/Gitalist/Git/CollectionOfRepositories.pm ↑ Summary script/gitalist_cgi.pl »
1 package Gitalist::Model::ContentMangler;
2 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use MooseX::Types::Moose qw/HashRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Gitalist::ContentMangler::Resolver;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 extends 'Catalyst::Model';
10  
11 7 has resolver_class => (
12 isa => NonEmptySimpleStr,
13 is => 'ro',
14 required => 1,
15 default => 'Gitalist::ContentMangler::Resolver::Default',
16 );
17  
18 has resolver_config => (
19 isa => HashRef,
20 is => 'ro',
21 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 7 );
23  
24 has _resolver => (
25 does => 'Gitalist::ContentMangler::Resolver',
26 handles => ['resolve'],
27 is => 'bare', lazy => 1,
28 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 my $self = shift;
30 0 my $class = $self->resolver_class;
31 0 Class::Load::load_class($class);
32 0 return $class->new($self->resolver_config);
33 },
34 7 );
35  
36 # FIXME This method is a gross hack.
37 #
38 # We need to work out what types of content mangles we have for various things based on hit type
39 # file name and mime type, and perform the appropriate bits..
40  
41 # We need to support multiple languages, and we also want to be able to do HTMLizing (for e.g. Pod)
42  
43 0 ▶sub process {
Subroutine process: not called CC=3 SCAR=24.8
Pod documented
44 0 my ($self, $c) = @_;
45  
46 # Find appropriate mangler based on filename,action,config
47 # Mangler should provide a transform e.g what part of the stash to mangle
48 # Then call the transform with the appropriate mangling
49  
50 my($transformer, $config) = $self->resolve({
51 filename => $c->stash->{filename} || '',
52 blob => \$c->stash->{blob},
53 0 ▶ config => Gitalist->config->{'Model::ContentMangler'},
Condition0%0/2
$c->stash->{'filename'} || ''
l!l
00
MC/DC0%0/1
$c->stash->{'filename'} || ''
$c->stash->{'filename'}
Truth table0%0/2
A
A= $c->stash->{'filename'}
Aresult
11
00
54 action => $c->action->name,
55 });
56  
57 return
58 0 ▶ unless $transformer;
Branch: 1 branch
BranchTrueFalseTotal
unless $transformer 0 0 0
59  
60 0 Class::Load::load_class($transformer);
61 0 $transformer->new($config)->transform($c, $config);
62 }
63  
64 7 __PACKAGE__->meta->make_immutable;
« lib/Gitalist/Git/CollectionOfRepositories.pm ↑ Summary script/gitalist_cgi.pl »