ICal/Standard.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 41 CC 3 SCAR 16.1
CC
3
Cov
0%
new
12.0
validate
2.0
_create
2.0
CRAP 5.0
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: Standard.pm,v 1.4 2001/08/04 05:43:32 srl 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::Standard -- class for representing STANDARD timezone sections
21  
22 =cut
23  
24 package Net::ICal::Standard;
25 use strict;
26  
27 use base qw(Net::ICal::Component);
28  
29 use Carp;
30 use Net::ICal::Property;
31 use Net::ICal::Util qw(:all);
32  
33 =head1 DESCRIPTION
34  
35 This module represents a STANDARD section in a VTIMEZONE, which
36 details information about when a particular timezone is on
37 "standard" (not daylight-savings) time.
38  
39 =head1 SYNOPSIS
40  
41 # really, look at Timezone.pm for a better usage example;
42 # this is totally untested
43  
44 my $s = Net::ICal::Standard->new(
45 tzoffsetto => '-0500',
46 tzoffsetfrom => '-0400',
47 rdate => Net::ICal::Recurrence->new ( ...)
48 tzname => 'EST'
49 );
50 =cut
51  
52 =head1 METHODS
53  
54 =head2 new(%args)
55  
56 Makes a new Standard object. Permissible arguments are:
57  
58 =over 4
59  
60 =item * tzoffsetto - the UTC offset this timezone's in now
61  
62 =item * tzoffsetfrom - the UTC offset this timezone was in before it changed
63  
64 =item * rdate - a recurrence date to describe when this timezone will switch times again
65  
66 =item * rrule - a recurrence rule to describe when this timezone shifts clocks again
67  
68 =item * tzname - a human-readable name for this timezone.
69  
70 =back
71  
72 See RFC2445 4.6.5 for more details on how this all works.
73  
74 =begin testing
75 TODO: {
76 local $TODO = "write tests for N::I::Standard";
77 ok(0, "write tests here, please");
78  
79 };
80 =end testing
81 =cut
82 #============================================================================
83 sub new {
84 my ($class, %args) = @_;
85  
86 my $self = &_create ($class, %args);
87  
88 return undef unless (defined $self);
89  
90 return undef unless ($self->validate);
91  
92 return $self;
93 }
94  
95 #=================================================================================
96 =head2 new_from_ical ($text)
97  
98 Takes iCalendar text as a parameter; returns a Net::ICal::Standard object.
99  
100 =cut
101  
102 # THIS IS INHERITED FROM Net::ICal::Component
103  
104 #==================================================================================
105 # make sure that this object has the bare minimum requirements specified by the RFC
106  
107 =head1 INTERNAL METHODS ONLY
108  
109 Use these outside this module at your own peril.
110  
111 =head2 validate($self)
112  
113 This routine validates the creation arguments we were given
114 to make sure that we have all the necessary elements to create
115 a valid VSTANDARD.
116 =cut
117 sub validate {
118 my ($self) = @_;
119
120 # TODO: fill in validation here
121
122 return $self->SUPER::validate ($self);
123 }
124  
125 =head2 create($class, %args)
126  
127 This is an internal function that sets up the object.
128 It mainly establishes a Class::MethodMapper data map
129 and hands off creation of the object to Net::ICal::Component.
130  
131 =cut
132 sub _create {
133 my ($class, %args) = @_;
134  
135 my $map = { # RFC2445 4.6.5 describes VTIMEZONE
136 dtstart => { # RFC2445 4.6.5? - optional in VTIMEZONE,
137 type => 'parameter',
138 doc => '',
139 domain => 'ref',
140 # TODO, BUG 424114: needs to be in UTC. how to enforce?
141 options => 'Net::ICal::Time',
142 value => undef,
143 },
144 tzoffsetto => { # RFC2445 4.8.3.4 - optional in VTIMEZONE
145 type => 'parameter',
146 doc => 'UTC offset in use now in this timezone',
147 domain => 'param',
148 options => [],
149 value => undef,
150 },
151 tzoffsetfrom => { # RFC2445 4.8.3.3 - optional in VTIMEZONE
152 type => 'parameter',
153 doc => 'UTC offset in use prior to the current offset in this tz',
154 domain => 'param',
155 options => [],
156 value => undef,
157 },
158 rdate => { # RFC2445 ? - optional multiple times in VTIMEZONE
159 # TODO: this should point to another N::I data type
160 type => 'parameter',
161 doc => 'recurrence date',
162 domain => 'ref',
163 options => 'ARRAY',
164 value => undef,
165 },
166 rrule => { # RFC2445 ? - optional multiple times in VTIMEZONE
167 # TODO: this should point to another N::I data type
168 type => 'parameter',
169 doc => 'a recurrence rule',
170 domain => 'ref',
171 options => 'ARRAY',
172 value => undef,
173 },
174 tzname => { # RFC2445 4.8.3.2 - optional multiple times in VTIMEZONE
175 type => 'parameter',
176 doc => 'a name for this timezone',
177 domain => 'param',
178 options => [],
179 value => undef,
180 },
181 # FIXME: handle x-properties.
182 };
183  
184 my $self = $class->SUPER::new ('STANDARD', $map, %args);
185  
186 return $self;
187 }
188  
189 1;
190  
191 =head1 SEE ALSO
192  
193 More documentation pointers can be found in L<Net::ICal::Timezone>.
194  
195 =cut