Curie/ViewModel/ViewManager/Role/Document.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use Renard::Incunabula::Common::Setup;
2 package Renard::Curie::ViewModel::ViewManager::Role::Document;
3 # ABSTRACT: A role for the document
4 $Renard::Curie::ViewModel::ViewManager::Role::Document::VERSION = '0.005';
5 use Moo::Role;
6  
7 use Renard::Incunabula::Document::Types qw(DocumentModel);
8 use Renard::Incunabula::Common::Types qw(Path FileUri);
9  
10 has current_document => (
11 is => 'rw',
12 isa => DocumentModel,
13 trigger => 1, # _trigger_current_document
14 );
15  
16 method _trigger_current_document( (DocumentModel) $doc ) {
17 $self->clear_view_options;
18 $self->current_view(
19 Renard::Curie::Model::View::Grid->new(
20 view_options => $self->view_options,
21 document => $doc,
22 )
23 );
24  
25 $self->signal_emit( 'document-changed' => $doc );
26 }
27  
28 method open_pdf_document( (Path->coercibles) $pdf_filename ) {
29 $pdf_filename = Path->coerce( $pdf_filename );
30 if( not -f $pdf_filename ) {
31 Renard::Incunabula::Common::Error::IO::FileNotFound
32 ->throw("PDF filename does not exist: $pdf_filename");
33 }
34  
35 $self->current_document(
36 Renard::Block::Format::PDF::Document->new(
37 filename => $pdf_filename,
38 )
39 );
40 }
41  
42 method open_document_as_file_uri( (FileUri) $uri ) {
43 $self->open_pdf_document( $uri->file );
44 }
45  
46 1;
47  
48 __END__