| 1 | package Text::Hoborg; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use File::Slurp 'read_file'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use version; our $VERSION = qv('0.0.6'); #(Hopefully) first | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | #non-test-failing version | ||||||||||
| 10 | |||||||||||
| 11 | 2 | our @appendices = qw(characters.md geography.md); #auxiliary and additional files | |||||||||
| 12 | |||||||||||
| 13 | # Module implementation here | ||||||||||
| 14 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||
| 15 | 2 | my $class = shift; | |||||||||
| 16 | 2 | my $dir = shift; | |||||||||
| 17 | 2 | ▶ | if ( ! $dir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 2 | ▶ | $dir = -d "../text" ? "../text": "../../text"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 2 | ▶ | $dir = -d $dir ? $dir : "t"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | } | ||||||||||
| 21 | 2 | my $text_file = "$dir/text.md"; | |||||||||
| 22 | 2 | my $text = read_file($text_file); | |||||||||
| 23 | 2 | my $self = { | |||||||||
| 24 | _dir => $dir, | ||||||||||
| 25 | _text => $text, | ||||||||||
| 26 | _text_file => $text_file, | ||||||||||
| 27 | _appendices => {} | ||||||||||
| 28 | }; | ||||||||||
| 29 | 2 | for my $a (@appendices ) { | |||||||||
| 30 | 4 | $text_file = "$dir/$a"; | |||||||||
| 31 | 4 | $text = read_file($text_file); | |||||||||
| 32 | 4 | $self->{'_appendices'}{$a} = $text; | |||||||||
| 33 | } | ||||||||||
| 34 | 2 | bless $self, $class; | |||||||||
| 35 | 2 | return $self; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | sub dir { | ||||||||
|
Subroutine
dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 1 | my $self = shift; | |||||||||
| 40 | 1 | return $self->{'_dir'}; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | sub text { | ||||||||
|
Subroutine
text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 44 | 1 | my $self = shift; | |||||||||
| 45 | 1 | return $self->{'_text'}; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | sub text_file { | ||||||||
|
Subroutine
text_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | 1 | my $self = shift; | |||||||||
| 50 | 1 | return $self->{'_text_file'}; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 3 | ▶ | sub appendices { | ||||||||
|
Subroutine
appendices: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 54 | 3 | my $self = shift; | |||||||||
| 55 | 3 | return $self->{'_appendices'}; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 2 | "All over, all out, all over and out"; # Magic circus phrase said at the end of the show | |||||||||
| 60 | |||||||||||
| 61 | __END__ | ||||||||||