blib/lib/Dallycot/AST/BuildList.pm

filter: Statementstmt 95.7% 45 / 47 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 2 totaltotal 90.7% 59 / 65 CC 3 SCAR 3.6
CC
3
Cov
96%
execute
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.4
« blib/lib/Dallycot/AST/FullPlaceholder.pm ↑ Summary blib/lib/Dallycot/AST/ForwardWalk.pm »
1 package Dallycot::AST::BuildList;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Create stream-like collection with possible generator
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 experimental qw(switch);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 29 ▶use Promises qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub to_rdf {
17 1 ▶ my($self, $model) = @_;
Subroutine to_rdf: called CC=1 SCAR=0.0
Pod undocumented
18  
19 1 return $model -> apply(
20 $model -> meta_uri('loc:build-list'),
21 [ @$self ],
22 {}
23 );
24 # my $bnode = $model -> bnode;
25 # $model -> add_type($bnode, 'loc:List');
26 # if(@$self) {
27 # $model -> add_list($bnode, 'loc:expressions',
28 # map { $_ -> to_rdf($model) } @$self
29 # );
30 # }
31  
32 # return $bnode;
33 }
34  
35 sub execute {
36 353 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=2 SCAR=6.9
Pod undocumented
37  
38 353 my $d = deferred;
39  
40 353 my @expressions = @$self;
41 353 given ( scalar(@expressions) ) {
42 353 when (0) {
43 9 $d->resolve( Dallycot::Value::EmptyStream->new );
44 }
45 344 when (1) {
46 $engine->execute( $self->[0] )->done(
47 sub {
48 1 ▶ my ($result) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
49 1 $d->resolve( Dallycot::Value::Stream->new($result) );
50 },
51 sub {
52 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 }
54 1 );
55 }
56 343 default {
57 343 my $last_expr = pop @expressions;
58 343 my $promise;
59 343 ▶ if ( $last_expr->isa('Dallycot::Value') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_expr->isa('Dallycot::Value')) { } 5 338 343
60 5 push @expressions, $last_expr;
61 }
62 else {
63 338 $promise = $engine->make_lambda($last_expr);
64 }
65 $engine->collect(@expressions)->done(
66 sub {
67 335 ▶ my (@items) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
68 335 my $result = Dallycot::Value::Stream->new( ( pop @items ), undef, $promise );
69 335 ▶ while (@items) {
Branch: 1 branch
BranchTrueFalseTotal
if (@items) 43 335 378
70 43 $result = Dallycot::Value::Stream->new( ( pop @items ), $result );
71 }
72 335 $d->resolve($result);
73 },
74 sub {
75 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 }
77 343 );
78 }
79 }
80  
81 353 return $d->promise;
82 }
83  
84 29 1;
« blib/lib/Dallycot/AST/FullPlaceholder.pm ↑ Summary blib/lib/Dallycot/AST/ForwardWalk.pm »