blib/lib/Book/Bilingual/App.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 51 CC 4 SCAR 20.1
CC
4
Cov
0%
get_reader
12.0
run
6.0
BEGIN
2.0
CRAP 7.4
1 # lib/Book/Bilingual/App.pm
2 # PODNAME: App.pm
3 # ABSTRACT: A reader app
4 use Mojolicious::Lite;
5 use Book::Bilingual::Reader;
6  
7 my $Reader;
8  
9 =head1 SYNOPSIS
10  
11 # Run as a daemon in production
12 biread BOOKFILE
13  
14 # Run as morbo to auto reload while in development
15 morbo lib/Book/Bilingual/App.pm BOOKFILE
16  
17 =cut
18  
19  
20 if ($0 eq '-e') {} # If called as a module, do nothing
21 else { run($ARGV[0]) } # If called as a program, run it
22  
23 get '/' => sub {} => 'index';
24  
25 sub get_reader {
26 my ($c) = @_;
27 my $ptr = $c->param('ptr') || '0.0.0';
28  
29 $Reader->_ptr([split '\.', $ptr])
30 ->_load_chapter()
31 ->_load_dlineset();
32  
33 my ($next_ptr) = @{$Reader->_next_ptr || []};
34 my ($prev_ptr) = @{$Reader->_prev_ptr || []};
35  
36 my $next_html = $next_ptr
37 ? '<a id="nextPtr" href="/reader?ptr='.$next_ptr.'">Next</a>'
38 : 'Next';
39 my $prev_html = $prev_ptr
40 ? '<a id="prevPtr" href="/reader?ptr='.$prev_ptr.'">Prev</a>'
41 : 'Prev';
42  
43 #say $ptr;
44 #say "Curr:$ptr Next:$next_ptr Prev:$prev_ptr";
45 #say "Next HTML: $next_html";
46 #say "Prev HTML: $prev_html";
47  
48 $c->stash(chapter_html => $Reader->html);
49 $c->stash(next_html => $next_html);
50 $c->stash(prev_html => $prev_html);
51  
52 }
53 get '/reader' => \&get_reader => 'reader';
54  
55 get '/credits';
56  
57 sub run { ## ($bookfile)
58 # Does the actual run using the file a
59 my ($file) = @_;
60 die "\n Usage:\n biread BOOKFILE\n\n" unless $file;
61  
62 $Reader = Book::Bilingual::Reader->new($file);
63 app->start;
64 }
65  
66 app; # Need to return an app for morbo to work
67  
68 __DATA__