File Coverage

blib/lib/Story/Interact/PageSource/Dir.pm
Criterion Covered Total %
statement 24 26 92.3
branch 2 2 100.0
condition n/a
subroutine 8 9 88.8
pod 0 2 0.0
total 34 39 87.1


line stmt bran cond sub pod time code
1 5     5   129 use 5.010001;
  5         28  
2 5     5   31 use strict;
  5         12  
  5         114  
3 5     5   42 use warnings;
  5         13  
  5         388  
4              
5             package Story::Interact::PageSource::Dir;
6              
7             our $AUTHORITY = 'cpan:TOBYINK';
8             our $VERSION = '0.001012';
9              
10 5     5   39 use Moo;
  5         19  
  5         37  
11 5     5   1924 use Types::Common -types;
  5         21  
  5         53  
12 5     5   73355 use Types::Path::Tiny -types;
  5         26  
  5         39  
13 5     5   6827 use namespace::clean;
  5         17  
  5         61  
14              
15             with 'Story::Interact::PageSource';
16              
17             has 'dir' => (
18             is => 'ro',
19             isa => Dir,
20             coerce => 1,
21             required => 1,
22             );
23              
24             sub get_source_code {
25 46     46 0 108 my ( $self, $page_id ) = @_;
26 46         372 my $file = $self->dir->child( join q[.], $page_id, 'page.pl' );
27 46 100       2245 return unless $file->exists;
28 34         1030 return $file->slurp_utf8;
29             }
30              
31             sub all_page_ids {
32 0     0 0   my ( $self ) = @_;
33 0           map $_->basename( '.page.pl' ), $self->dir->children( qr/\.page\.pl\z/ );
34             }
35              
36             1;