blib/lib/PYX/Sort.pm

filter: Statementstmt 100% 46 / 46 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 100% 61 / 61 CC 2 SCAR 1.5
CC
2
Cov
100%
_flush
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package PYX::Sort;
2  
3 # Pragmas.
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Modules.
8 6 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use PYX::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Version.
12 6 our $VERSION = 0.03;
13  
14 # Constructor.
15 sub new {
16 6 ▶ my ($class, @params) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 6 my $self = bless {}, $class;
18  
19 # Output handler.
20 6 $self->{'output_handler'} = \*STDOUT;
21  
22 # Process params.
23 6 set_params($self, @params);
24  
25 # PYX::Parser object.
26 $self->{'pyx_parser'} = PYX::Parser->new(
27 'callbacks' => {
28 'attribute' => \&_attribute,
29 'start_element' => \&_tag,
30 'end_element' => \&_tag,
31 'comment' => \&_tag,
32 'instruction' => \&_tag,
33 'data' => \&_tag,
34 },
35 'non_parser_options' => {
36 'tag' => {},
37 },
38 4 'output_handler' => $self->{'output_handler'},
39 );
40  
41 # Object.
42 4 return $self;
43 }
44  
45 # Parse pyx text or array of pyx text.
46 sub parse {
47 2 ▶ my ($self, $pyx, $out) = @_;
Subroutine parse: called CC=1 SCAR=0.0
Pod documented
48 2 $self->{'pyx_parser'}->parse($pyx, $out);
49 2 return;
50 }
51  
52 # Parse file with pyx text.
53 sub parse_file {
54 2 ▶ my ($self, $file, $out) = @_;
Subroutine parse_file: called CC=1 SCAR=0.0
Pod documented
55 2 $self->{'pyx_parser'}->parse_file($file, $out);
56 2 return;
57 }
58  
59 # Parse from handler.
60 sub parse_handler {
61 2 ▶ my ($self, $input_file_handler, $out) = @_;
Subroutine parse_handler: called CC=1 SCAR=0.0
Pod documented
62 2 $self->{'pyx_parser'}->parse_handler($input_file_handler, $out);
63 2 return;
64 }
65  
66 # Process attribute.
67 sub _attribute {
68 18 ▶ my ($pyx_parser_obj, $att, $attval) = @_;
Subroutine _attribute: called CC=1 SCAR=0.0
69 18 $pyx_parser_obj->{'non_parser_options'}->{'tag'}->{$att} = $attval;
70 18 return;
71 }
72  
73 # Process tag.
74 sub _tag {
75 18 ▶ my $pyx_parser_obj = shift;
Subroutine _tag: called CC=1 SCAR=0.0
76 18 my $out = $pyx_parser_obj->{'output_handler'};
77 18 _flush($pyx_parser_obj);
78 18 print {$out} $pyx_parser_obj->line, "\n";
79 18 return;
80 }
81  
82 # Flush attributes.
83 sub _flush {
84 18 ▶ my $pyx_parser_obj = shift;
Subroutine _flush: called CC=2 SCAR=6.9
85 18 my $out = $pyx_parser_obj->{'output_handler'};
86 18 foreach my $key (sort keys %{$pyx_parser_obj->{'non_parser_options'}
87 18 ->{'tag'}}) {
88  
89 18 print {$out} 'A'.$key.'="'.$pyx_parser_obj
90 18 ->{'non_parser_options'}->{'tag'}->{$key}.'"'."\n";
91 }
92 18 $pyx_parser_obj->{'non_parser_options'}->{'tag'} = {};
93 18 return;
94 }
95  
96 6 1;
97  
98 __END__
↑ Summary