blib/lib/Dallycot/AST/BuildMap.pm

filter: Statementstmt 91.0% 51 / 56 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 2 totaltotal 86.5% 71 / 82 CC 4 SCAR 3.1
CC
4
Cov
87%
__ANON__
2.1
__ANON__
2.1
__ANON__
2.1
CRAP 1.4
« blib/lib/Dallycot/AST/BuildFilter.pm ↑ Summary blib/lib/Dallycot/AST/Expr.pm »
1 package Dallycot::AST::BuildMap;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Create derivative stream through a mapping
5  
6 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 29 ▶use parent 'Dallycot::AST';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 29 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 29 ▶use Dallycot::Util qw(maybe_promise);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 29 ▶use List::Util qw(all any);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 29 ▶use Promises qw(deferred collect);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub to_rdf {
18 0 ▶ my($self, $model) = @_;
Subroutine to_rdf: not called CC=1 SCAR=6.9
Pod undocumented
19  
20 0 return $model -> apply(
21 $model -> meta_uri('loc:build-map'),
22 [ @$self ],
23 {}
24 );
25 }
26  
27 sub execute {
28 40 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=1 SCAR=0.1
Pod undocumented
29  
30 return $engine->collect(@$self)->then(
31 sub {
32 37 ▶ my (@functions) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
33 37 my $stream = pop @functions;
34 39 return collect( map { maybe_promise( $_->is_lambda ) } @functions )->then(
35 sub {
36 37 ▶ my @flags = map {@$_} @_;
Subroutine __ANON__: called CC=2 SCAR=7.2
37 37 ▶ if ( any { !$_ } @flags ) {
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { not $_; } , @flags)) 0 37 37
38 0 croak "All but the last term in a mapping must be lambdas.";
39 }
40 37 return ( \@functions, $stream );
41 }
42 37 );
43 }
44 )->then(
45 sub {
46 37 ▶ my ( $functions, $stream ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.1
47  
48 39 return collect( map { maybe_promise( $_->min_arity ) } @$functions )->then(
49 sub {
50 35 ▶ my (@arities) = map {@$_} @_;
Subroutine __ANON__: called CC=2 SCAR=7.2
51 35 ▶ if ( any { 1 != $_ } @arities ) {
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { 1 != $_; } , @arities)) 0 35 35
52 0 croak "All lambdas in a mapping must have arity 1.";
53 }
54 35 return ( $functions, $stream );
55 }
56 37 );
57 }
58 )->then(
59 sub {
60 34 ▶ my ( $functions, $stream ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.1
61  
62 return maybe_promise( $stream->is_lambda )->then(
63 sub {
64 34 ▶ my ($flag) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.4
65  
66 34 ▶ if ($flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag) { } 0 34 34
67 0 return $engine->make_map( $engine->compose_lambdas( @$functions, $stream ) );
68 }
69 else {
70 34 my $transform = $engine->compose_lambdas(@$functions);
71  
72 34 return $stream->apply_map( $engine, $transform );
73 }
74 }
75 34 );
76 }
77 40 );
78 }
79  
80 29 1;
« blib/lib/Dallycot/AST/BuildFilter.pm ↑ Summary blib/lib/Dallycot/AST/Expr.pm »