Treex/Core/TredView/BackendStorable.pm

filter: Statementstmt 58.3% 21 / 36 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod n/a totaltotal 56.2% 27 / 48 CC 2 SCAR 7.8
CC
2
Cov
55%
open_backend
6.0
test
2.0
read
2.0
CRAP 2.2
« Treex/Core/TredView/Common.pm ↑ Summary Treex/postprocess_POD.pl »
1 package Treex::Core::TredView::BackendStorable;
2 1 $Treex::Core::TredView::BackendStorable::VERSION = '2.20151210';
3 package Treex::PML::Backend::Treex::Core::TredView::BackendStorable;
4 1 $Treex::PML::Backend::Treex::Core::TredView::BackendStorable::VERSION = '2.20151210';
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Treex::Core::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Treex::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Treex::PML::IO qw( close_backend);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use UNIVERSAL::DOES;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub test {
15 0 ▶ my ( $filename, $encoding )=@_;
Subroutine test: not called CC=1 SCAR=6.9
16 0 return $filename =~ /\.streex$/;
17 }
18  
19 sub open_backend {
20 0 ▶ my ( $filename ) = @_;
Subroutine open_backend: not called CC=2 SCAR=17.9
21 0 ▶ open my $FILEHANDLE, "<:gzip", $filename or log_fatal($!); # only for reading so far
Branch: 1 branch
BranchTrueFalseTotal
open my $FILEHANDLE, "<:gzip", $filename or log_fatal($!) 0 0 0
22 0 return $FILEHANDLE;
23 }
24  
25 sub read { ## no critic (ProhibitBuiltinHomonyms)
26  
27 0 ▶ my ($filehandle,$pmldoc)=@_;
Subroutine read: not called CC=1 SCAR=6.9
28 0 my $doc = Treex::Core::Document->retrieve_storable($filehandle);
29 0 my $restore = $doc->_pmldoc;
30  
31 # moving the data from the retrieved document to the prepared empty document
32 0 @{$pmldoc} = @{$restore};
33  
34 # this is a hack for passing the already created Treex::Core structure up to TredView modules;
35 # God knows what the 13th slot is, probably it's a slot for some application data
36 0 $pmldoc->[13]->{_treex_core_document} = $doc;
37 0 return;
38 }
39  
40  
41 sub write { ## no critic (ProhibitBuiltinHomonyms)
42 0 ▶ my ($fd,$fs)=@_;
Subroutine write: not called CC=1 SCAR=6.9
43 0 log_fatal "Saving of .streex files in TrEd not implemented yet";
44 }
45  
46  
47 1 1;
48 __END__
49  
50  
51 =pod
52  
53 =encoding utf-8
54  
55 =head1 NAME
56  
57 Treex::Core::TredView::Backend::Storable - I/O backend for opening .streex files in TrEd
58  
59 =head1 VERSION
60  
61 version 2.20151210
62  
63 =head1 DESCRIPTION
64  
65 .streex files are gzipped data dumps of Treex::Core::Documents created by the Storable module.
66 This backend is based on Peter Pajas' Treex::PML::Backend::Storable.
67  
68 =head1 SYNOPSIS
69  
70 $ tred -B Treex::Core::TredView::Backend::Storable ...
71  
72 =head1 AUTHOR
73  
74 Zdeněk Žabokrtský <toman@ufal.mff.cuni.cz>
75  
76 =head1 COPYRIGHT AND LICENSE
77  
78 Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
79  
80 This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
« Treex/Core/TredView/Common.pm ↑ Summary Treex/postprocess_POD.pl »