PTD/StarDict.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 52 CC 5 SCAR 27.7
CC
5
Cov
0%
_save
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 16.0
1 package Lingua::PTD::StarDict;
2 $Lingua::PTD::StarDict::VERSION = '1.15';
3 use warnings;
4 use strict;
5  
6 use parent 'Lingua::PTD';
7  
8 use Module::Load::Conditional qw/check_install/;
9  
10 =encoding UTF-8
11  
12 =head1 NAME
13  
14 Lingua::PTD::StarDict - Sub-module to export PTD to StarDict
15  
16 =head1 SYNOPSIS
17  
18 use Lingua::PTD;
19  
20 my $ptd = Lingua::PTD->new( $file );
21 $ptd->saveAs("stardict", $name, $options);
22  
23 =head1 DESCRIPTION
24  
25 Check L<<Lingua::PTD>> for complete reference.
26  
27 =head1 SEE ALSO
28  
29 NATools(3), perl(1)
30  
31 =head1 AUTHOR
32  
33 Alberto Manuel Brandão Simões, E<lt>ambs@cpan.orgE<gt>
34  
35 =head1 COPYRIGHT AND LICENSE
36  
37 Copyright (C) 2010-2014 by Alberto Manuel Brandão Simões
38  
39 =cut
40  
41 sub _save {
42 my ($ptd, $name, $my_opts) = @_;
43 my $min = $my_opts->{m} //= 0.2;
44 my $dir = $my_opts->{d} //= './';
45  
46 my $d;
47 $ptd->downtr( sub {
48 my ($w, $c, %t) = @_;
49 return if $w =~ m/^_/;
50  
51 my @l;
52 foreach (keys %t) {
53 push @l, sprintf "<kref>%s</kref> (%.0f%s)", $_, $t{$_}*100,'%' if ($t{$_} > $min);
54 }
55 $d->{$w} = join '; ', @l if @l;
56 });
57  
58 if ( check_install( module=>'Lingua::StarDict::Gen' ) ) {
59 require "Lingua::StarDict::Gen";
60 Lingua::StarDict::Gen::writeDict($d, $name, $dir);
61 } else {
62 die "Lingua::StarDict::Gen is required to output StarDict format."
63 }
64  
65 return 1;
66 }
67  
68 "This has been Sparta!";
69 __END__