| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## File: DTA::CAB::Format::Raw::Base.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Description: Datum parser/formatter: raw untokenized text (common) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package DTA::CAB::Format::Raw::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use DTA::CAB::Format; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use DTA::CAB::Datum ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Encode qw(encode decode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ## Globals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our @ISA = qw(DTA::CAB::Format); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ## $fmt = CLASS_OR_OBJ->new(%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ## + object structure: assumed HASH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ## { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ## ##-- Common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ## #utf8 => $bool, ##-- utf8 mode always on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## #level => $level, ##-- output level (ignored) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ## } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $fmt = bless({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ##-- common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | utf8 => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | #level => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ##-- user args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }, ref($that)||$that); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $fmt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ## Methods: Input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # (nothing here) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ## Methods: Output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ## Methods: Output: Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ## $type = $fmt->mimeType() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ## + default returns text/plain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub mimeType { return 'text/plain'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mimeType: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## $ext = $fmt->defaultExtension() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## + returns default filename extension for this format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub defaultExtension { return '.raw'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultExtension: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ## $str = $fmt->toString(\$str) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ## $str = $fmt->toString(\$str,$formatLevel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ## + select output to byte-string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ## + default implementation wraps $fmt->toFh() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ## $fmt_or_undef = $fmt->toFile($filename_or_handle, $formatLevel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ## + select output to named file $filename. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ## + default implementation wraps $fmt->toFh() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ## $fmt_or_undef = $fmt->toFh($fh,$formatLevel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ## + select output to an open filehandle $fh. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ## + default implementation calls to $fmt->formatString($formatLevel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub toFh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toFh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $_[0]->DTA::CAB::Format::toFh(@_[1..$#_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $_[0]->setLayers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ## Methods: Output: API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ## $fmt = $fmt->putDocument($doc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ## + override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub putDocument { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
putDocument: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($fmt,$doc,$bufr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #$bufr = \(my $buf='') if (!defined($bufr)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $level = $fmt->{level} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$fmt->{"level"} // 0
MC/DC0%0/1
$fmt->{"level"} // 0
$fmt->{"level"}
Truth table0%0/2
A
A= $fmt->{"level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my ($s,$w, $txt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | foreach $s (@{$doc->{body}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | $fmt->{fh}->print(join(' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ($_->{moot} && defined($_->{moot}{word}) ? $_->{moot}{word} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | : ($_->{dmoot} && defined($_->{dmoot}{tag}) ? $_->{dmoot}{tag} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | : ($_->{xlit} && defined($_->{xlit}{latin1Text}) ? $_->{xlit}{latin1Text} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | : $_->{text}))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/9
$_->{"moot"} and defined $_->{"moot"}{"word"}
$_->{"dmoot"} and defined $_->{"dmoot"}{"tag"}
$_->{"xlit"} and defined $_->{"xlit"}{"latin1Text"}
MC/DC0%0/2
$_->{"moot"} and defined $_->{"moot"}{"word"}
$_->{"moot"}
defined $_->{"moot"}{"word"}
MC/DC0%0/2
$_->{"dmoot"} and defined $_->{"dmoot"}{"tag"}
$_->{"dmoot"}
defined $_->{"dmoot"}{"tag"}
MC/DC0%0/2
$_->{"xlit"} and defined $_->{"xlit"}{"latin1Text"}
$_->{"xlit"}
defined $_->{"xlit"}{"latin1Text"}
Truth table0%0/3
A and B
A= $_->{"moot"}B= defined $_->{"moot"}{"word"}
Truth table0%0/3
A and B
A= $_->{"dmoot"}B= defined $_->{"dmoot"}{"tag"}
Truth table0%0/3
A and B
A= $_->{"xlit"}B= defined $_->{"xlit"}{"latin1Text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | } @{$s->{tokens}}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return $fmt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ## $fmt = $fmt->putData($data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ## + puts raw data (uses forceDocument()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub putData { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
putData: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $_[0]->putDocument($_[0]->forceDocument($_[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | 1; ##-- be happy | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||