File Coverage

blib/lib/Locale/XGettext/Text.pm
Criterion Covered Total %
statement 20 29 68.9
branch 3 8 37.5
condition n/a
subroutine 4 8 50.0
pod 5 5 100.0
total 32 50 64.0


line stmt bran cond sub pod time code
1             #! /bin/false
2             # vim: ts=4:et
3              
4             # Copyright (C) 2016-2017 Guido Flohr ,
5             # all rights reserved.
6              
7             # This program is free software; you can redistribute it and/or modify it
8             # under the terms of the GNU Library General Public License as published
9             # by the Free Software Foundation; either version 2, or (at your option)
10             # any later version.
11              
12             # This program is distributed in the hope that it will be useful,
13             # but WITHOUT ANY WARRANTY; without even the implied warranty of
14             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15             # Library General Public License for more details.
16              
17             # You should have received a copy of the GNU Library General Public
18             # License along with this program; if not, write to the Free Software
19             # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20             # USA.
21              
22             package Locale::XGettext::Text;
23             $Locale::XGettext::Text::VERSION = '0.6';
24 15     15   1020107 use strict;
  15         199  
  15         513  
25              
26 15     15   9283 use Locale::TextDomain qw(Locale-XGettext);
  15         283330  
  15         102  
27              
28 15     15   419506 use base qw(Locale::XGettext);
  15         39  
  15         8372  
29              
30             sub readFile {
31 40     40 1 104 my ($self, $filename) = @_;
32              
33 40 50       1420 open my $fh, '<', $filename
34             or die __x("Error reading '{filename}': {error}!\n",
35             filename => $filename, error => $!);
36            
37 40         138 my $chunk = '';
38 40         71 my $last_lineno = 1;
39 40         724 while (my $line = <$fh>) {
40 40 50       253 if ($line =~ /^[\x09-\x0d ]*$/) {
41 0 0       0 if (length $chunk) {
42 0         0 chomp $chunk;
43 0         0 $self->addEntry({msgid => $chunk,
44             reference => "$filename:$last_lineno"});
45             }
46 0         0 $last_lineno = $. + 1;
47 0         0 $chunk = '';
48             } else {
49 40         368 $chunk .= $line;
50             }
51             }
52            
53 40 50       143 if (length $chunk) {
54 40         89 chomp $chunk;
55 40         363 $self->addEntry({msgid => $chunk,
56             reference => "$filename:$last_lineno"});
57             }
58              
59 40         629 return $self;
60             }
61              
62             sub versionInformation {
63 0     0 1   return __x('{program} (Locale-XGettext) {version}
64             Copyright (C) {years} Cantanea EOOD (http://www.cantanea.com/).
65             License LGPLv3+: GNU Lesser General Public Licence version 3
66             or later .
67             This is free software: you are free to change and redistribute it.
68             There is NO WARRANTY, to the extent permitted by law.
69             Written by Guido Flohr (http://www.guido-flohr.net/).
70             ', program => $0, years => '2016-2017', version => $Locale::XGettext::VERSION);
71             }
72              
73             sub fileInformation {
74 0     0 1   return __(<
75             Input files are interpreted as plain text files with each paragraph being
76             a separately translatable unit.
77             EOF
78             }
79              
80             sub canExtractAll {
81 0     0 1   shift;
82             }
83              
84             sub canKeywords {
85 0     0 1   return;
86             }
87              
88             1;