lib/Treex/Core/TredView/BackendStorable.pm

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