lib/AI/MicroStructure/ObjectParser.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 64 CC 3 SCAR 15.0
CC
3
Cov
0%
start
12.0
new
2.0
declaration
2.0
CRAP 4.5
1  
2 package AI::MicroStructure::ObjectParser;
3 use HTML::Parser;
4 use HTML::Entities ();
5 use URI::URL;
6  
7 use vars qw(@ISA);
8 @ISA = qw(HTML::Parser);
9  
10 sub new {
11 my $pack = shift;
12 my $self = $pack->SUPER::new;
13 @{$self}{qw(__base __out __within)} = @_;
14 $self;
15 }
16  
17 sub declaration {
18 my $self = shift;
19 my ($decl) = @_;
20 $self->{__out}->print("<!$decl>");
21 }
22  
23 sub start {
24 my $self = shift;
25 my ($tag, $attr, $attrseq, $origtext) = @_;
26 my $out = $self->{__out};
27 $out->print("<$tag");
28 for (keys %$attr) {
29 $out->print(" $_=\"");
30 my $val = $attr->{$_};
31 if ("$tag $_" =~ /^(a href|img src)$/) {
32 $val = url($val)->abs($self->{__base},1);
33 if ($self->{__within}->($val)) {
34 $val = $val->rel($self->{__base});
35 }
36 }
37 $out->print(HTML::Entities::encode($val, '<>&"'));
38 $out->print('"');
39 }
40 $out->print(">");
41 }
42  
43 sub end {
44 my $self = shift;
45 my ($tag) = @_;
46 $self->{__out}->print("</$tag>");
47 }
48  
49 sub text {
50 my $self = shift;
51 my ($text) = @_;
52 $self->{__out}->print("$text");
53 }
54  
55 sub comment {
56 my $self = shift;
57 my ($comment) = @_;
58 $self->{__out}->print("<!-- $comment -->");
59 }
60  
61 1;
62  
63  
64  
65  
66  
67 =head1 NAME
68  
69 AI::MicroStructure::ObjectParser
70  
71 =head1 DESCRIPTION
72  
73 Html Parser
74  
75 =head1 SYNOPSIS
76  
77 ~$ micro new world
78  
79 ~$ micro structures
80  
81 ~$ micro any 2
82  
83 ~$ micro drop world
84  
85 ~$ micro
86  
87 =head1 AUTHOR
88  
89 Hagen Geissler <santex@cpan.org>
90  
91 =head1 COPYRIGHT AND LICENCE
92  
93 Hagen Geissler <santex@cpan.org>
94  
95 =head1 SUPPORT AND DOCUMENTATION
96  
97 [sample using concepts](http://quantup.com)
98  
99 [PDF info on my works](https://github.com/santex)
100  
101  
102 =head1 SEE ALSO
103  
104 AI-MicroStructure
105  
106 =cut