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