[Rt-commit] r3591 - in Data-ICal: . lib/Data lib/Data/ICal
lib/Data/ICal/Entry/TimeZone
glasser at bestpractical.com
glasser at bestpractical.com
Wed Aug 3 11:50:05 EDT 2005
Author: glasser
Date: Wed Aug 3 11:50:04 2005
New Revision: 3591
Modified:
Data-ICal/ (props changed)
Data-ICal/lib/Data/ICal.pm
Data-ICal/lib/Data/ICal/Entry.pm
Data-ICal/lib/Data/ICal/Entry/TimeZone/Daylight.pm
Data-ICal/lib/Data/ICal/Entry/TimeZone/Standard.pm
Log:
r38405 at tin-foil: glasser | 2005-08-03 11:49:50 -0400
perltidy
Modified: Data-ICal/lib/Data/ICal.pm
==============================================================================
--- Data-ICal/lib/Data/ICal.pm (original)
+++ Data-ICal/lib/Data/ICal.pm Wed Aug 3 11:50:04 2005
@@ -73,12 +73,12 @@
my $self = $class->SUPER::new(@_);
if (@_) {
- $self->parse_file(@_) || return undef;
+ $self->parse_file(@_) || return undef;
} else {
- $self->add_properties(
+ $self->add_properties(
version => '2.0',
prodid => $self->product_id,
- );
+ );
}
return $self;
}
@@ -90,23 +90,22 @@
=cut
sub parse_file {
- my ($self, $file) = @_;
+ my ( $self, $file ) = @_;
-
# open the file (checking as we go, like good little Perl mongers)
- open my($fh), $file or return undef;
+ open my ($fh), $file or return undef;
my $cal = Text::vFile::asData->new->parse($fh) || return undef;
close $fh;
return undef unless exists $cal->{objects};
+
# loop through all the vcards
- foreach my $object (@{ $cal->{objects} }) {
+ foreach my $object ( @{ $cal->{objects} } ) {
$self->parse_object($object);
}
- return 1;
+ return 1;
}
-
=head2 ical_entry_type
Returns C<VCALENDAR>, its iCalendar entry name.
@@ -236,4 +235,5 @@
SUCH DAMAGES.
=cut
+
1;
Modified: Data-ICal/lib/Data/ICal/Entry.pm
==============================================================================
--- Data-ICal/lib/Data/ICal/Entry.pm (original)
+++ Data-ICal/lib/Data/ICal/Entry.pm Wed Aug 3 11:50:04 2005
@@ -139,7 +139,6 @@
return $self->{'properties'};
}
-
=head2 property
Given a property name returns a reference to the array of L<Data::ICal::Property> objects.
@@ -149,10 +148,9 @@
sub property {
my $self = shift;
my $prop = lc shift;
- return $self->{'properties'}->{$prop};
+ return $self->{'properties'}->{$prop};
}
-
=head2 add_property $propname => $propval
Creates a new L<Data::ICal::Property> object with name C<$propname> and value
@@ -375,7 +373,6 @@
daylight => 'TimeZone::Daylight',
);
-
=head2 parse_object
Translate a L<Text::vFile::asData> sub object into the appropriate
@@ -383,114 +380,110 @@
=cut
-
# TODO: this is currently recursive which could blow the stack -
# it might be worth refactoring to make it sequential
sub parse_object {
- my ($self,$object) = @_;
-
+ my ( $self, $object ) = @_;
my $type = $object->{type};
-
-
+
my $new_self;
-
- # First check to see if it's generic long name just in case there
+
+ # First check to see if it's generic long name just in case there
# event turns out to be a VGENERIC entry type
- if (my $class = $_generic{lc($type)}) {
- $new_self = $self->_parse_data_ical_generic($class, $object);
- # then look for specific overrides
- } elsif (my $sub = $self->can('_parse_'.lc($type))) {
+ if ( my $class = $_generic{ lc($type) } ) {
+ $new_self = $self->_parse_data_ical_generic( $class, $object );
+
+ # then look for specific overrides
+ } elsif ( my $sub = $self->can( '_parse_' . lc($type) ) ) {
$new_self = $self->$sub($object);
- # bitch
+
+ # bitch
} else {
warn "Can't parse type $type yet";
return;
}
-
+
# recurse through sub-objects
- foreach my $sub_object(@{ $object->{objects} }) {
+ foreach my $sub_object ( @{ $object->{objects} } ) {
$new_self->parse_object($sub_object);
}
}
-
-
# special because we want to use ourselves as the parent
sub _parse_vcalendar {
- my ($self, $object) = @_;
- $self->_parse_generic_event($self, $object);
+ my ( $self, $object ) = @_;
+ $self->_parse_generic_event( $self, $object );
return $self;
}
# mapping of action types to class (under the Data::Ical::Event::Alarm namespace)
my %_action_map = (
- AUDIO => 'Audio',
- DISPLAY => 'Display',
- EMAIL => 'Email',
- PROCEDURE => 'Procedure',
+ AUDIO => 'Audio',
+ DISPLAY => 'Display',
+ EMAIL => 'Email',
+ PROCEDURE => 'Procedure',
);
# alarms have actions
sub _parse_valarm {
- my ($parent, $object) = @_;
+ my ( $parent, $object ) = @_;
# ick
my $action = $object->{properties}->{ACTION}->[0]->{value};
- die "Can't parse VALARM with action $action" unless exists $_action_map{$action};
+ die "Can't parse VALARM with action $action"
+ unless exists $_action_map{$action};
-
- my $alarm_class = "Data::ICal::Entry::Alarm::".$_action_map{$action};
+ my $alarm_class = "Data::ICal::Entry::Alarm::" . $_action_map{$action};
eval "require $alarm_class";
die "Failed to require $alarm_class : $@" if $@;
$alarm_class->import;
my $alarm = $alarm_class->new;
- $parent->_parse_generic_event($alarm, $object);
+ $parent->_parse_generic_event( $alarm, $object );
$parent->add_entry($alarm);
return $alarm;
-
-}
+}
# generic event handler
sub _parse_data_ical_generic {
- my ($parent, $class, $object) = @_;
-
+ my ( $parent, $class, $object ) = @_;
+
my $entry_class = "Data::ICal::Entry::$class";
eval "require $entry_class";
die "Failed to require $entry_class : $@" if $@;
-
+
$entry_class->import;
my $entry = $entry_class->new;
- $parent->_parse_generic_event($entry, $object);
+ $parent->_parse_generic_event( $entry, $object );
$parent->add_entry($entry);
return $entry;
}
# handle transferring of properties
sub _parse_generic_event {
- my ($parent, $entry, $object) = @_;
+ my ( $parent, $entry, $object ) = @_;
my $p = $object->{properties};
- while (my($key,$val) = each(%$p)) {
+ while ( my ( $key, $val ) = each(%$p) ) {
foreach my $occurence (@$val) {
my $prop;
+
# handle optional params and 'normal' key/value pairs
# TODO: line wrapping?
- if ($occurence->{param}) {
+ if ( $occurence->{param} ) {
$prop = [ $occurence->{value}, $occurence->{param} ];
} else {
$prop = $occurence->{value};
}
- $entry->add_property( lc($key) => $prop );
+ $entry->add_property( lc($key) => $prop );
}
}
return $entry;
}
-
=head1 AUTHOR
Jesse Vincent C<< <jesse at bestpractical.com> >> with David Glasser and Simon Wistow
Modified: Data-ICal/lib/Data/ICal/Entry/TimeZone/Daylight.pm
==============================================================================
--- Data-ICal/lib/Data/ICal/Entry/TimeZone/Daylight.pm (original)
+++ Data-ICal/lib/Data/ICal/Entry/TimeZone/Daylight.pm Wed Aug 3 11:50:04 2005
@@ -81,8 +81,8 @@
sub mandatory_unique_properties {
qw(
dtstart
- tzoffsetto
- tzoffsetfrom
+ tzoffsetto
+ tzoffsetfrom
);
}
@@ -98,9 +98,9 @@
sub optional_repeatable_properties {
qw(
comment
- rdate
- rrule
- tzname
+ rdate
+ rrule
+ tzname
);
}
Modified: Data-ICal/lib/Data/ICal/Entry/TimeZone/Standard.pm
==============================================================================
--- Data-ICal/lib/Data/ICal/Entry/TimeZone/Standard.pm (original)
+++ Data-ICal/lib/Data/ICal/Entry/TimeZone/Standard.pm Wed Aug 3 11:50:04 2005
@@ -81,8 +81,8 @@
sub mandatory_unique_properties {
qw(
dtstart
- tzoffsetto
- tzoffsetfrom
+ tzoffsetto
+ tzoffsetfrom
);
}
@@ -98,9 +98,9 @@
sub optional_repeatable_properties {
qw(
comment
- rdate
- rrule
- tzname
+ rdate
+ rrule
+ tzname
);
}
More information about the Rt-commit
mailing list