File Coverage

blib/lib/XML/ASX/File.pm
Criterion Covered Total %
statement 39 70 55.7
branch 2 26 7.6
condition 3 12 25.0
subroutine 10 12 83.3
pod 0 5 0.0
total 54 125 43.2


line stmt bran cond sub pod time code
1             package XML::ASX::File;
2              
3 1     1   11 use strict;
  1         1  
  1         44  
4 1     1   5 use vars qw($VERSION $AUTOLOAD @ISA %ASX_SLOTS);
  1         2  
  1         83  
5              
6             @ISA = qw(XML::ASX);
7              
8 1     1   637 use XML::ASX::Entry;
  1         3  
  1         33  
9 1     1   803 use XML::ASX::Repeat;
  1         2  
  1         29  
10 1     1   592 use XML::ASX::Event;
  1         3  
  1         37  
11              
12 1     1   8 use overload '""' => \&xml;
  1         1  
  1         7  
13              
14             $VERSION = '0.01';
15              
16             my %RW_SLOTS = (
17             title => '',
18             moreinfo => '',
19             target => '',
20             copyright => '',
21             base => '',
22             author => '',
23             abstract => '',
24              
25             version => '3.0',
26             previewmode => 'YES',
27             bannerbar => 'AUTO',
28              
29             banner => '',
30             logo_icon => '',
31             logo_mark => '',
32             );
33              
34             sub AUTOLOAD {
35 23     23   107 my $self = shift;
36 23         27 my $param = $AUTOLOAD;
37 23         71 $param =~ s/.*:://;
38 23 50 33     61 die(__PACKAGE__." doesn't implement $param") unless defined($RW_SLOTS{$param}) or defined($ASX_SLOTS{$param});
39 23 50       104 $self->{$param} = shift if @_;
40 23         101 return $self->{$param};
41             }
42              
43             sub new {
44 1     1 0 2 my $class = shift;
45 1         2 my %param = @_;
46 1         3 my $self = bless {}, $class;
47              
48 1         4 $self->$_($ASX_SLOTS{$_}) foreach keys %ASX_SLOTS;
49 1         15 $self->$_($RW_SLOTS{$_}) foreach keys %RW_SLOTS;
50 1         3 $self->$_($param{$_}) foreach keys %param;
51              
52 1         3 return $self;
53             }
54              
55             sub add_repeat {
56 0     0 0 0 my $self = shift;
57 0   0     0 my $repeat = shift || XML::ASX::Repeat->new;
58 0         0 push @{$self->{queue}}, $repeat;
  0         0  
59              
60 0         0 return $self->{queue}->[scalar @{$self->{queue}} - 1];
  0         0  
61             }
62              
63             sub add_entry {
64 1     1 0 4 my $self = shift;
65 1   33     10 my $entry = shift || XML::ASX::Entry->new;
66 1         3 push @{$self->{queue}}, $entry;
  1         3  
67              
68 1         2 return $self->{queue}->[scalar @{$self->{queue}} - 1];
  1         3  
69             }
70              
71             sub add_event {
72 1     1 0 34 my $self = shift;
73 1   33     14 my $event = shift || XML::ASX::Event->new;
74 0           push @{$self->{queue}}, $event;
  0            
75              
76 0           return $self->{queue}->[scalar @{$self->{queue}} - 1];
  0            
77             }
78              
79             sub xml {
80 0     0 0   my $self = shift;
81              
82 0           my $paramstr = '';
83 0           my %param = $self->each_param;
84 0           foreach my $key (keys %param){
85 0           $paramstr .= $self->entag('PARAM','',{NAME=>$key,VALUE=>$param{$key}},1);
86             }
87              
88 0           my $bannercontent = '';
89 0 0         $bannercontent .= $self->entag('MoreInfo','',{href=>$self->moreinfo,target=>$self->target},1) if $self->moreinfo;
90 0 0         $bannercontent .= $self->entag('Abstract',$self->abstract) if $self->abstract;
91              
92 0           my $content = '';
93 0 0         $content .= $self->entag('ABSTRACT',$self->abstract) if $self->abstract;
94 0 0         $content .= $self->entag('TITLE',$self->title) if $self->title;
95 0 0         $content .= $self->entag('AUTHOR',$self->author) if $self->author;
96 0 0         $content .= $self->entag('BASE','',{href=>$self->base}) if $self->base;
97 0 0         $content .= $self->entag('COPYRIGHT',$self->copyright) if $self->copyright;
98 0 0         $content .= $self->entag('Logo','',{href=>$self->logo_icon,style=>'ICON'},1) if $self->logo_icon;
99 0 0         $content .= $self->entag('Logo','',{href=>$self->logo_mark,style=>'MARK'},1) if $self->logo_mark;
100 0 0         $content .= $self->entag('Banner',$bannercontent,{href=>$self->banner}) if $self->banner;
101 0 0         $content .= $self->entag('MoreInfo','',{href=>$self->moreinfo,target=>$self->target},1) if $self->moreinfo;
102 0           $content .= $paramstr;
103              
104 0           $content .= join "", ($self->each_in_queue);
105              
106 0           return $self->entag('ASX',$content,{previewmode => $self->previewmode, version => $self->version, BannerBar => $self->bannerbar},0);
107             }
108              
109             1;
110             __END__