| 1 | package Don::Mendo::Jornada; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = "0.0.4"; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # Other recommended modules (uncomment to use): | ||||||||||||||||||||||||||||
| 10 | # use IO::Prompt; | ||||||||||||||||||||||||||||
| 11 | # use Perl6::Export; | ||||||||||||||||||||||||||||
| 12 | # use Perl6::Slurp; | ||||||||||||||||||||||||||||
| 13 | # use Perl6::Say; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Don::Mendo::Linea; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Module implementation here | ||||||||||||||||||||||||||||
| 18 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 20 | 4 | ▶ | my $text = shift || croak "No text here!"; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || croak('No text here!')
MC/DC0%0/1
shift() || croak('No text here!')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 21 | 4 | my @parts = split(/\n\n/, $text ); | |||||||||||||||||||||||||||
| 22 | 4 | my $this_part = shift @parts; | |||||||||||||||||||||||||||
| 23 | 4 | my $intro; | |||||||||||||||||||||||||||
| 24 | 4 | ▶ | while ( $this_part !~ / {5}[A-ZÑÍÁ y,]+\.–/ && @parts ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $this_part =~ / {5}[A-Z\303\221\303\215\303\201 y,]+\.\342\200\223/ and @parts
MC/DC50%1/2
not $this_part =~ / {5}[A-Z\303\221\303\215\303\201 y,]+\.\342\200\223/ and @parts
not $this_part =~ / {5}[A-Z\303\221\303\215\303\201 y,]+\.\342\200\223/
@parts
Truth table66%2/3
not(A) and B
A= not $this_part =~ / {5}[A-Z\303\221\303\215\303\201 y,]+\.\342\200\223/B= @parts
| |||||||||||||||||||||||||||||
| 25 | 12 | $intro .= $this_part; | |||||||||||||||||||||||||||
| 26 | 12 | $this_part = shift @parts; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 4 | unshift( @parts, $this_part); | |||||||||||||||||||||||||||
| 29 | 4 | my $lines = join( "\n\n", @parts ); | |||||||||||||||||||||||||||
| 30 | 4 | my $self = { _text => $text, | |||||||||||||||||||||||||||
| 31 | _intro => $intro, | ||||||||||||||||||||||||||||
| 32 | _linestext => $lines }; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 4 | my @bits = ( $lines =~ / {5}([A-ZÑÍÁ y,]+)\.– (.+?)\n\n\n/gs ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | my $last_line; | |||||||||||||||||||||||||||
| 37 | 4 | ▶ | while (@bits ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 834 | my $actor = shift @bits; | |||||||||||||||||||||||||||
| 39 | 834 | my $this_line = shift @bits; | |||||||||||||||||||||||||||
| 40 | 834 | ▶ | if ( $this_line =~ /\.– / ){ #Missed split lines | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 45 | my ($new_linea, $new_actor, $otra_linea) = | |||||||||||||||||||||||||||
| 42 | ($this_line =~ /(.+?) {5}([A-ZÑÍÁ y,]+)\.– (.+)/gs); | ||||||||||||||||||||||||||||
| 43 | 45 | unshift @bits, ($new_actor, $otra_linea); | |||||||||||||||||||||||||||
| 44 | 45 | $this_line = $new_linea; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 834 | my $line = new Don::Mendo::Linea( $actor, $this_line ); | |||||||||||||||||||||||||||
| 47 | 834 | push @{$self->{'_lines'}}, $line; | |||||||||||||||||||||||||||
| 48 | 834 | ▶ | if ( $last_line ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 830 | $last_line->follows( $line ); | |||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||
| 51 | 4 | $self->{'_first_line'} = $line; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 834 | $last_line = $line; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 4 | bless $self, $class; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub start { | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 0 | my $self =shift; | |||||||||||||||||||||||||||
| 61 | 0 | return $self->{'_first_line'}; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub text { | ||||||||||||||||||||||||||
|
Subroutine
text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 66 | 0 | return $self->{'text'}; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | sub lines_for_character { | ||||||||||||||||||||||||||
|
Subroutine
lines_for_character: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | 4 | my $character = uc( shift ); | |||||||||||||||||||||||||||
| 72 | 4 | ▶ | return $self->{'_lines'} if !$character; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 2 | my @these_lines; | |||||||||||||||||||||||||||
| 74 | 2 | for my $l (@{$self->{'_lines'}}) { | |||||||||||||||||||||||||||
| 75 | 464 | ▶ | push(@these_lines, $l) if ($l->character() eq $character); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 2 | return \@these_lines; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub tell { | ||||||||||||||||||||||||||
|
Subroutine
tell: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 1 | my $line = $self->{'_first_line'}; | |||||||||||||||||||||||||||
| 83 | 1 | my $text; | |||||||||||||||||||||||||||
| 84 | do { | ||||||||||||||||||||||||||||
| 85 | 256 | $text .= "\t".$line->character()." - ".$line->say()."\n\n"; | |||||||||||||||||||||||||||
| 86 | 1 | ▶ | }while ($line = $line->{'_follows'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 1 | return $text; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | sub actors{ | ||||||||||||||||||||||||||
|
Subroutine
actors: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 1 | my %actors; | |||||||||||||||||||||||||||
| 93 | 1 | for my $l ( @{$self->{'_lines'}} ) { | |||||||||||||||||||||||||||
| 94 | 256 | ▶ | if ( !$actors{$l->character()} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 18 | $actors{$l->character()} = $l; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | 1 | return \%actors; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 1 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 NAME | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Don::Mendo::Jornada - Each one of the acts of the Don Mendo play | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 VERSION | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | This document describes Don::Mendo::Jornada version 0.0.3. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | use Don::Mendo::Jornada; | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | A "jornada" is the equivalent of an act, a part of the play taking | ||||||||||||||||||||||||||||
| 121 | place in a single setup. Don Mendo has 4 acts, first one in | ||||||||||||||||||||||||||||
| 122 | Magdalena's tower, second one in Don Mendo's prison, third one in | ||||||||||||||||||||||||||||
| 123 | the king's camp, and the last in the cave. | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head1 INTERFACE | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =head2 new( $text ) | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | Creates a new one, and sets up lines and bits and pieces inside | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | my $jornada = new Don::Mendo::Jornada( $text ); | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head2 start() | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | Returns the first character line (C<Don::Mendo::Line>) | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head2 text() | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Returns the raw text of the jornada | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =head2 lines_for_character( [ $actor ] ) | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Returns the lines for a particular actor, or all of them if void | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =head2 tell() | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Follows narrative returning the whole text | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =head2 actors() | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | Returns a hash with the names of the actors and their first line | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head1 CONFIGURATION AND ENVIRONMENT | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Don::Mendo requires no configuration files or environment variables. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | None. | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head1 INCOMPATIBILITIES | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | None reported. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | No bugs have been reported. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 173 | C<bug-don-mendo@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||
| 174 | L<http://rt.cpan.org>. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | JJ Merelo C<< <jj@merelo.net> >> | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | Copyright (c) 2008, JJ Merelo C<< <jj@merelo.net> >>. All rights reserved. | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 187 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | =head1 DISCLAIMER OF WARRANTY | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||||||||||||||||||||||||||||
| 193 | FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||||||||||||||||||||||||||||
| 194 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||||||||||||||||||||||||||||
| 195 | PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER | ||||||||||||||||||||||||||||
| 196 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||||||||||||||||||||||||
| 197 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE | ||||||||||||||||||||||||||||
| 198 | ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH | ||||||||||||||||||||||||||||
| 199 | YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL | ||||||||||||||||||||||||||||
| 200 | NECESSARY SERVICING, REPAIR, OR CORRECTION. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||||||||||||||||||||||||||||
| 203 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||||||||||||||||||||||||||||
| 204 | REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE | ||||||||||||||||||||||||||||
| 205 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, | ||||||||||||||||||||||||||||
| 206 | OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE | ||||||||||||||||||||||||||||
| 207 | THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | ||||||||||||||||||||||||||||
| 208 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | ||||||||||||||||||||||||||||
| 209 | FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | ||||||||||||||||||||||||||||
| 210 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||||||||||||||||||||||||||||
| 211 | SUCH DAMAGES. | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =cut | ||||||||||||||||||||||||||||