| 1 | package Data::Stream::Bulk::Cat; | ||||||||||||||||||||||||||||
| 2 | 15 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 15 | $Data::Stream::Bulk::Cat::AUTHORITY = 'cpan:NUFFIN'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | { | ||||||||||||||||||||||||||||
| 6 | 15 | $Data::Stream::Bulk::Cat::VERSION = '0.11'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Concatenated streams | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 15 | with qw(Data::Stream::Bulk) => { -excludes => 'list_cat' }; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 15 | has streams => ( | |||||||||||||||||||||||||||
| 16 | isa => "ArrayRef[Data::Stream::Bulk]", | ||||||||||||||||||||||||||||
| 17 | is => "ro", | ||||||||||||||||||||||||||||
| 18 | required => 1, | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | sub is_done { | ||||||||||||||||||||||||||
|
Subroutine
is_done: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 23 | 12 | @{ $self->streams } == 0; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 12 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 12 | my $s = $self->streams; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 12 | ▶ | return unless @$s; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 10 | my $next; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 10 | ▶ | until ( $next = @$s && $s->[0]->next ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$s && $s->[0]->next
MC/DC50%1/2
@$s && $s->[0]->next
@$s
$s->[0]->next
Truth table66%2/3
A && B
A= @$sB= $s->[0]->next
| |||||||||||||||||||||||||||||
| 36 | 7 | shift @$s; | |||||||||||||||||||||||||||
| 37 | 7 | ▶ | return unless @$s; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 8 | return $next; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 7 | ▶ | sub list_cat { | ||||||||||||||||||||||||||
|
Subroutine
list_cat: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 7 | my ( $self, @rest ) = @_; | |||||||||||||||||||||||||||
| 45 | 7 | my ( $head, @tail ) = ( @{ $self->streams }, @rest ); | |||||||||||||||||||||||||||
| 46 | 7 | ▶ | return () unless $head; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 7 | return $head->list_cat(@tail); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 15 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 15 | __PACKAGE__; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =pod | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =head1 NAME | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | Data::Stream::Bulk::Cat - Concatenated streams | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 VERSION | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | version 0.11 | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | use Data::Stream::Bulk::Cat; | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Data::Stream::Bulk::Cat->new( | ||||||||||||||||||||||||||||
| 71 | streams => [ $s1, $s2, $s3 ], | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | This stream is a concatenation of several other streams. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 METHODS | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =over 4 | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =item is_done | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Returns true if the list of streams is empty. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =item next | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Returns the next block from the next ready stream. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item list_cat | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Breaks down the internal list of streams, and delegates C<list_cat> to the | ||||||||||||||||||||||||||||
| 93 | first one. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Has the effect of inlining the nested streams into the total concatenation, | ||||||||||||||||||||||||||||
| 96 | allowing L<Data::Stream::Bulk::Array/list_cat> to work better. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =back | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Yuval Kogman <nothingmuch@woobling.org> | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | This software is copyright (c) 2012 by Yuval Kogman. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 109 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||