File Coverage

blib/lib/Story/Interact.pm
Criterion Covered Total %
statement 44 49 89.8
branch 4 6 66.6
condition n/a
subroutine 14 14 100.0
pod 0 1 0.0
total 62 70 88.5


line stmt bran cond sub pod time code
1 5     5   1347967 use 5.010001;
  5         76  
2 5     5   42 use strict;
  5         9  
  5         110  
3 5     5   22 use warnings;
  5         9  
  5         270  
4              
5             package Story::Interact;
6              
7             our $AUTHORITY = 'cpan:TOBYINK';
8             our $VERSION = '0.001012';
9              
10 5     5   2148 use Story::Interact::Analyze ();
  5         18  
  5         167  
11 5     5   33 use Story::Interact::Character ();
  5         15  
  5         81  
12 5     5   2977 use Story::Interact::Harness::Terminal ();
  5         46  
  5         412  
13 5     5   3368 use Story::Interact::Page ();
  5         19  
  5         174  
14 5     5   2323 use Story::Interact::PageSource ();
  5         19  
  5         170  
15 5     5   2617 use Story::Interact::PageSource::DBI ();
  5         28  
  5         158  
16 5     5   2556 use Story::Interact::PageSource::Dir ();
  5         29  
  5         198  
17 5     5   2163 use Story::Interact::PageSource::Waterfall ();
  5         19  
  5         145  
18 5     5   59 use Story::Interact::State ();
  5         15  
  5         80  
19 5     5   27 use Story::Interact::Syntax ();
  5         13  
  5         1185  
20              
21             sub new_page_source {
22 4     4 0 88851 my ( undef, $story ) = @_;
23              
24 4 100       149 if ( -d $story ) {
    50          
    50          
25 2         60 return Story::Interact::PageSource::Dir->new( dir => $story );
26             }
27             elsif ( $story =~ /^dbi:/i ) {
28 0         0 require DBI;
29 0         0 my $dbh = DBI->connect( $story, undef, undef );
30 0         0 return Story::Interact::PageSource::DBI->new( dbh => $dbh );
31             }
32             elsif ( -f $story ) {
33 2         2045 require DBI;
34 2         19447 my $dbh = DBI->connect( "dbi:SQLite:dbname=$story", '', '' );
35 2         13717 return Story::Interact::PageSource::DBI->new( dbh => $dbh );
36             }
37              
38 0           require Carp;
39 0           Carp::croak("Could not open '$story' as a page source");
40             }
41              
42             1;
43              
44             __END__