ICal/Journal.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 34 CC 3 SCAR 17.5
CC
3
Cov
0%
new
12.0
validate
2.0
_create
2.0
CRAP 5.8
1 #!/usr/bin/perl -w
2 # vi:sts=4:shiftwidth=4
3 # -*- Mode: perl -*-
4 #======================================================================
5 #
6 # This package is free software and is provided "as is" without
7 # express or implied warranty. It may be used, redistributed and/or
8 # modified under the same terms as perl itself. ( Either the Artistic
9 # License or the GPL. )
10 #
11 # $Id: Journal.pm,v 1.14 2001/07/09 14:35:34 lotr Exp $
12 #
13 # (C) COPYRIGHT 2000-2001, Reefknot developers.
14 #
15 # See the AUTHORS file included in the distribution for a full list.
16 #======================================================================
17  
18 =head1 NAME
19  
20 Net::ICal::Journal -- Journal class
21  
22 =cut
23  
24 package Net::ICal::Journal;
25 use strict;
26  
27 use base qw(Net::ICal::ETJ);
28  
29 use Carp;
30  
31 =head1 SYNOPSIS
32  
33 use Net::ICal::Journal;
34 my $c = new Net::ICal::Journal(optionhash);
35  
36 =head1 DESCRIPTION
37  
38 Net::ICal::Journal represents Journal events: things someone did,
39 perhaps.
40  
41 =pod
42  
43 =head1 BASIC METHODS
44  
45 =head2 new(optionhash)
46  
47 Makes a new Journal object, given a hash of parameters. RFC-valid parameters
48 are below.
49  
50 USAGE NOTE: We're working on describing *how* these get used (semantics).
51 Read the source for this module if you're looking for a parameter that's
52 in the RFC for VJOURNALs and isn't listed here. We probably had a question
53 about whether it was really useful for Journal objects.
54  
55 =head2 REQUIRED
56  
57 =over 4
58  
59 =item * organizer - a Net::ICal::Attendee for who's organizing this meeting.
60  
61 =back
62  
63  
64 =head2 OPTIONAL
65  
66 =over 4
67  
68 =cut
69  
70 #=item * dtstart - a Net::ICal::Time for when you started this Journal item.
71 # XXX: DTSTART isn't really specified in the RFC; I think it's meaningful,
72 # but better not to give people the option to use it unless it means
73 # something to other calendar implementations.
74  
75 =pod
76  
77 =item * class - PUBLIC, PRIVATE, or CONFIDENTIAL - the creator's intention
78 about who should see this Journal. This is B<not> a binding access-control
79 mechanism.
80  
81 =item * created - a Net::ICal::Time saying when this object was created.
82  
83 =item * description - a hash with at least a content key, maybe an altrep
84 and a language key. Content is a description of this Journal.
85  
86 =cut
87  
88 # XXX: for journals, there can be more than one DESCRIPTION item.
89 # See RFC2445 4.8.1.5.
90  
91 =pod
92  
93 =item * dtstamp - when this Journal was created. Will be set to the current
94 time unless otherwise specified.
95  
96 =item * last_modified - a Net::ICal::Time specifying the last time this
97 object was changed.
98  
99 =item * status - DRAFT, FINAL, or CANCELLED;
100 the status of this journal item.
101  
102 =item * summary - a one-line summary of this Journal. If you need more
103 space, use the description parameter.
104  
105 =item * uid - a globally unique identifier for this event. Will be created
106 automagically unless you specify it.
107  
108 =item * url - a URL for this Journal. Optional.
109  
110 =item * attach - a Net::ICal::Attach - attached file for this Journal.
111  
112 =item * attendee - an array of Net::ICal::Attendee objects; people who were
113 relevant to this Journal item.
114  
115 =item * categories - an array: what categories this event falls into. Make up
116 your own categories.
117  
118 =item * comment - a hash like that for description (above); comments
119 on this Journal item.
120  
121 =item * contact - a string describing who to contact about this Journal.
122  
123 =cut
124  
125 # This is allowed by the RFC, but I'm not sure what it means to Journal
126 # objects, so I'm excluding it.
127 #=item * request_status - how successful we've been at scheduling this Todo
128 #so far. Values can be integers separated by periods. 1.x.y is a preliminary
129 #success, 2.x.y is a complete successful request, 3.x.y is a failed request
130 #because of bad iCal format, 4.x.y is a calendar server failure.
131  
132 =pod
133  
134 =item * related_to - an array of other Event, Todo, or Journal objects this
135 Journal is related to.
136  
137 =cut
138  
139 # XXX: how do we express related_to in iCal? with UIDs?
140  
141 =pod
142  
143 =item * sequence - an integer that starts at 0 when this object is
144 created and is incremented every time the object is changed.
145  
146 =back
147  
148 =head2 RECURRING TASKS
149  
150 =over 4
151  
152 =item * recurrence_id - if this journal occurs multiple times, which
153 occurrence of it is this particular journal?
154  
155 =item * rdate - an array of Net::ICal::Time objects describing repeated
156 occurrences of this journal.
157  
158 =item * rrule - an array of Net::ICal::Recurrence objects telling when
159 this journal repeats; "every Wednesday at 3pm," for example.
160  
161 =item * exdate - a Net::ICal::Time giving a single-date exception to a
162 recurring journal.
163  
164 =item * exrule - an array of Net::ICal::Recurrence objects giving a
165 recurring exception to a recurring journal. "Every Wednesday except the
166 first Wednesday of the month" is an example.
167  
168 =back
169  
170 =for testing
171 use lib "./lib";
172 use Net::ICal::Journal;
173 use Net::ICal::Attendee;
174 %bogusargs = ();
175 %args = ( organizer => new Net::ICal::Attendee('mailto:alice@example.com'));
176 ok($c = new Net::ICal::Journal ( %args ), "Create a Journal object");
177 #ok(not( $d = new Net::ICal::Journal ( %bogusargs )), "Create a bogus Journal object");
178  
179 =cut
180  
181  
182 sub new {
183 my ($class, %args) = @_;
184  
185 my $self = _create ($class, %args);
186 $self->_init;
187  
188 return undef unless (defined $self);
189 return undef unless $self->validate;
190  
191 return $self;
192 }
193  
194 =pod
195  
196 =head2 validate
197  
198 Validates a Journal object. Returns 1 for success, undef for failure.
199  
200 TODO: make sure that this object has the bare minimum requirements
201 specified by the RFC.
202  
203 =for testing
204 ok($c->validate , "Simple validation should pass");
205 #ok(not($d->validate), "Bogus args should fail");
206  
207 =cut
208  
209 sub validate {
210 my ($self) = @_;
211  
212 #TODO: fill in validation checks
213 #BUG: 424137
214  
215 return $self->SUPER::validate;
216 }
217  
218  
219 # TODO: someone needs to verify that new_from_ical works for Journals.
220 =head2 new_from_ical($txt)
221  
222 Creates a new Journal object from a string of valid iCalendar text.
223  
224 =cut
225  
226  
227 =pod
228  
229 =head1 DEVELOPER METHODS
230  
231 =pod
232  
233 =head2 _create($class, %args)
234  
235 Class::MethodMapper creation routine. Returns a blessed object.
236  
237 =cut
238  
239 sub _create {
240 my ($class, %args) = @_;
241  
242 my $self = $class->SUPER::_create ('VJOURNAL', %args);
243  
244 #TODO: modify the map to include map values that are specific
245 # to Journals, if any.
246 #BUG: 424139
247  
248 # no location in a Journal
249 $self->delete_map (qw(location priority resources duration));
250  
251 return $self;
252 }
253  
254 1;
255  
256 =head1 SEE ALSO
257  
258 L<Net::ICal::Time>, L<Net::ICal::Recurrence>, L<Net::ICal::Attendee>. If you
259 want to know how this works, read the source for this and L<Net::ICal::ETJ>.
260  
261 More documentation pointers can also be found in L<Net::ICal>.
262  
263 =cut