[Bps-public-commit] Data-ICal branch, master, updated. 0.19-3-g3ee70a8

Thomas Sibley trs at bestpractical.com
Wed May 1 21:59:16 EDT 2013


The branch, master has been updated
       via  3ee70a8c4cbd13acb6265c3a707b72f06116df0b (commit)
       via  3be51e78e41d22b534a4b1748e513b431a4c3e1d (commit)
       via  ace3613aeb5627fbb5d2f9dfca6fd39878dbf345 (commit)
      from  688fc54c2aa12900f38bd4038c70de425a1a2914 (commit)

Summary of changes:
 MANIFEST                     |  2 ++
 lib/Data/ICal/Entry.pm       |  1 +
 lib/Data/ICal/Entry/Event.pm | 58 +++++++++++++++++++++++-------
 lib/Data/ICal/Entry/Todo.pm  | 58 +++++++++++++++++++++++-------
 t/12.verson1.t               | 84 ++++++++++++++++++++++++++++++++++++++++++++
 t/ics/version1.ics           | 41 +++++++++++++++++++++
 6 files changed, 218 insertions(+), 26 deletions(-)
 create mode 100644 t/12.verson1.t
 create mode 100644 t/ics/version1.ics

- Log -----------------------------------------------------------------
commit ace3613aeb5627fbb5d2f9dfca6fd39878dbf345
Author: Ashley Willis <ashleyw at cpan.org>
Date:   Sat Dec 15 23:33:25 2012 -0500

    Fix properties when the vcalendar is version 1.0, and add specific known properties for version 1.0.
    
    lib/Data/ICal/Entry.pm:
    * added line to _parse_data_ical_generic to set vcal10 mode.
    
    lib/Data/ICal/Entry/Event.pm:
    * modified optional_unique_properties and optional_repeatable_properties for version 1.0 properties.
    
    lib/Data/ICal/Entry/Todo.pm:
    * modified optional_unique_properties and optional_repeatable_properties for version 1.0 properties.
    
    t/12.verson1.t:
    * new file to test version 1.0 calendars.
    
    t/ics/version1.ics:
    * new file to support above tests.

diff --git a/MANIFEST b/MANIFEST
index 9921a9b..d0835d0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -43,8 +43,10 @@ t/08.parse.t
 t/09.mime.t
 t/10.mime-vcal10.t
 t/11.crlf.t
+t/12.verson1.t
 t/ics/badlyformed.ics
 t/ics/noversion.ics
 t/ics/test.ics
+t/ics/version1.ics
 t/pod-coverage.t
 t/pod.t
diff --git a/lib/Data/ICal/Entry.pm b/lib/Data/ICal/Entry.pm
index 7ffbca2..f7fbc24 100644
--- a/lib/Data/ICal/Entry.pm
+++ b/lib/Data/ICal/Entry.pm
@@ -543,6 +543,7 @@ sub _parse_data_ical_generic {
 
     $entry_class->import;
     my $entry = $entry_class->new;
+    $entry->vcal10($parent->vcal10);
     $parent->_parse_generic_event( $entry, $object );
     $parent->add_entry($entry);
     return $entry;
diff --git a/lib/Data/ICal/Entry/Event.pm b/lib/Data/ICal/Entry/Event.pm
index 4828354..f721b72 100644
--- a/lib/Data/ICal/Entry/Event.pm
+++ b/lib/Data/ICal/Entry/Event.pm
@@ -56,17 +56,34 @@ In addition, C<dtend> and C<duration> may be specified at most once
 each, but not both in the same entry (though this restriction is not
 enforced).
 
+Or if C<< vcal10 => 1 >>:
+
+        class dcreated completed description dtstart dtend
+        last-modified location rnum priority
+        sequence status summary transp
+        url uid
+
 =cut
 
 sub optional_unique_properties {
-    qw(
-        class  created  description  dtstart  geo
-        last-modified  location  organizer  priority
-        dtstamp  sequence  status  summary  transp
-        uid  url  recurrence-id
-
-        dtend duration
-    );
+    my $self = shift;
+    if (!defined $self->vcal10 || !$self->vcal10) {
+        qw(
+            class  created  description  dtstart  geo
+            last-modified  location  organizer  priority
+            dtstamp  sequence  status  summary  transp
+            uid  url  recurrence-id
+
+            dtend duration
+        );
+    } else {
+        qw(
+            class dcreated completed description dtstart dtend
+            last-modified location rnum priority
+            sequence status summary transp
+            url uid
+        );
+    }
 }
 
 =head2 optional_repeatable_properties
@@ -78,14 +95,29 @@ specified any number of times for an event:
 	contact  exdate  exrule  request-status  related-to 
 	resources  rdate  rrule  
 
+Or if C<< vcal10 => 1 >>:
+
+        aalarm  attach  attendee  categories
+        dalarm  exdate  exrule  malarm  palarm  related-to
+        resources  rdate  rrule
+
 =cut
 
 sub optional_repeatable_properties {
-    qw(
-        attach  attendee  categories  comment
-        contact  exdate  exrule  request-status  related-to
-        resources  rdate  rrule
-    );
+    my $self = shift;
+    if (!defined $self->vcal10 || !$self->vcal10) {
+        qw(
+            attach  attendee  categories  comment
+            contact  exdate  exrule  request-status  related-to
+            resources  rdate  rrule
+        );
+    } else {
+        qw(
+            aalarm  attach  attendee  categories
+            dalarm  exdate  exrule  malarm  palarm  related-to
+            resources  rdate  rrule
+        );
+    }
 }
 
 =head1 SEE ALSO
diff --git a/lib/Data/ICal/Entry/Todo.pm b/lib/Data/ICal/Entry/Todo.pm
index c98dfa6..c904fbd 100644
--- a/lib/Data/ICal/Entry/Todo.pm
+++ b/lib/Data/ICal/Entry/Todo.pm
@@ -56,17 +56,34 @@ In addition, C<due> and C<duration> may be specified at most once
 each, but not both in the same entry (though this restriction is not
 enforced).
 
+Or if C<< vcal10 => 1 >>:
+
+        class dcreated completed description dtstart due
+        last-modified location rnum priority
+        sequence status summary transp
+        url uid
+
 =cut
 
 sub optional_unique_properties {
-    qw(
-        class  completed  created  description  dtstamp
-        dtstart  geo  last-modified  location  organizer
-        percent-complete  priority  recurrence-id  sequence  status
-        summary  uid  url
-
-        due duration
-    );
+    my $self = shift;
+    if (!defined $self->vcal10 || !$self->vcal10) {
+        qw(
+            class  completed  created  description  dtstamp
+            dtstart  geo  last-modified  location  organizer
+            percent-complete  priority  recurrence-id  sequence  status
+            summary  uid  url
+
+            due duration
+        );
+    } else {
+        qw(
+            class dcreated completed description dtstart due
+            last-modified location rnum priority
+            sequence status summary transp
+            url uid
+        );
+    }
 }
 
 =head2 optional_repeatable_properties
@@ -78,14 +95,29 @@ specified any number of times for a to-do item:
       exdate  exrule  request-status  related-to  resources
       rdate  rrule  
 
+Or if C<< vcal10 => 1 >>:
+
+        aalarm  attach  attendee  categories
+        dalarm  exdate  exrule  malarm  palarm  related-to
+        resources  rdate  rrule
+
 =cut
 
 sub optional_repeatable_properties {
-    qw(
-        attach  attendee  categories  comment  contact
-        exdate  exrule  request-status  related-to  resources
-        rdate  rrule
-    );
+    my $self = shift;
+    if (!defined $self->vcal10 || !$self->vcal10) {
+        qw(
+            attach  attendee  categories  comment  contact
+            exdate  exrule  request-status  related-to  resources
+            rdate  rrule
+        );
+    } else {
+        qw(
+            aalarm  attach  attendee  categories
+            dalarm  exdate  exrule  malarm  palarm  related-to
+            resources  rdate  rrule
+        );
+    }
 }
 
 =head1 AUTHOR
diff --git a/t/12.verson1.t b/t/12.verson1.t
new file mode 100644
index 0000000..5430323
--- /dev/null
+++ b/t/12.verson1.t
@@ -0,0 +1,84 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+
+use constant TESTS_IN_TEST_CALENDAR => 6;
+use Test::More tests => 10 + 3 * TESTS_IN_TEST_CALENDAR;
+use Test::LongString;
+use Test::Warn;
+
+BEGIN { use_ok('Data::ICal') }
+
+my $cal;
+
+warnings_are { $cal = Data::ICal->new(filename => 't/ics/version1.ics') }
+    [ {carped => "Unknown property for Data::ICal::Entry::Event: malarm"},
+    {carped => "Unknown property for Data::ICal::Entry::Event: dcreated"} ],
+    "Got a warning for fake property set";
+ok((not $cal), "rejected calendar with version property value 1.0");
+
+warnings_are { $cal = Data::ICal->new(filename => 't/ics/test.ics', vcal10 => 1) }
+    [ {carped => "Unknown property for Data::ICal::Entry::Event: duration"} ],
+    "Got a warning for fake property set";
+ok((not $cal), "rejected calendar with version property value 2.0");
+
+require Test::NoWarnings;
+
+$cal = Data::ICal->new(filename => 't/ics/version1.ics', vcal10 => 1);
+
+isa_ok($cal, 'Data::ICal');
+
+test_calendar($cal);
+
+my $data = $cal->as_string;
+like($data, qr/^BEGIN:VCALENDAR/, "looks like a calendar");
+
+my $roundtripped_from_data_cal = Data::ICal->new(data => $data, vcal10 => 1);
+isa_ok($roundtripped_from_data_cal, 'Data::ICal');
+
+test_calendar($roundtripped_from_data_cal);
+
+SKIP: {
+    my $CAL_FILENAME = "t/ics/out.ics";
+    skip "Can't create $CAL_FILENAME: $!", 1 + TESTS_IN_TEST_CALENDAR unless open my $fh,'>', $CAL_FILENAME;
+    print $fh $cal->as_string;
+    close $fh;
+
+    my $roundtripped_cal = Data::ICal->new(filename => $CAL_FILENAME, vcal10 => 1);
+    isa_ok($roundtripped_cal, 'Data::ICal');
+
+    test_calendar($roundtripped_cal);
+
+    unlink $CAL_FILENAME;
+}
+
+Test::NoWarnings::had_no_warnings();
+
+sub test_calendar {
+    my $s = shift;
+    is($s->ical_entry_type, 'VCALENDAR', "Is a VCALENDAR");
+    my $id = $s->property('prodid')->[0]->value;
+    is($id,'-//Mirapoint Calendar', 'Got id');
+
+    my @entries = @{$s->entries};
+    is(@entries,1,"Correct number of entries");
+
+    my $event;
+
+    for (@entries) {
+        if ( $_->ical_entry_type eq 'VEVENT' ) {
+            $event = $_;
+        }
+    }
+    undef(@entries);
+
+    # Event
+    isa_ok($event, 'Data::ICal::Entry::Event');
+    is($event->property('summary')->[0]->value, 'cal1');
+
+    # check sub entries
+    @entries = @{$event->entries};
+    is(@entries, 0, "Got no sub entries");
+    undef(@entries);
+}
diff --git a/t/ics/version1.ics b/t/ics/version1.ics
new file mode 100644
index 0000000..f6a95ca
--- /dev/null
+++ b/t/ics/version1.ics
@@ -0,0 +1,41 @@
+BEGIN:VCALENDAR
+PRODID:-//Mirapoint Calendar
+VERSION:1.0
+BEGIN:VEVENT
+UID:mcal:e158a06000 at mail.example.com
+SUMMARY:cal1
+DESCRIPTION:bleh
+DCREATED:19600314T004656Z
+LAST-MODIFIED:20121207T220428Z
+PRIORITY:3
+MALARM:20121210T125500Z;PT0H;1;888-555-1212;cal1
+X-MIRA-ACCESSREAD:DEFAULT
+X-MIRA-ACCESSWRITE:DEFAULT
+CLASS:CONFIDENTIAL
+SEQUENCE:1
+X-MIRA-REVISION:2
+X-MIRA-TZ:America/New_York
+X-MIRA-VTZ;ENCODING=QUOTED-PRINTABLE:BEGIN:VTIMEZONE=0D=0ATZID:America/New=
+ _York=0D=0ABEGIN:DAYLIGHT=0D=0ATZOFFSETFROM:-0500=0D=0ATZOFFSETTO:-0400=0D=
+ =0ATZNAME:EDT=0D=0ADTSTART:19700308T020000=0D=0ARRULE:FREQ=3DYEARLY;BYMONT=
+ H=3D3;BYDAY=3D2SU=0D=0AEND:DAYLIGHT=0D=0ABEGIN:STANDARD=0D=0ATZOFFSETFROM:=
+ -0400=0D=0ATZOFFSETTO:-0500=0D=0ATZNAME:EST=0D=0ADTSTART:19701101T020000=
+ =0D=0ARRULE:FREQ=3DYEARLY;BYMONTH=3D11;BYDAY=3D1SU=0D=0AEND:STANDARD=0D=0A=
+ END:VTIMEZONE=0D=0A
+DTSTART:20121210T130000Z
+DTEND:20121210T140000Z
+X-MIRA-STATUS:NEWUI
+X-MIRA-CLIENTID:040000008200E00074C5B7101A82E008
+ 000000000021C7EAB71B096E0000000000000000100000001338F0DFC7CD3183F6A2D58D58
+ A06000
+X-MIRA-MASTERCLIENTID:040000008200E00074C5B7101A
+ 82E008000000000021C7EAB71B096E0000000000000000100000001338F0DFC7CD3183F6A2
+ D58D58A06000
+X-MIRA-OWNERSREFLOCAL:l!uuid!d66c7c82-b897-1031-
+ 9c2a-001517b0b2c8!ashley at example.com:e158a06000 at mail.example.com
+X-MIRA-CREATIONUSER:!uuid!d66c7c82-b897-1031-9c2
+ a-001517b0b2c8!mail.example.com
+CATEGORIES:none
+ATTENDEE;ROLE=OWNER;STATUS=CONFIRMED:ashley willis <!uuid!d66c7c82-b897-1031-9c2a-001517b0b2c8!ashley at example.com>
+END:VEVENT
+END:VCALENDAR

commit 3be51e78e41d22b534a4b1748e513b431a4c3e1d
Merge: 688fc54 ace3613
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed May 1 18:52:40 2013 -0700

    Merge remote-tracking branch 'github/pr/1'


commit 3ee70a8c4cbd13acb6265c3a707b72f06116df0b
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed May 1 18:58:25 2013 -0700

    Simplify the version 1.0 check in available properties

diff --git a/lib/Data/ICal/Entry/Event.pm b/lib/Data/ICal/Entry/Event.pm
index f721b72..08a1646 100644
--- a/lib/Data/ICal/Entry/Event.pm
+++ b/lib/Data/ICal/Entry/Event.pm
@@ -67,7 +67,7 @@ Or if C<< vcal10 => 1 >>:
 
 sub optional_unique_properties {
     my $self = shift;
-    if (!defined $self->vcal10 || !$self->vcal10) {
+    if (not $self->vcal10) {
         qw(
             class  created  description  dtstart  geo
             last-modified  location  organizer  priority
@@ -105,7 +105,7 @@ Or if C<< vcal10 => 1 >>:
 
 sub optional_repeatable_properties {
     my $self = shift;
-    if (!defined $self->vcal10 || !$self->vcal10) {
+    if (not $self->vcal10) {
         qw(
             attach  attendee  categories  comment
             contact  exdate  exrule  request-status  related-to
diff --git a/lib/Data/ICal/Entry/Todo.pm b/lib/Data/ICal/Entry/Todo.pm
index c904fbd..b1e0eb6 100644
--- a/lib/Data/ICal/Entry/Todo.pm
+++ b/lib/Data/ICal/Entry/Todo.pm
@@ -67,7 +67,7 @@ Or if C<< vcal10 => 1 >>:
 
 sub optional_unique_properties {
     my $self = shift;
-    if (!defined $self->vcal10 || !$self->vcal10) {
+    if (not $self->vcal10) {
         qw(
             class  completed  created  description  dtstamp
             dtstart  geo  last-modified  location  organizer
@@ -105,7 +105,7 @@ Or if C<< vcal10 => 1 >>:
 
 sub optional_repeatable_properties {
     my $self = shift;
-    if (!defined $self->vcal10 || !$self->vcal10) {
+    if (not $self->vcal10) {
         qw(
             attach  attendee  categories  comment  contact
             exdate  exrule  request-status  related-to  resources

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list