| 1 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Data::ICal::Entry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use base qw/Class::Accessor/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Data::ICal::Property; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use Sys::Hostname qw(); # For unique UIDs for entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use constant CRLF => "\x0d\x0a"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | Data::ICal::Entry - Represents an entry in an iCalendar file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | my $vtodo = Data::ICal::Entry::Todo->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $vtodo->add_property( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # ... see Data::ICal::Entry::Todo documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | $vtodo->add_properties( ... ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | $calendar->add_entry($vtodo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | $event->add_entry($alarm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $event->add_entries($alarm1, ...); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # or all in one go | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | my $vtodo = Data::ICal::Entry::Todo->new( \%props, \@entries ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | A L<Data::ICal::Entry> object represents a single entry in an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | iCalendar file. (Note that the iCalendar RFC refers to entries as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | "components".) iCalendar defines several types of entries, such as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | events and to-do lists; each of these corresponds to a subclass of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | L<Data::ICal::Entry> (though only to-do lists and events are currently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | implemented). L<Data::ICal::Entry> should be treated as an abstract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | base class -- all objects created should be of its subclasses. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | entire calendar itself (the L<Data::ICal> object) is also represented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | as a L<Data::ICal::Entry> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | Each entry has an entry type (such as C<VCALENDAR> or C<VEVENT>), a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | series of "properties", and possibly some sub-entries. (Only the root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | L<Data::ICal> object can have sub-entries, except for alarm entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | contained in events and to-dos (not yet implemented).) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Creates a new entry object with no properties or sub-entries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 87 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 87 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 87 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # ALLOW passing arguments here! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 87 | $self->set( properties => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 87 | $self->set( entries => [] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 87 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 43 | ▶ | ref $_ eq "HASH" and $self->add_properties( %$_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 43 | ▶ | ref $_ eq "ARRAY" and $self->add_entries( @$_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 87 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | =head2 as_string [ crlf => C<CRLF> ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | Returns the entry as an appropriately formatted string (with trailing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | newline). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | Properties are returned in alphabetical order, with multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | properties of the same name returned in the order added. (Property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | order is unimportant in iCalendar, and this makes testing easier.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | If any mandatory property is missing, issues a warning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | The string to use as a newline can optionally be specified by giving | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | the a C<crlf> argument, which defaults to C<\x0d\x0a>, per RFC 2445 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | spec; this option is primarily for backwards compatibility with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | versions of this module before 0.16. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 14 | my $uid = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 58 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=12 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 58 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 58 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | crlf => CRLF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 58 | my $output = $self->header(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 58 | my @mandatory = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $self->mandatory_unique_properties, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $self->mandatory_repeatable_properties, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 58 | ▶ | if (grep {$_ eq "uid"} @mandatory and !defined $self->properties->{uid} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
grep {$_ eq "uid";} @mandatory and not defined $self->properties->{"uid"} and $self->auto_uid
grep {$_ eq "uid";} @mandatory and not defined $self->properties->{"uid"}
MC/DC0%0/3
grep {$_ eq "uid";} @mandatory and not defined $self->properties->{"uid"} and $self->auto_uid
grep {$_ eq "uid";} @mandatory
not defined $self->properties->{"uid"}
$self->auto_uid
Truth table25%1/4
A and not(B) and C
A= grep {$_ eq "uid";} @mandatoryB= not defined $self->properties->{"uid"}C= $self->auto_uid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | and $self->auto_uid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # Per the RFC, create a "persistent, globally unique" UID for this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # event; "persistent" in this context does not mean consistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # across time, but rather "unique across all time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->add_property( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | uid => time() . '-' .$$ . '-' . $uid++ . '@' . Sys::Hostname::hostname() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 58 | for my $name ( @mandatory ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | carp "Mandatory property for " . ( ref $self ) . " missing: $name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | unless $self->properties->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 74 | ▶ | and @{ $self->properties->{$name} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->properties->{$name} and @{$self->properties->{$name};}
MC/DC50%1/2
$self->properties->{$name} and @{$self->properties->{$name};}
$self->properties->{$name}
@{$self->properties->{$name};}
Truth table66%2/3
A and B
A= $self->properties->{$name}B= @{$self->properties->{$name};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | my @properties = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # RFC2445 implies an order (see 4.6 Calendar Components) but does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # require it. However, some applications break if VERSION is not first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # (see http://icalvalid.cloudapp.net/Default.aspx and [rt.cpan.org # #65447]). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 294 | ▶ | return -1 if $a eq 'version'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 279 | ▶ | return 1 if $b eq 'version'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 276 | return $a cmp $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 58 | } keys %{ $self->properties }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 58 | for my $name (@properties) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | $output .= $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 199 | for map { $_->as_string(%args) } @{ $self->properties->{$name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 58 | for my $entry ( @{ $self->entries } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 33 | $output .= $entry->as_string(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 58 | $output .= $self->footer(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 58 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =head2 add_entry $entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Adds an entry to this entry. (According to the standard, this should | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | only be called on either a to-do or event entry with an alarm entry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | or on a calendar entry (L<Data::ICal>) with a to-do, event, journal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | timezone, or free/busy entry.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Returns true if the entry was successfully added, and false otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | (perhaps because you tried to add an entry of an invalid type, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | this check hasn't been implemented yet). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 60 | ▶ | sub add_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_entry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 60 | my $entry = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 60 | push @{ $self->{entries} }, $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 60 | $entry->vcal10( $self->vcal10 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 60 | $entry->rfc_strict( $self->rfc_strict ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 60 | $entry->auto_uid( $self->auto_uid ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 60 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | =head2 add_entries $entry1, [$entry2, ...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | Convenience function to call C<add_entry> several times with a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | of entries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub add_entries { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_entries: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->add_entry( $_ ) for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | =head2 entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | Returns a reference to the array of subentries of this entry. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 14 | __PACKAGE__->mk_ro_accessors('entries'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | =head2 properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | Returns a reference to the hash of properties of this entry. The keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | are property names and the values are array references containing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | L<Data::ICal::Property> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | __PACKAGE__->mk_ro_accessors('properties'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | =head2 property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Given a property name returns a reference to the array of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | L<Data::ICal::Property> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 44 | ▶ | sub property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 44 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 44 | my $prop = lc shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 44 | return $self->{'properties'}->{$prop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | =head2 add_property $propname => $propval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | Creates a new L<Data::ICal::Property> object with name C<$propname> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | and value C<$propval> and adds it to the event. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | If the property is not known to exist for that object type and does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | not begin with C<X->, issues a warning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | If the property is known to be unique, replaces the original property. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | To specify parameters for the property, let C<$propval> be a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | two-element array reference where the first element is the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | value and the second element is a hash reference. The keys of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | hash are parameter names; the values should be either strings or array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | references of strings, depending on whether the parameter should have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | one or multiple (to be comma-separated) values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | Examples of setting parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # Add a property with a parameter of VALUE set to 'DATE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $event->add_property( rdate => [ $date, { VALUE => 'DATE' } ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 362 | ▶ | sub add_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_property: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 362 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 362 | my $prop = lc shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 362 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 362 | ▶ | return unless defined $prop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 362 | ▶ | unless ( $self->is_property($prop) or $prop =~ /^x-/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->is_property($prop) or $prop =~ /^x-/i
MC/DC100%2/2
$self->is_property($prop) or $prop =~ /^x-/i
$self->is_property($prop)
$prop =~ /^x-/i
Truth table100%3/3
A or B
A= $self->is_property($prop)B= $prop =~ /^x-/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | carp "Unknown property for " . ( ref $self ) . ": $prop"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 362 | ▶ | if ( $self->is_unique($prop) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # It should be unique, so clear out anything we might have first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 265 | $self->properties->{$prop} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 362 | ▶ | $val = [ $val, {} ] unless ref $val eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 362 | my ( $prop_value, $param_hash ) = @$val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 362 | my $p = Data::ICal::Property->new( $prop => $prop_value, $param_hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 362 | $p->vcal10( $self->vcal10 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 362 | push @{ $self->properties->{$prop} }, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 362 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =head2 add_properties $propname1 => $propval1, [$propname2 => $propname2, ...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | Convenience function to call C<add_property> several times with a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | of properties. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | This method is guaranteed to call add C<add_property> on them in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | order given, so that unique properties given later in the call will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | take precedence over those given earlier. (This is unrelated to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | order of properties when the entry is rendered as a string, though.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | Parameters for the properties are specified in the same way as in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | C<add_property>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 13 | ▶ | sub add_properties { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_properties: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 13 | ▶ | if ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | carp "Odd number of elements in add_properties call"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 13 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 33 | my $prop = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 33 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 33 | $self->add_property( $prop => $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | =head2 mandatory_unique_properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | Subclasses should override this method (which returns an empty list by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | default) to provide a list of lower case strings identifying the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | properties which must appear exactly once in the subclass's entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub mandatory_unique_properties { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mandatory_unique_properties: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | =head2 mandatory_repeatable_properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | Subclasses should override this method (which returns an empty list by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | default) to provide a list of lower case strings identifying the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | properties which must appear at least once in the subclass's entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 420 | ▶ | sub mandatory_repeatable_properties { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mandatory_repeatable_properties: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | =head2 optional_unique_properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | Subclasses should override this method (which returns an empty list by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | default) to provide a list of lower case strings identifying the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | properties which must appear at most once in the subclass's entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 240 | ▶ | sub optional_unique_properties { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optional_unique_properties: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | =head2 optional_repeatable_properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | Subclasses should override this method (which returns an empty list by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | default) to provide a list of lower case strings identifying the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | properties which may appear zero, one, or more times in the subclass's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | entry type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 84 | ▶ | sub optional_repeatable_properties { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optional_repeatable_properties: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | =head2 is_property $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | Returns a boolean value indicating whether or not the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | C<$name> is known to the class (that is, if it's listed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | C<(mandatory/optional)_(unique/repeatable)_properties>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 362 | ▶ | sub is_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_property: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 362 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 362 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 362 | return scalar grep { $_ eq $name } $self->mandatory_unique_properties, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | $self->mandatory_repeatable_properties, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | $self->optional_unique_properties, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | $self->optional_repeatable_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | =head2 is_mandatory $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | Returns a boolean value indicating whether or not the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | C<$name> is known to the class as mandatory (that is, if it's listed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | in C<mandatory_(unique/repeatable)_properties>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub is_mandatory { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mandatory: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return scalar grep { $_ eq $name } $self->mandatory_unique_properties, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $self->mandatory_repeatable_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =head2 is_optional $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | Returns a boolean value indicating whether or not the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | C<$name> is known to the class as optional (that is, if it's listed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | C<optional_(unique/repeatable)_properties>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | sub is_optional { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_optional: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return scalar grep { $_ eq $name } $self->optional_unique_properties, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $self->optional_repeatable_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | =head2 is_unique $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | Returns a boolean value indicating whether or not the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | C<$name> is known to the class as unique (that is, if it's listed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | C<(mandatory/optional)_unique_properties>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 362 | ▶ | sub is_unique { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unique: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 362 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 362 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 362 | return scalar grep { $_ eq $name } $self->mandatory_unique_properties, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | $self->optional_unique_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | =head2 is_repeatable $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | Returns a boolean value indicating whether or not the property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | C<$name> is known to the class as repeatable (that is, if it's listed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | in C<(mandatory/optional)_repeatable_properties>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | sub is_repeatable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_repeatable: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return scalar grep { $_ eq $name } $self->mandatory_repeatable_properties, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | $self->optional_repeatable_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | =head2 ical_entry_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | Subclasses should override this method to provide the identifying type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | name of the entry (such as C<VCALENDAR> or C<VTODO>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub ical_entry_type {'UNDEFINED'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ical_entry_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | =head2 vcal10 [$bool] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | Gets or sets a boolean saying whether this entry should be interpreted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | as vCalendar 1.0 (as opposed to iCalendar 2.0). Generally, you can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | just set this on your main L<Data::ICal> object when you construct it; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | C<add_entry> automatically makes sure that sub-entries end up with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | same value as their parents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 14 | __PACKAGE__->mk_accessors('vcal10'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | =head2 rfc_strict [$bool] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | Gets or sets a boolean saying whether this entry will complain about | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | missing UIDs as per RFC2446. Defaults to false, for backwards | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | compatibility. Generally, you can just set this on your main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | L<Data::ICal> object when you construct it; C<add_entry> automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | makes sure that sub-entries end up with the same value as their parents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 14 | __PACKAGE__->mk_accessors('rfc_strict'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | =head2 auto_uid [$bool] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | Gets or sets a boolean saying whether this entry should automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | generate its own persistently unique UIDs. Defaults to false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | Generally, you can just set this on your main L<Data::ICal> object when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | you construct it; C<add_entry> automatically makes sure that sub-entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | end up with the same value as their parents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 14 | __PACKAGE__->mk_accessors('auto_uid'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | =head2 header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | Returns the header line for the entry (including trailing newline). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 58 | ▶ | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 58 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 58 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | crlf => CRLF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 58 | return 'BEGIN:' . $self->ical_entry_type . $args{crlf}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | =head2 footer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | Returns the footer line for the entry (including trailing newline). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 58 | ▶ | sub footer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
footer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 58 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 58 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | crlf => CRLF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 58 | return 'END:' . $self->ical_entry_type . $args{crlf}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # mapping of event types to class (under the Data::Ical::Event namespace) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 14 | my %_generic = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | vevent => 'Event', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | vtodo => 'Todo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | vjournal => 'Journal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | vfreebusy => 'FreeBusy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | vtimezone => 'TimeZone', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | standard => 'TimeZone::Standard', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | daylight => 'TimeZone::Daylight', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | =head2 parse_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | Translate a L<Text::vFile::asData> sub object into the appropriate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | L<Data::iCal::Event> subtype. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # TODO: this is currently recursive which could blow the stack - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # it might be worth refactoring to make it sequential | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 66 | ▶ | sub parse_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_object: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 66 | my ( $self, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 66 | my $type = $object->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 66 | my $new_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # First check to see if it's generic long name just in case there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # event turns out to be a VGENERIC entry type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 66 | ▶ | if ( my $class = $_generic{ lc($type) } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 48 | $new_self = $self->_parse_data_ical_generic( $class, $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # then look for specific overrides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } elsif ( my $sub = $self->can( '_parse_' . lc($type) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 18 | $new_self = $self->$sub($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # complain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | warn "Can't parse type $type yet"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # recurse through sub-objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 66 | foreach my $sub_object ( @{ $object->{objects} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 53 | $new_self->parse_object($sub_object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 66 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # special because we want to use ourselves as the parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 13 | ▶ | sub _parse_vcalendar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vcalendar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 13 | my ( $self, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 13 | $self->_parse_generic_event( $self, $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # mapping of action types to class (under the Data::Ical::Event::Alarm namespace) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 14 | my %_action_map = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | AUDIO => 'Audio', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | DISPLAY => 'Display', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | EMAIL => 'Email', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | PROCEDURE => 'Procedure', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | NONE => 'None', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | URI => 'URI', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # alarms have actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 5 | ▶ | sub _parse_valarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_valarm: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 5 | my ( $parent, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # ick | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 5 | my $action = $object->{properties}->{ACTION}->[0]->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | die "Can't parse VALARM with action $action" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 5 | ▶ | unless exists $_action_map{$action}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 5 | $action = $_action_map{$action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 5 | my $alarm_class = "Data::ICal::Entry::Alarm::$action"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | eval "require $alarm_class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | ▶ | die "Failed to require $alarm_class : $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 5 | $alarm_class->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 5 | my $alarm = $alarm_class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 5 | $parent->_parse_generic_event( $alarm, $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 5 | $parent->add_entry($alarm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 5 | return $alarm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # generic event handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 48 | ▶ | sub _parse_data_ical_generic { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_data_ical_generic: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 48 | my ( $parent, $class, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 48 | my $entry_class = "Data::ICal::Entry::$class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 48 | eval "require $entry_class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 48 | ▶ | die "Failed to require $entry_class : $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 48 | $entry_class->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 48 | my $entry = $entry_class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 48 | $entry->vcal10($parent->vcal10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 48 | $parent->_parse_generic_event( $entry, $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 48 | $parent->add_entry($entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 48 | return $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # handle transferring of properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 66 | ▶ | sub _parse_generic_event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_generic_event: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 66 | my ( $parent, $entry, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 66 | my $p = $object->{properties}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 66 | for my $key ( sort keys %$p ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 315 | foreach my $occurence (@{ $p->{$key} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 315 | my $prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # Unescapes, but only in v2, and not if it's explicitly not TEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 315 | ▶ | if (not $parent->vcal10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not $parent->vcal10 and !($occurence->{"param"} && defined $occurence->{"param"}{"VALUE"}) || $occurence->{"param"}{"VALUE"} eq "TEXT"
not $occurence->{"param"} && defined $occurence->{"param"}{"VALUE"} or $occurence->{"param"}{"VALUE"} eq "TEXT"
$occurence->{'param'} && defined $occurence->{'param'}{'VALUE'}
MC/DC75%3/4
not $parent->vcal10 and !($occurence->{"param"} && defined $occurence->{"param"}{"VALUE"}) || $occurence->{"param"}{"VALUE"} eq "TEXT"
not $parent->vcal10
$occurence->{'param'}
defined $occurence->{'param'}{'VALUE'}
$occurence->{"param"}{"VALUE"} eq "TEXT"
Truth table80%4/5
not(A) and not(B && C) or D
A= not $parent->vcal10B= $occurence->{'param'}C= defined $occurence->{'param'}{'VALUE'}D= $occurence->{"param"}{"VALUE"} eq "TEXT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | and ( not $occurence->{param} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | or not defined $occurence->{param}{VALUE} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | or $occurence->{param}{VALUE} eq "TEXT" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 189 | $occurence->{value} =~ s/\\([;,\\])/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 189 | $occurence->{value} =~ s/\\n/\n/ig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # handle optional params and 'normal' key/value pairs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # TODO: line wrapping? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 315 | ▶ | if ( $occurence->{param} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 30 | $prop = [ $occurence->{value}, $occurence->{param} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 285 | $prop = $occurence->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 315 | $entry->add_property( lc($key) => $prop ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 66 | return $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | Best Practical Solutions, LLC E<lt>modules@bestpractical.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | Copyright (c) 2005 - 2020, Best Practical Solutions, LLC. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||