icalendar 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +61 -0
  3. data/PostInstall.txt +5 -0
  4. data/{README → README.rdoc} +4 -0
  5. data/Rakefile +28 -133
  6. data/config/website.yml +2 -0
  7. data/icalendar.gemspec +55 -0
  8. data/lib/icalendar/base.rb +2 -0
  9. data/lib/icalendar/component.rb +9 -7
  10. data/script/console +10 -0
  11. data/script/destroy +14 -0
  12. data/script/generate +14 -0
  13. data/script/recur1.ics +38 -0
  14. data/script/tryit.rb +13 -0
  15. data/script/txt2html +71 -0
  16. data/test.ical +33 -0
  17. data/test.ics +33 -0
  18. data/test.rb +48 -0
  19. data/test/component/{event_test.rb → test_event.rb} +0 -0
  20. data/test/component/{timezone_test.rb → test_timezone.rb} +1 -1
  21. data/test/component/{todo_test.rb → test_todo.rb} +0 -0
  22. data/test/fixtures/folding.ics +7 -7
  23. data/test/{calendar_test.rb → test_calendar.rb} +1 -4
  24. data/test/{component_test.rb → test_component.rb} +0 -0
  25. data/test/{conversions_test.rb → test_conversions.rb} +8 -8
  26. data/test/test_helper.rb +3 -0
  27. data/test/{parameter_test.rb → test_parameter.rb} +4 -0
  28. data/test/{parser_test.rb → test_parser.rb} +0 -0
  29. data/test2.rb +28 -0
  30. data/website/index.html +11 -0
  31. data/website/index.txt +79 -0
  32. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  33. data/website/stylesheets/screen.css +159 -0
  34. data/website/template.html.erb +50 -0
  35. metadata +135 -135
  36. data/docs/api/classes/Array.html +0 -155
  37. data/docs/api/classes/Bignum.html +0 -148
  38. data/docs/api/classes/Date.html +0 -172
  39. data/docs/api/classes/DateTime.html +0 -200
  40. data/docs/api/classes/Fixnum.html +0 -148
  41. data/docs/api/classes/Float.html +0 -148
  42. data/docs/api/classes/HashAttrs.html +0 -212
  43. data/docs/api/classes/Icalendar/Alarm.html +0 -228
  44. data/docs/api/classes/Icalendar/Base.html +0 -179
  45. data/docs/api/classes/Icalendar/Calendar.html +0 -504
  46. data/docs/api/classes/Icalendar/Component.html +0 -853
  47. data/docs/api/classes/Icalendar/DateProp.html +0 -187
  48. data/docs/api/classes/Icalendar/DateProp/ClassMethods.html +0 -195
  49. data/docs/api/classes/Icalendar/Daylight.html +0 -156
  50. data/docs/api/classes/Icalendar/Event.html +0 -671
  51. data/docs/api/classes/Icalendar/Freebusy.html +0 -266
  52. data/docs/api/classes/Icalendar/Geo.html +0 -211
  53. data/docs/api/classes/Icalendar/InvalidPropertyValue.html +0 -117
  54. data/docs/api/classes/Icalendar/Journal.html +0 -443
  55. data/docs/api/classes/Icalendar/Parameter.html +0 -166
  56. data/docs/api/classes/Icalendar/Parser.html +0 -352
  57. data/docs/api/classes/Icalendar/RRule.html +0 -428
  58. data/docs/api/classes/Icalendar/RRule/Weekday.html +0 -199
  59. data/docs/api/classes/Icalendar/Standard.html +0 -156
  60. data/docs/api/classes/Icalendar/Timezone.html +0 -450
  61. data/docs/api/classes/Icalendar/Todo.html +0 -480
  62. data/docs/api/classes/Icalendar/TzidSupport.html +0 -118
  63. data/docs/api/classes/Icalendar/UnknownComponentClass.html +0 -117
  64. data/docs/api/classes/Icalendar/UnknownPropertyMethod.html +0 -117
  65. data/docs/api/classes/Object.html +0 -272
  66. data/docs/api/classes/String.html +0 -148
  67. data/docs/api/classes/TZInfo.html +0 -119
  68. data/docs/api/classes/TZInfo/Timezone.html +0 -153
  69. data/docs/api/classes/TZInfo/TimezonePeriod.html +0 -200
  70. data/docs/api/classes/TZInfo/TimezoneTransitionInfo.html +0 -229
  71. data/docs/api/classes/Time.html +0 -180
  72. data/docs/api/classes/URI.html +0 -111
  73. data/docs/api/classes/URI/Generic.html +0 -148
  74. data/docs/api/created.rid +0 -1
  75. data/docs/api/files/COPYING.html +0 -163
  76. data/docs/api/files/GPL.html +0 -531
  77. data/docs/api/files/README.html +0 -401
  78. data/docs/api/files/lib/hash_attrs_rb.html +0 -107
  79. data/docs/api/files/lib/icalendar/base_rb.html +0 -108
  80. data/docs/api/files/lib/icalendar/calendar_rb.html +0 -101
  81. data/docs/api/files/lib/icalendar/component/alarm_rb.html +0 -101
  82. data/docs/api/files/lib/icalendar/component/event_rb.html +0 -101
  83. data/docs/api/files/lib/icalendar/component/freebusy_rb.html +0 -101
  84. data/docs/api/files/lib/icalendar/component/journal_rb.html +0 -101
  85. data/docs/api/files/lib/icalendar/component/timezone_rb.html +0 -101
  86. data/docs/api/files/lib/icalendar/component/todo_rb.html +0 -101
  87. data/docs/api/files/lib/icalendar/component_rb.html +0 -108
  88. data/docs/api/files/lib/icalendar/conversions_rb.html +0 -109
  89. data/docs/api/files/lib/icalendar/helpers_rb.html +0 -101
  90. data/docs/api/files/lib/icalendar/parameter_rb.html +0 -101
  91. data/docs/api/files/lib/icalendar/parser_rb.html +0 -110
  92. data/docs/api/files/lib/icalendar/rrule_rb.html +0 -110
  93. data/docs/api/files/lib/icalendar/tzinfo_rb.html +0 -101
  94. data/docs/api/files/lib/icalendar_rb.html +0 -121
  95. data/docs/api/files/lib/meta_rb.html +0 -107
  96. data/docs/api/fr_class_index.html +0 -64
  97. data/docs/api/fr_file_index.html +0 -47
  98. data/docs/api/fr_method_index.html +0 -123
  99. data/docs/api/index.html +0 -24
  100. data/docs/api/rdoc-style.css +0 -208
  101. data/docs/rfcs/itip_notes.txt +0 -69
  102. data/docs/rfcs/rfc2425.pdf +0 -0
  103. data/docs/rfcs/rfc2426.pdf +0 -0
  104. data/docs/rfcs/rfc2445.pdf +0 -0
  105. data/docs/rfcs/rfc2446.pdf +0 -0
  106. data/docs/rfcs/rfc2447.pdf +0 -0
  107. data/docs/rfcs/rfc3283.txt +0 -738
  108. data/test/coverage/STUB +0 -0
  109. data/test/coverage/index.html +0 -272
  110. data/test/coverage/lib-hash_attrs_rb.html +0 -235
  111. data/test/coverage/lib-icalendar-base_rb.html +0 -249
  112. data/test/coverage/lib-icalendar-calendar_rb.html +0 -324
  113. data/test/coverage/lib-icalendar-component-alarm_rb.html +0 -250
  114. data/test/coverage/lib-icalendar-component-event_rb.html +0 -353
  115. data/test/coverage/lib-icalendar-component-freebusy_rb.html +0 -245
  116. data/test/coverage/lib-icalendar-component-journal_rb.html +0 -278
  117. data/test/coverage/lib-icalendar-component-timezone_rb.html +0 -326
  118. data/test/coverage/lib-icalendar-component-todo_rb.html +0 -277
  119. data/test/coverage/lib-icalendar-component_rb.html +0 -733
  120. data/test/coverage/lib-icalendar-conversions_rb.html +0 -358
  121. data/test/coverage/lib-icalendar-parser_rb.html +0 -671
  122. data/test/coverage/lib-icalendar-rrule_rb.html +0 -357
  123. data/test/coverage/lib-icalendar_rb.html +0 -243
  124. data/test/coverage/lib-meta_rb.html +0 -234
@@ -1,733 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
- <head>
4
- <title>
5
- lib/icalendar/component.rb - C0 code coverage information
6
- </title>
7
- <style type='text/css'>
8
- body { background-color: rgb(240, 240, 245); }
9
- </style>
10
- <style type='text/css'>
11
- span.cross-ref-title { font-size: 140%; } span.cross-ref a {
12
- text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
13
- border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
14
- a.crossref-toggle { text-decoration: none; } span.marked0 {
15
- background-color: rgb(185, 210, 200); display: block; } span.marked1 {
16
- background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
17
- background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
18
- background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
19
- background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
20
- background-color: rgb(235, 120, 120); display: block; } span.overview {
21
- border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
22
- black; } body { font-family: verdana, arial, helvetica; } div.footer {
23
- font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
24
- margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
25
- } div.separator { height: 10px; } /* Commented out for better readability,
26
- esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
27
- table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
28
- border: #808080 1px solid; empty-cells: show; } table.percent_graph
29
- td.covered { height: 10px; background: #00f000; } table.percent_graph
30
- td.uncovered { height: 10px; background: #e00000; } table.percent_graph
31
- td.NA { height: 10px; background: #eaeaea; } table.report {
32
- border-collapse: collapse; width: 100%; } table.report td.heading {
33
- background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
34
- text-align: center; } table.report td.heading:hover { background: #c0ffc0;
35
- } table.report td.text { border: #d0d0d0 1px solid; } table.report
36
- td.value, table.report td.lines_total, table.report td.lines_code {
37
- text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
38
- background-color: rgb(240, 240, 245); } table.report tr.dark {
39
- background-color: rgb(230, 230, 235); }
40
- </style>
41
- <script type='text/javascript'>
42
- // <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
43
- elem = document.getElementById( id ); else if ( document.all ) elem =
44
- eval( "document.all." + id ); else return false; elemStyle = elem.style;
45
- if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
46
- elemStyle.display = "none" } return true; } // Make cross-references
47
- hidden by default document.writeln( "<style
48
- type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
49
- </script>
50
- <style type='text/css'>
51
- span.run0 { background-color: rgb(178, 204, 255); display: block; }
52
- span.run1 { background-color: rgb(178, 206, 255); display: block; }
53
- span.run2 { background-color: rgb(178, 209, 255); display: block; }
54
- span.run3 { background-color: rgb(178, 211, 255); display: block; }
55
- span.run4 { background-color: rgb(178, 214, 255); display: block; }
56
- span.run5 { background-color: rgb(178, 218, 255); display: block; }
57
- span.run6 { background-color: rgb(178, 220, 255); display: block; }
58
- span.run7 { background-color: rgb(178, 223, 255); display: block; }
59
- span.run8 { background-color: rgb(178, 225, 255); display: block; }
60
- span.run9 { background-color: rgb(178, 228, 255); display: block; }
61
- span.run10 { background-color: rgb(178, 232, 255); display: block; }
62
- span.run11 { background-color: rgb(178, 234, 255); display: block; }
63
- span.run12 { background-color: rgb(178, 237, 255); display: block; }
64
- span.run13 { background-color: rgb(178, 239, 255); display: block; }
65
- span.run14 { background-color: rgb(178, 242, 255); display: block; }
66
- span.run15 { background-color: rgb(178, 246, 255); display: block; }
67
- span.run16 { background-color: rgb(178, 248, 255); display: block; }
68
- span.run17 { background-color: rgb(178, 251, 255); display: block; }
69
- span.run18 { background-color: rgb(178, 253, 255); display: block; }
70
- span.run19 { background-color: rgb(178, 255, 253); display: block; }
71
- span.run20 { background-color: rgb(178, 255, 249); display: block; }
72
- span.run21 { background-color: rgb(178, 255, 247); display: block; }
73
- span.run22 { background-color: rgb(178, 255, 244); display: block; }
74
- span.run23 { background-color: rgb(178, 255, 242); display: block; }
75
- span.run24 { background-color: rgb(178, 255, 239); display: block; }
76
- span.run25 { background-color: rgb(178, 255, 235); display: block; }
77
- span.run26 { background-color: rgb(178, 255, 233); display: block; }
78
- span.run27 { background-color: rgb(178, 255, 230); display: block; }
79
- span.run28 { background-color: rgb(178, 255, 228); display: block; }
80
- span.run29 { background-color: rgb(178, 255, 225); display: block; }
81
- span.run30 { background-color: rgb(178, 255, 221); display: block; }
82
- span.run31 { background-color: rgb(178, 255, 219); display: block; }
83
- span.run32 { background-color: rgb(178, 255, 216); display: block; }
84
- span.run33 { background-color: rgb(178, 255, 214); display: block; }
85
- span.run34 { background-color: rgb(178, 255, 211); display: block; }
86
- span.run35 { background-color: rgb(178, 255, 207); display: block; }
87
- span.run36 { background-color: rgb(178, 255, 205); display: block; }
88
- span.run37 { background-color: rgb(178, 255, 202); display: block; }
89
- span.run38 { background-color: rgb(178, 255, 200); display: block; }
90
- span.run39 { background-color: rgb(178, 255, 197); display: block; }
91
- span.run40 { background-color: rgb(178, 255, 193); display: block; }
92
- span.run41 { background-color: rgb(178, 255, 191); display: block; }
93
- span.run42 { background-color: rgb(178, 255, 188); display: block; }
94
- span.run43 { background-color: rgb(178, 255, 186); display: block; }
95
- span.run44 { background-color: rgb(178, 255, 183); display: block; }
96
- span.run45 { background-color: rgb(178, 255, 179); display: block; }
97
- span.run46 { background-color: rgb(179, 255, 178); display: block; }
98
- span.run47 { background-color: rgb(182, 255, 178); display: block; }
99
- span.run48 { background-color: rgb(184, 255, 178); display: block; }
100
- span.run49 { background-color: rgb(187, 255, 178); display: block; }
101
- span.run50 { background-color: rgb(191, 255, 178); display: block; }
102
- span.run51 { background-color: rgb(193, 255, 178); display: block; }
103
- span.run52 { background-color: rgb(196, 255, 178); display: block; }
104
- span.run53 { background-color: rgb(198, 255, 178); display: block; }
105
- span.run54 { background-color: rgb(201, 255, 178); display: block; }
106
- span.run55 { background-color: rgb(205, 255, 178); display: block; }
107
- span.run56 { background-color: rgb(207, 255, 178); display: block; }
108
- span.run57 { background-color: rgb(210, 255, 178); display: block; }
109
- span.run58 { background-color: rgb(212, 255, 178); display: block; }
110
- span.run59 { background-color: rgb(215, 255, 178); display: block; }
111
- span.run60 { background-color: rgb(219, 255, 178); display: block; }
112
- span.run61 { background-color: rgb(221, 255, 178); display: block; }
113
- span.run62 { background-color: rgb(224, 255, 178); display: block; }
114
- span.run63 { background-color: rgb(226, 255, 178); display: block; }
115
- span.run64 { background-color: rgb(229, 255, 178); display: block; }
116
- span.run65 { background-color: rgb(233, 255, 178); display: block; }
117
- span.run66 { background-color: rgb(235, 255, 178); display: block; }
118
- span.run67 { background-color: rgb(238, 255, 178); display: block; }
119
- span.run68 { background-color: rgb(240, 255, 178); display: block; }
120
- span.run69 { background-color: rgb(243, 255, 178); display: block; }
121
- span.run70 { background-color: rgb(247, 255, 178); display: block; }
122
- span.run71 { background-color: rgb(249, 255, 178); display: block; }
123
- span.run72 { background-color: rgb(252, 255, 178); display: block; }
124
- span.run73 { background-color: rgb(255, 255, 178); display: block; }
125
- span.run74 { background-color: rgb(255, 252, 178); display: block; }
126
- span.run75 { background-color: rgb(255, 248, 178); display: block; }
127
- span.run76 { background-color: rgb(255, 246, 178); display: block; }
128
- span.run77 { background-color: rgb(255, 243, 178); display: block; }
129
- span.run78 { background-color: rgb(255, 240, 178); display: block; }
130
- span.run79 { background-color: rgb(255, 238, 178); display: block; }
131
- span.run80 { background-color: rgb(255, 234, 178); display: block; }
132
- span.run81 { background-color: rgb(255, 232, 178); display: block; }
133
- span.run82 { background-color: rgb(255, 229, 178); display: block; }
134
- span.run83 { background-color: rgb(255, 226, 178); display: block; }
135
- span.run84 { background-color: rgb(255, 224, 178); display: block; }
136
- span.run85 { background-color: rgb(255, 220, 178); display: block; }
137
- span.run86 { background-color: rgb(255, 218, 178); display: block; }
138
- span.run87 { background-color: rgb(255, 215, 178); display: block; }
139
- span.run88 { background-color: rgb(255, 212, 178); display: block; }
140
- span.run89 { background-color: rgb(255, 210, 178); display: block; }
141
- span.run90 { background-color: rgb(255, 206, 178); display: block; }
142
- span.run91 { background-color: rgb(255, 204, 178); display: block; }
143
- span.run92 { background-color: rgb(255, 201, 178); display: block; }
144
- span.run93 { background-color: rgb(255, 198, 178); display: block; }
145
- span.run94 { background-color: rgb(255, 196, 178); display: block; }
146
- span.run95 { background-color: rgb(255, 192, 178); display: block; }
147
- span.run96 { background-color: rgb(255, 189, 178); display: block; }
148
- span.run97 { background-color: rgb(255, 187, 178); display: block; }
149
- span.run98 { background-color: rgb(255, 184, 178); display: block; }
150
- span.run99 { background-color: rgb(255, 182, 178); display: block; }
151
- span.run100 { background-color: rgb(255, 178, 178); display: block; }
152
- </style>
153
- </head>
154
- <body>
155
- <h3>
156
- C0 code coverage information
157
- </h3>
158
- <p>
159
- Generated on Sun Mar 29 23:07:04 -0400 2009 with
160
- <a href='http://eigenclass.org/hiki/rcov'>
161
- rcov 0.8.1.2
162
- </a>
163
- </p>
164
- <hr />
165
- <pre><span class='marked0'>Code reported as executed by Ruby looks like
166
- this... </span><span class='marked1'>and this: this line is also marked as
167
- covered. </span><span class='inferred0'>Lines considered as run by rcov, but
168
- not reported by Ruby, look like this, </span><span class='inferred1'>and
169
- this: these lines were inferred by rcov (using simple heuristics).
170
- </span><span class='uncovered0'>Finally, here&apos;s a line marked as not
171
- executed. </span></pre>
172
- <table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
173
- class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
174
- <td class='heading'> Total coverage </td> <td class='heading'> Code coverage
175
- </td> </tr> </thead> <tbody> <tr class='light'> <td> <a
176
- href='lib-icalendar-component_rb.html'> lib/icalendar/component.rb </a>
177
- </td> <td class='lines_total'> <tt> 442 </tt> </td> <td class='lines_code'>
178
- <tt> 298 </tt> </td> <td> <table cellspacing='0' align='right'
179
- cellpadding='0'> <tr> <td> <tt class='coverage_total'> 97.5% </tt> &nbsp;
180
- </td> <td> <table class='percent_graph' cellspacing='0' width='100'
181
- cellpadding='0'> <tr> <td class='covered' width='98' /> <td
182
- class='uncovered' width='2' /> </tr> </table> </td> </tr> </table> </td>
183
- <td> <table cellspacing='0' align='right' cellpadding='0'> <tr> <td> <tt
184
- class='coverage_code'> 96.3% </tt> &nbsp; </td> <td> <table
185
- class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
186
- class='covered' width='96' /> <td class='uncovered' width='4' /> </tr>
187
- </table> </td> </tr> </table> </td> </tr> </tbody> </table><pre><span
188
- class="inferred0"><a name="line1"></a> 1 =begin </span><span
189
- class="inferred1"><a name="line2"></a> 2 Copyright (C) 2005 Jeff Rose
190
- </span><span class="inferred0"><a name="line3"></a> 3 </span><span
191
- class="inferred1"><a name="line4"></a> 4 This library is free software; you
192
- can redistribute it and/or modify it </span><span class="inferred0"><a
193
- name="line5"></a> 5 under the same terms as the ruby language itself, see
194
- the file COPYING for </span><span class="inferred1"><a name="line6"></a> 6
195
- details. </span><span class="inferred0"><a name="line7"></a> 7 =end
196
- </span><span class="inferred1"><a name="line8"></a> 8 </span><span
197
- class="marked0"><a name="line9"></a> 9 module Icalendar </span><span
198
- class="marked1"><a name="line10"></a> 10 require 'socket' </span><span
199
- class="inferred0"><a name="line11"></a> 11 </span><span class="marked1"><a
200
- name="line12"></a> 12 MAX_LINE_LENGTH = 75 </span><span class="inferred0"><a
201
- name="line13"></a> 13 </span><span class="marked1"><a name="line14"></a> 14
202
- class Geo &lt; Icalendar::Base </span><span class="marked0"><a
203
- name="line15"></a> 15 attr_accessor :latitude, :longitude </span><span
204
- class="marked1"><a name="line16"></a> 16 alias :lat :latitude </span><span
205
- class="marked0"><a name="line17"></a> 17 alias :long :longitude </span><span
206
- class="inferred1"><a name="line18"></a> 18 </span><span class="marked0"><a
207
- name="line19"></a> 19 def initialize(lat, long) </span><span
208
- class="marked1"><a name="line20"></a> 20 @lat = lat </span><span
209
- class="marked0"><a name="line21"></a> 21 @long = long </span><span
210
- class="inferred1"><a name="line22"></a> 22 end </span><span
211
- class="inferred0"><a name="line23"></a> 23 </span><span class="marked1"><a
212
- name="line24"></a> 24 def to_ical </span><span class="marked0"><a
213
- name="line25"></a> 25 &quot;#{@lat.to_ical};#{@long.to_ical}&quot;
214
- </span><span class="inferred1"><a name="line26"></a> 26 end </span><span
215
- class="inferred0"><a name="line27"></a> 27 end </span><span
216
- class="inferred1"><a name="line28"></a> 28 </span><span class="inferred0"><a
217
- name="line29"></a> 29 # The body of the iCalendar object consists of a
218
- sequence of calendar </span><span class="inferred1"><a name="line30"></a> 30
219
- # properties and one or more calendar components. The calendar </span><span
220
- class="inferred0"><a name="line31"></a> 31 # properties are attributes that
221
- apply to the calendar as a whole. The </span><span class="inferred1"><a
222
- name="line32"></a> 32 # calendar components are collections of properties
223
- that express a </span><span class="inferred0"><a name="line33"></a> 33 #
224
- particular calendar semantic. For example, the calendar component can
225
- </span><span class="inferred1"><a name="line34"></a> 34 # specify an Event,
226
- a Todo, a Journal entry, Timezone information, or </span><span
227
- class="inferred0"><a name="line35"></a> 35 # Freebusy time information, or
228
- an Alarm. </span><span class="marked1"><a name="line36"></a> 36 class
229
- Component &lt; Icalendar::Base </span><span class="inferred0"><a
230
- name="line37"></a> 37 </span><span class="marked1"><a name="line38"></a> 38
231
- meta_include HashAttrs </span><span class="inferred0"><a name="line39"></a>
232
- 39 </span><span class="marked1"><a name="line40"></a> 40 attr_reader :name
233
- </span><span class="marked0"><a name="line41"></a> 41 attr_accessor
234
- :properties </span><span class="inferred1"><a name="line42"></a> 42
235
- </span><span class="marked0"><a name="line43"></a> 43 @@multi_properties =
236
- {} </span><span class="marked1"><a name="line44"></a> 44
237
- @@multiline_properties = {} </span><span class="inferred0"><a
238
- name="line45"></a> 45 </span><span class="marked1"><a name="line46"></a> 46
239
- def initialize(name) </span><span class="marked0"><a name="line47"></a> 47
240
- @name = name </span><span class="marked1"><a name="line48"></a> 48
241
- @components = Hash.new([]) </span><span class="marked0"><a
242
- name="line49"></a> 49 @properties = {} </span><span class="inferred1"><a
243
- name="line50"></a> 50 </span><span class="marked0"><a name="line51"></a> 51
244
- @@logger.info(&quot;New #{@name[1,@name.size].capitalize}...&quot;)
245
- </span><span class="inferred1"><a name="line52"></a> 52 end </span><span
246
- class="inferred0"><a name="line53"></a> 53 </span><span class="inferred1"><a
247
- name="line54"></a> 54 # Add a sub-component to the current component object.
248
- </span><span class="marked0"><a name="line55"></a> 55 def
249
- add_component(component) </span><span class="marked1"><a name="line56"></a>
250
- 56 key = (component.class.to_s.downcase + 's').gsub('icalendar::',
251
- '').to_sym </span><span class="inferred0"><a name="line57"></a> 57
252
- </span><span class="marked1"><a name="line58"></a> 58 unless
253
- @components.has_key? key </span><span class="marked0"><a name="line59"></a>
254
- 59 @components[key] = [] </span><span class="inferred1"><a
255
- name="line60"></a> 60 end </span><span class="inferred0"><a
256
- name="line61"></a> 61 </span><span class="marked1"><a name="line62"></a> 62
257
- @components[key] &lt;&lt; component </span><span class="inferred0"><a
258
- name="line63"></a> 63 end </span><span class="inferred1"><a
259
- name="line64"></a> 64 </span><span class="inferred0"><a name="line65"></a>
260
- 65 # Add a component to the calendar. </span><span class="marked1"><a
261
- name="line66"></a> 66 alias add add_component </span><span
262
- class="inferred0"><a name="line67"></a> 67 </span><span class="inferred1"><a
263
- name="line68"></a> 68 # Add an event to the calendar. </span><span
264
- class="marked0"><a name="line69"></a> 69 alias add_event add_component
265
- </span><span class="inferred1"><a name="line70"></a> 70 </span><span
266
- class="inferred0"><a name="line71"></a> 71 # Add a todo item to the
267
- calendar. </span><span class="marked1"><a name="line72"></a> 72 alias
268
- add_todo add_component </span><span class="inferred0"><a name="line73"></a>
269
- 73 </span><span class="inferred1"><a name="line74"></a> 74 # Add a journal
270
- item to the calendar. </span><span class="marked0"><a name="line75"></a> 75
271
- alias add_journal add_component </span><span class="inferred1"><a
272
- name="line76"></a> 76 </span><span class="marked0"><a name="line77"></a> 77
273
- def remove_component(component) </span><span class="marked1"><a
274
- name="line78"></a> 78 key = (component.class.to_s.downcase +
275
- 's').gsub('icalendar::', '').to_sym </span><span class="inferred0"><a
276
- name="line79"></a> 79 </span><span class="marked1"><a name="line80"></a> 80
277
- if @components.has_key? key </span><span class="marked0"><a
278
- name="line81"></a> 81 @components[key].delete(component) </span><span
279
- class="inferred1"><a name="line82"></a> 82 end </span><span
280
- class="inferred0"><a name="line83"></a> 83 end </span><span
281
- class="inferred1"><a name="line84"></a> 84 </span><span class="inferred0"><a
282
- name="line85"></a> 85 # Remove a component from the calendar. </span><span
283
- class="marked1"><a name="line86"></a> 86 alias remove remove_component
284
- </span><span class="inferred0"><a name="line87"></a> 87 </span><span
285
- class="inferred1"><a name="line88"></a> 88 # Remove an event from the
286
- calendar. </span><span class="marked0"><a name="line89"></a> 89 alias
287
- remove_event remove_component </span><span class="inferred1"><a
288
- name="line90"></a> 90 </span><span class="inferred0"><a name="line91"></a>
289
- 91 # Remove a todo item from the calendar. </span><span class="marked1"><a
290
- name="line92"></a> 92 alias remove_todo remove_component </span><span
291
- class="inferred0"><a name="line93"></a> 93 </span><span class="inferred1"><a
292
- name="line94"></a> 94 # Remove a journal item from the calendar.
293
- </span><span class="marked0"><a name="line95"></a> 95 alias remove_journal
294
- remove_component </span><span class="inferred1"><a name="line96"></a> 96
295
- </span><span class="inferred0"><a name="line97"></a> 97 # Used to generate
296
- unique component ids </span><span class="marked1"><a name="line98"></a> 98
297
- def new_uid </span><span class="marked0"><a name="line99"></a> 99
298
- &quot;#{DateTime.now}_#{rand(999999999)}@#{Socket.gethostname}&quot;
299
- </span><span class="inferred1"><a name="line100"></a>100 end </span><span
300
- class="inferred0"><a name="line101"></a>101 </span><span
301
- class="inferred1"><a name="line102"></a>102 # Output in the icalendar format
302
- </span><span class="marked0"><a name="line103"></a>103 def to_ical
303
- </span><span class="marked1"><a name="line104"></a>104 print_component do
304
- </span><span class="marked0"><a name="line105"></a>105 s = &quot;&quot;
305
- </span><span class="marked1"><a name="line106"></a>106
306
- @components.each_value do |comps| </span><span class="marked0"><a
307
- name="line107"></a>107 comps.each { |component| s &lt;&lt; component.to_ical
308
- } </span><span class="inferred1"><a name="line108"></a>108 end </span><span
309
- class="marked0"><a name="line109"></a>109 s </span><span
310
- class="inferred1"><a name="line110"></a>110 end </span><span
311
- class="inferred0"><a name="line111"></a>111 end </span><span
312
- class="inferred1"><a name="line112"></a>112 </span><span
313
- class="inferred0"><a name="line113"></a>113 # Print this icalendar component
314
- </span><span class="marked1"><a name="line114"></a>114 def print_component
315
- </span><span class="inferred0"><a name="line115"></a>115 # Begin a new
316
- component </span><span class="inferred1"><a name="line116"></a>116
317
- &quot;BEGIN:#{@name.upcase}\r\n&quot; + </span><span class="inferred0"><a
318
- name="line117"></a>117 </span><span class="inferred1"><a
319
- name="line118"></a>118 # Then the properties </span><span class="marked0"><a
320
- name="line119"></a>119 print_properties + </span><span class="inferred1"><a
321
- name="line120"></a>120 </span><span class="inferred0"><a
322
- name="line121"></a>121 # sub components </span><span class="inferred1"><a
323
- name="line122"></a>122 yield + </span><span class="inferred0"><a
324
- name="line123"></a>123 </span><span class="inferred1"><a
325
- name="line124"></a>124 # End of this component </span><span
326
- class="marked0"><a name="line125"></a>125
327
- &quot;END:#{@name.upcase}\r\n&quot; </span><span class="inferred1"><a
328
- name="line126"></a>126 end </span><span class="inferred0"><a
329
- name="line127"></a>127 </span><span class="inferred1"><a
330
- name="line128"></a>128 # Print this components properties </span><span
331
- class="marked0"><a name="line129"></a>129 def print_properties </span><span
332
- class="marked1"><a name="line130"></a>130 s = &quot;&quot; </span><span
333
- class="inferred0"><a name="line131"></a>131 </span><span class="marked1"><a
334
- name="line132"></a>132 @properties.each do |key,val| </span><span
335
- class="inferred0"><a name="line133"></a>133 # Take out underscore for
336
- property names that conflicted </span><span class="inferred1"><a
337
- name="line134"></a>134 # with built-in words. </span><span
338
- class="marked0"><a name="line135"></a>135 if key =~ /ip_.*/ </span><span
339
- class="marked1"><a name="line136"></a>136 key = key[3..-1] </span><span
340
- class="inferred0"><a name="line137"></a>137 end </span><span
341
- class="inferred1"><a name="line138"></a>138 </span><span
342
- class="inferred0"><a name="line139"></a>139 # Property name </span><span
343
- class="marked1"><a name="line140"></a>140 unless multiline_property?(key)
344
- </span><span class="marked0"><a name="line141"></a>141 prelude =
345
- &quot;#{key.gsub(/_/, '-').upcase}&quot; + </span><span class="inferred1"><a
346
- name="line142"></a>142 </span><span class="inferred0"><a
347
- name="line143"></a>143 # Possible parameters </span><span class="marked1"><a
348
- name="line144"></a>144 print_parameters(val) </span><span
349
- class="inferred0"><a name="line145"></a>145 </span><span
350
- class="inferred1"><a name="line146"></a>146 # Property value </span><span
351
- class="marked0"><a name="line147"></a>147 value =
352
- &quot;:#{val.to_ical}&quot; </span><span class="marked1"><a
353
- name="line148"></a>148 add_sliced_text(s,prelude+escape_chars(value))
354
- </span><span class="uncovered0"><a name="line149"></a>149 else </span><span
355
- class="uncovered1"><a name="line150"></a>150 prelude = &quot;#{key.gsub(/_/,
356
- '-').upcase}&quot; </span><span class="uncovered0"><a name="line151"></a>151
357
- val.each do |v| </span><span class="uncovered1"><a name="line152"></a>152
358
- params = print_parameters(v) </span><span class="uncovered0"><a
359
- name="line153"></a>153 value = &quot;:#{v.to_ical}&quot; </span><span
360
- class="uncovered1"><a name="line154"></a>154 add_sliced_text(s,prelude +
361
- params + escape_chars(value)) </span><span class="uncovered0"><a
362
- name="line155"></a>155 end </span><span class="uncovered1"><a
363
- name="line156"></a>156 end </span><span class="uncovered0"><a
364
- name="line157"></a>157 end </span><span class="marked1"><a
365
- name="line158"></a>158 s </span><span class="inferred0"><a
366
- name="line159"></a>159 end </span><span class="inferred1"><a
367
- name="line160"></a>160 </span><span class="marked0"><a
368
- name="line161"></a>161 def escape_chars(value) </span><span
369
- class="marked1"><a name="line162"></a>162 value.gsub(&quot;\\&quot;,
370
- &quot;\\\\&quot;).gsub(&quot;\n&quot;, &quot;\\n&quot;).gsub(&quot;,&quot;,
371
- &quot;\\,&quot;).gsub(&quot;;&quot;, &quot;\\;&quot;) </span><span
372
- class="inferred0"><a name="line163"></a>163 end </span><span
373
- class="inferred1"><a name="line164"></a>164 </span><span class="marked0"><a
374
- name="line165"></a>165 def add_sliced_text(add_to,escaped) </span><span
375
- class="marked1"><a name="line166"></a>166 escaped = escaped.split('') #
376
- split is unicdoe-aware when `$KCODE = 'u'` </span><span class="marked0"><a
377
- name="line167"></a>167 add_to &lt;&lt;
378
- escaped.slice!(0,MAX_LINE_LENGTH).to_s &lt;&lt; &quot;\r\n &quot; while
379
- escaped.length != 0 # shift(MAX_LINE_LENGTH) does not work with ruby 1.8.6
380
- </span><span class="marked1"><a name="line168"></a>168 add_to.gsub!(/ *$/,
381
- '') </span><span class="inferred0"><a name="line169"></a>169 end
382
- </span><span class="inferred1"><a name="line170"></a>170 </span><span
383
- class="inferred0"><a name="line171"></a>171 # Print the parameters for a
384
- specific property </span><span class="marked1"><a name="line172"></a>172 def
385
- print_parameters(val) </span><span class="marked0"><a name="line173"></a>173
386
- s = &quot;&quot; </span><span class="marked1"><a name="line174"></a>174
387
- return s unless val.respond_to?(:ical_params) and not val.ical_params.nil?
388
- </span><span class="inferred0"><a name="line175"></a>175 </span><span
389
- class="marked1"><a name="line176"></a>176 val.ical_params.each do |key,val|
390
- </span><span class="marked0"><a name="line177"></a>177 s &lt;&lt;
391
- &quot;;#{key}&quot; </span><span class="marked1"><a name="line178"></a>178
392
- val = [ val ] unless val.is_a?(Array) </span><span class="inferred0"><a
393
- name="line179"></a>179 </span><span class="inferred1"><a
394
- name="line180"></a>180 # Possible parameter values </span><span
395
- class="marked0"><a name="line181"></a>181 unless val.empty? </span><span
396
- class="marked1"><a name="line182"></a>182 s &lt;&lt; &quot;=&quot;
397
- </span><span class="marked0"><a name="line183"></a>183 sep = &quot;&quot; #
398
- First entry comes after = sign, but then we need commas </span><span
399
- class="marked1"><a name="line184"></a>184 val.each do |pval| </span><span
400
- class="marked0"><a name="line185"></a>185 if pval.respond_to? :to_ical
401
- </span><span class="marked1"><a name="line186"></a>186 s &lt;&lt; sep
402
- &lt;&lt; pval.to_ical </span><span class="marked0"><a name="line187"></a>187
403
- sep = &quot;,&quot; </span><span class="inferred1"><a name="line188"></a>188
404
- end </span><span class="inferred0"><a name="line189"></a>189 end
405
- </span><span class="inferred1"><a name="line190"></a>190 end </span><span
406
- class="inferred0"><a name="line191"></a>191 end </span><span
407
- class="marked1"><a name="line192"></a>192 s </span><span
408
- class="inferred0"><a name="line193"></a>193 end </span><span
409
- class="inferred1"><a name="line194"></a>194 </span><span
410
- class="inferred0"><a name="line195"></a>195 # TODO: Look into the
411
- x-property, x-param stuff... </span><span class="inferred1"><a
412
- name="line196"></a>196 # This would really only be needed for subclassing to
413
- add additional </span><span class="inferred0"><a name="line197"></a>197 #
414
- properties to an application using the API. </span><span class="marked1"><a
415
- name="line198"></a>198 def custom_property(name, value) </span><span
416
- class="uncovered0"><a name="line199"></a>199 @properties[name] = value
417
- </span><span class="uncovered1"><a name="line200"></a>200 end </span><span
418
- class="inferred0"><a name="line201"></a>201 </span><span class="marked1"><a
419
- name="line202"></a>202 def multi_property?(name) </span><span
420
- class="marked0"><a name="line203"></a>203
421
- @@multi_properties.has_key?(name.downcase) </span><span class="inferred1"><a
422
- name="line204"></a>204 end </span><span class="inferred0"><a
423
- name="line205"></a>205 </span><span class="marked1"><a
424
- name="line206"></a>206 def multiline_property?(name) </span><span
425
- class="marked0"><a name="line207"></a>207
426
- @@multiline_properties.has_key?(name.downcase) </span><span
427
- class="inferred1"><a name="line208"></a>208 end </span><span
428
- class="inferred0"><a name="line209"></a>209 </span><span
429
- class="inferred1"><a name="line210"></a>210 # Make it protected so we can
430
- monitor usage... </span><span class="marked0"><a name="line211"></a>211
431
- protected </span><span class="inferred1"><a name="line212"></a>212
432
- </span><span class="marked0"><a name="line213"></a>213 def
433
- Component.ical_component(*syms) </span><span class="marked1"><a
434
- name="line214"></a>214 hash_accessor :@components, *syms </span><span
435
- class="inferred0"><a name="line215"></a>215 end </span><span
436
- class="inferred1"><a name="line216"></a>216 </span><span
437
- class="inferred0"><a name="line217"></a>217 # Define a set of methods
438
- supporting a new property </span><span class="marked1"><a
439
- name="line218"></a>218 def Component.ical_property(property, alias_name =
440
- nil, prop_name = nil) </span><span class="marked0"><a name="line219"></a>219
441
- property = &quot;#{property}&quot;.strip.downcase </span><span
442
- class="marked1"><a name="line220"></a>220 alias_name =
443
- &quot;#{alias_name}&quot;.strip.downcase unless alias_name.nil? </span><span
444
- class="inferred0"><a name="line221"></a>221 # If a prop_name was given then
445
- we use that for the actual storage </span><span class="marked1"><a
446
- name="line222"></a>222 property = &quot;#{prop_name}&quot;.strip.downcase
447
- unless prop_name.nil? </span><span class="inferred0"><a
448
- name="line223"></a>223 </span><span class="marked1"><a
449
- name="line224"></a>224 generate_getter(property, alias_name) </span><span
450
- class="marked0"><a name="line225"></a>225 generate_setter(property,
451
- alias_name) </span><span class="marked1"><a name="line226"></a>226
452
- generate_query(property, alias_name) </span><span class="inferred0"><a
453
- name="line227"></a>227 end </span><span class="inferred1"><a
454
- name="line228"></a>228 </span><span class="inferred0"><a
455
- name="line229"></a>229 # Define a set of methods defining a new property,
456
- which </span><span class="inferred1"><a name="line230"></a>230 # supports
457
- multiple values for the same property name. </span><span class="marked0"><a
458
- name="line231"></a>231 def Component.ical_multi_property(property, singular,
459
- plural) </span><span class="marked1"><a name="line232"></a>232 property =
460
- &quot;#{property}&quot;.strip.downcase.gsub(/-/, '_') </span><span
461
- class="marked0"><a name="line233"></a>233 plural =
462
- &quot;#{plural}&quot;.strip.downcase </span><span class="inferred1"><a
463
- name="line234"></a>234 </span><span class="inferred0"><a
464
- name="line235"></a>235 # Set this key so the parser knows to use an array
465
- for </span><span class="inferred1"><a name="line236"></a>236 # storing this
466
- property type. </span><span class="marked0"><a name="line237"></a>237
467
- @@multi_properties[&quot;#{property}&quot;] = true </span><span
468
- class="inferred1"><a name="line238"></a>238 </span><span class="marked0"><a
469
- name="line239"></a>239 generate_multi_getter(property, plural) </span><span
470
- class="marked1"><a name="line240"></a>240 generate_multi_setter(property,
471
- plural) </span><span class="marked0"><a name="line241"></a>241
472
- generate_multi_query(property, plural) </span><span class="marked1"><a
473
- name="line242"></a>242 generate_multi_adder(property, singular) </span><span
474
- class="marked0"><a name="line243"></a>243 generate_multi_remover(property,
475
- singular) </span><span class="inferred1"><a name="line244"></a>244 end
476
- </span><span class="inferred0"><a name="line245"></a>245 </span><span
477
- class="inferred1"><a name="line246"></a>246 # Define a set of methods
478
- defining a new property, which </span><span class="inferred0"><a
479
- name="line247"></a>247 # supports multiple values in multiple lines with
480
- same property name </span><span class="marked1"><a name="line248"></a>248
481
- def Component.ical_multiline_property(property, singular, plural)
482
- </span><span class="marked0"><a name="line249"></a>249
483
- @@multiline_properties[&quot;#{property}&quot;] = true </span><span
484
- class="marked1"><a name="line250"></a>250 ical_multi_property(property,
485
- singular, plural) </span><span class="inferred0"><a name="line251"></a>251
486
- end </span><span class="inferred1"><a name="line252"></a>252 </span><span
487
- class="inferred0"><a name="line253"></a>253 </span><span class="marked1"><a
488
- name="line254"></a>254 private </span><span class="inferred0"><a
489
- name="line255"></a>255 </span><span class="marked1"><a
490
- name="line256"></a>256 def Component.generate_getter(property, alias_name)
491
- </span><span class="marked0"><a name="line257"></a>257 unless
492
- instance_methods.include? property </span><span class="marked1"><a
493
- name="line258"></a>258 code = &lt;&lt;-code </span><span
494
- class="inferred0"><a name="line259"></a>259 def #{property}(val = nil,
495
- params = nil) </span><span class="inferred1"><a name="line260"></a>260
496
- return @properties[&quot;#{property}&quot;] if val.nil? </span><span
497
- class="inferred0"><a name="line261"></a>261 </span><span
498
- class="inferred1"><a name="line262"></a>262 unless val.respond_to?(:to_ical)
499
- </span><span class="inferred0"><a name="line263"></a>263
500
- raise(NotImplementedError, &quot;Value of type (&quot; + val.class.to_s +
501
- &quot;) does not support to_ical method!&quot;) </span><span
502
- class="inferred1"><a name="line264"></a>264 end </span><span
503
- class="inferred0"><a name="line265"></a>265 </span><span
504
- class="inferred1"><a name="line266"></a>266 unless params.nil? </span><span
505
- class="inferred0"><a name="line267"></a>267 # Extend with the parameter
506
- methods only if we have to... </span><span class="inferred1"><a
507
- name="line268"></a>268 unless val.respond_to?(:ical_params) </span><span
508
- class="inferred0"><a name="line269"></a>269 val.class.class_eval {
509
- attr_accessor :ical_params } </span><span class="inferred1"><a
510
- name="line270"></a>270 end </span><span class="inferred0"><a
511
- name="line271"></a>271 val.ical_params = params </span><span
512
- class="inferred1"><a name="line272"></a>272 end </span><span
513
- class="inferred0"><a name="line273"></a>273 </span><span
514
- class="inferred1"><a name="line274"></a>274
515
- @properties[&quot;#{property}&quot;] = val </span><span class="inferred0"><a
516
- name="line275"></a>275 end </span><span class="inferred1"><a
517
- name="line276"></a>276 code </span><span class="inferred0"><a
518
- name="line277"></a>277 </span><span class="marked1"><a
519
- name="line278"></a>278 class_eval code, &quot;component.rb&quot;, 219
520
- </span><span class="marked0"><a name="line279"></a>279
521
- alias_method(&quot;#{alias_name}&quot;, &quot;#{property}&quot;) unless
522
- alias_name.nil? </span><span class="inferred1"><a name="line280"></a>280 end
523
- </span><span class="inferred0"><a name="line281"></a>281 end </span><span
524
- class="inferred1"><a name="line282"></a>282 </span><span class="marked0"><a
525
- name="line283"></a>283 def Component.generate_setter(property, alias_name)
526
- </span><span class="marked1"><a name="line284"></a>284 setter = property +
527
- '=' </span><span class="marked0"><a name="line285"></a>285 unless
528
- instance_methods.include? setter </span><span class="marked1"><a
529
- name="line286"></a>286 code = &lt;&lt;-code </span><span
530
- class="inferred0"><a name="line287"></a>287 def #{setter}(val) </span><span
531
- class="inferred1"><a name="line288"></a>288 #{property}(val) </span><span
532
- class="inferred0"><a name="line289"></a>289 end </span><span
533
- class="inferred1"><a name="line290"></a>290 code </span><span
534
- class="inferred0"><a name="line291"></a>291 </span><span class="marked1"><a
535
- name="line292"></a>292 class_eval code, &quot;component.rb&quot;, 233
536
- </span><span class="marked0"><a name="line293"></a>293
537
- alias_method(&quot;#{alias_name}=&quot;, &quot;#{property+'='}&quot;) unless
538
- alias_name.nil? </span><span class="inferred1"><a name="line294"></a>294 end
539
- </span><span class="inferred0"><a name="line295"></a>295 end </span><span
540
- class="inferred1"><a name="line296"></a>296 </span><span class="marked0"><a
541
- name="line297"></a>297 def Component.generate_query(property, alias_name)
542
- </span><span class="marked1"><a name="line298"></a>298 query =
543
- &quot;#{property}?&quot; </span><span class="marked0"><a
544
- name="line299"></a>299 unless instance_methods.include? query </span><span
545
- class="marked1"><a name="line300"></a>300 code = &lt;&lt;-code </span><span
546
- class="inferred0"><a name="line301"></a>301 def #{query} </span><span
547
- class="inferred1"><a name="line302"></a>302
548
- @properties.has_key?(&quot;#{property.downcase}&quot;) </span><span
549
- class="inferred0"><a name="line303"></a>303 end </span><span
550
- class="inferred1"><a name="line304"></a>304 code </span><span
551
- class="inferred0"><a name="line305"></a>305 </span><span class="marked1"><a
552
- name="line306"></a>306 class_eval code, &quot;component.rb&quot;, 226
553
- </span><span class="inferred0"><a name="line307"></a>307 </span><span
554
- class="marked1"><a name="line308"></a>308
555
- alias_method(&quot;#{alias_name}\?&quot;, &quot;#{query}&quot;) unless
556
- alias_name.nil? </span><span class="inferred0"><a name="line309"></a>309 end
557
- </span><span class="inferred1"><a name="line310"></a>310 end </span><span
558
- class="inferred0"><a name="line311"></a>311 </span><span class="marked1"><a
559
- name="line312"></a>312 def Component.generate_multi_getter(property, plural)
560
- </span><span class="inferred0"><a name="line313"></a>313 # Getter for whole
561
- array </span><span class="marked1"><a name="line314"></a>314 unless
562
- instance_methods.include? plural </span><span class="marked0"><a
563
- name="line315"></a>315 code = &lt;&lt;-code </span><span
564
- class="inferred1"><a name="line316"></a>316 def #{plural}(a = nil)
565
- </span><span class="inferred0"><a name="line317"></a>317 if a.nil?
566
- </span><span class="inferred1"><a name="line318"></a>318
567
- @properties[&quot;#{property}&quot;] || [] </span><span class="inferred0"><a
568
- name="line319"></a>319 else </span><span class="inferred1"><a
569
- name="line320"></a>320 self.#{plural}=(a) </span><span class="inferred0"><a
570
- name="line321"></a>321 end </span><span class="inferred1"><a
571
- name="line322"></a>322 end </span><span class="inferred0"><a
572
- name="line323"></a>323 code </span><span class="inferred1"><a
573
- name="line324"></a>324 </span><span class="marked0"><a
574
- name="line325"></a>325 class_eval code, &quot;component.rb&quot;, 186
575
- </span><span class="inferred1"><a name="line326"></a>326 end </span><span
576
- class="inferred0"><a name="line327"></a>327 end </span><span
577
- class="inferred1"><a name="line328"></a>328 </span><span class="marked0"><a
578
- name="line329"></a>329 def Component.generate_multi_setter(property, plural)
579
- </span><span class="inferred1"><a name="line330"></a>330 # Setter for whole
580
- array </span><span class="marked0"><a name="line331"></a>331 unless
581
- instance_methods.include? plural+'+' </span><span class="marked1"><a
582
- name="line332"></a>332 code = &lt;&lt;-code </span><span
583
- class="inferred0"><a name="line333"></a>333 def #{plural}=(a) </span><span
584
- class="inferred1"><a name="line334"></a>334 if a.respond_to?(:to_ary)
585
- </span><span class="inferred0"><a name="line335"></a>335 a.to_ary.each do
586
- |val| </span><span class="inferred1"><a name="line336"></a>336 unless
587
- val.respond_to?(:to_ical) </span><span class="inferred0"><a
588
- name="line337"></a>337 raise(NotImplementedError, &quot;Property values do
589
- not support to_ical method!&quot;) </span><span class="inferred1"><a
590
- name="line338"></a>338 end </span><span class="inferred0"><a
591
- name="line339"></a>339 end </span><span class="inferred1"><a
592
- name="line340"></a>340 </span><span class="inferred0"><a
593
- name="line341"></a>341 @properties[&quot;#{property}&quot;] = a.to_ary
594
- </span><span class="inferred1"><a name="line342"></a>342 else </span><span
595
- class="inferred0"><a name="line343"></a>343 raise ArgumentError,
596
- &quot;#{plural} is a multi-property that must be an array! Use the
597
- add_[property] method to add single entries.&quot; </span><span
598
- class="inferred1"><a name="line344"></a>344 end </span><span
599
- class="inferred0"><a name="line345"></a>345 end </span><span
600
- class="inferred1"><a name="line346"></a>346 code </span><span
601
- class="inferred0"><a name="line347"></a>347 </span><span class="marked1"><a
602
- name="line348"></a>348 class_eval code, &quot;component.rb&quot;, 198
603
- </span><span class="inferred0"><a name="line349"></a>349 end </span><span
604
- class="inferred1"><a name="line350"></a>350 end </span><span
605
- class="inferred0"><a name="line351"></a>351 </span><span class="marked1"><a
606
- name="line352"></a>352 def Component.generate_multi_query(property, plural)
607
- </span><span class="inferred0"><a name="line353"></a>353 # Query for any of
608
- these properties </span><span class="marked1"><a name="line354"></a>354
609
- unless instance_methods.include? plural+'?' </span><span class="marked0"><a
610
- name="line355"></a>355 code = &lt;&lt;-code </span><span
611
- class="inferred1"><a name="line356"></a>356 def #{plural}? </span><span
612
- class="inferred0"><a name="line357"></a>357
613
- @properties.has_key?(&quot;#{property}&quot;) </span><span
614
- class="inferred1"><a name="line358"></a>358 end </span><span
615
- class="inferred0"><a name="line359"></a>359 code </span><span
616
- class="inferred1"><a name="line360"></a>360 </span><span class="marked0"><a
617
- name="line361"></a>361 class_eval code, &quot;component.rb&quot;, 210
618
- </span><span class="inferred1"><a name="line362"></a>362 end </span><span
619
- class="inferred0"><a name="line363"></a>363 end </span><span
620
- class="inferred1"><a name="line364"></a>364 </span><span class="marked0"><a
621
- name="line365"></a>365 def Component.generate_multi_adder(property,
622
- singular) </span><span class="marked1"><a name="line366"></a>366 adder =
623
- &quot;add_&quot;+singular.to_s </span><span class="inferred0"><a
624
- name="line367"></a>367 # Add another item to this properties array
625
- </span><span class="marked1"><a name="line368"></a>368 unless
626
- instance_methods.include? adder </span><span class="marked0"><a
627
- name="line369"></a>369 code = &lt;&lt;-code </span><span
628
- class="inferred1"><a name="line370"></a>370 def #{adder}(val, params = {})
629
- </span><span class="inferred0"><a name="line371"></a>371 unless
630
- val.respond_to?(:to_ical) </span><span class="inferred1"><a
631
- name="line372"></a>372 raise(NotImplementedError, &quot;Property value
632
- object does not support to_ical method!&quot;) </span><span
633
- class="inferred0"><a name="line373"></a>373 end </span><span
634
- class="inferred1"><a name="line374"></a>374 </span><span
635
- class="inferred0"><a name="line375"></a>375 unless params.nil? </span><span
636
- class="inferred1"><a name="line376"></a>376 # Extend with the parameter
637
- methods only if we have to... </span><span class="inferred0"><a
638
- name="line377"></a>377 unless val.respond_to?(:ical_params) </span><span
639
- class="inferred1"><a name="line378"></a>378 val.class.class_eval {
640
- attr_accessor :ical_params } </span><span class="inferred0"><a
641
- name="line379"></a>379 end </span><span class="inferred1"><a
642
- name="line380"></a>380 val.ical_params = params </span><span
643
- class="inferred0"><a name="line381"></a>381 end </span><span
644
- class="inferred1"><a name="line382"></a>382 </span><span
645
- class="inferred0"><a name="line383"></a>383 if
646
- @properties.has_key?(&quot;#{property}&quot;) </span><span
647
- class="inferred1"><a name="line384"></a>384
648
- @properties[&quot;#{property}&quot;] &lt;&lt; val </span><span
649
- class="inferred0"><a name="line385"></a>385 else </span><span
650
- class="inferred1"><a name="line386"></a>386
651
- @properties[&quot;#{property}&quot;] = [val] </span><span
652
- class="inferred0"><a name="line387"></a>387 end </span><span
653
- class="inferred1"><a name="line388"></a>388 end </span><span
654
- class="inferred0"><a name="line389"></a>389 code </span><span
655
- class="inferred1"><a name="line390"></a>390 </span><span class="marked0"><a
656
- name="line391"></a>391 class_eval code, &quot;component.rb&quot;, 289
657
- </span><span class="marked1"><a name="line392"></a>392
658
- alias_method(&quot;add_#{property.downcase}&quot;, &quot;#{adder}&quot;)
659
- </span><span class="inferred0"><a name="line393"></a>393 end </span><span
660
- class="inferred1"><a name="line394"></a>394 end </span><span
661
- class="inferred0"><a name="line395"></a>395 </span><span class="marked1"><a
662
- name="line396"></a>396 def Component.generate_multi_remover(property,
663
- singular) </span><span class="inferred0"><a name="line397"></a>397 # Remove
664
- an item from this properties array </span><span class="marked1"><a
665
- name="line398"></a>398 unless instance_methods.include?
666
- &quot;remove_#{singular}&quot; </span><span class="marked0"><a
667
- name="line399"></a>399 code = &lt;&lt;-code </span><span
668
- class="inferred1"><a name="line400"></a>400 def remove_#{singular}(a)
669
- </span><span class="inferred0"><a name="line401"></a>401 if
670
- @properties.has_key?(&quot;#{property}&quot;) </span><span
671
- class="inferred1"><a name="line402"></a>402
672
- @properties[&quot;#{property}&quot;].delete(a) </span><span
673
- class="inferred0"><a name="line403"></a>403 end </span><span
674
- class="inferred1"><a name="line404"></a>404 end </span><span
675
- class="inferred0"><a name="line405"></a>405 code </span><span
676
- class="inferred1"><a name="line406"></a>406 </span><span class="marked0"><a
677
- name="line407"></a>407 class_eval code, &quot;component.rb&quot;, 303
678
- </span><span class="marked1"><a name="line408"></a>408
679
- alias_method(&quot;remove_#{property.downcase}&quot;,
680
- &quot;remove_#{singular}&quot;) </span><span class="inferred0"><a
681
- name="line409"></a>409 end </span><span class="inferred1"><a
682
- name="line410"></a>410 end </span><span class="inferred0"><a
683
- name="line411"></a>411 </span><span class="marked1"><a
684
- name="line412"></a>412 def method_missing(method_name, *args) </span><span
685
- class="marked0"><a name="line413"></a>413 @@logger.debug(&quot;Inside
686
- method_missing...&quot;) </span><span class="marked1"><a
687
- name="line414"></a>414 method_name = method_name.to_s.downcase </span><span
688
- class="inferred0"><a name="line415"></a>415 </span><span class="marked1"><a
689
- name="line416"></a>416 unless method_name =~ /x_.*/ </span><span
690
- class="inferred0"><a name="line417"></a>417 raise NoMethodError,
691
- &quot;Method Name: #{method_name}&quot; </span><span class="inferred1"><a
692
- name="line418"></a>418 end </span><span class="inferred0"><a
693
- name="line419"></a>419 </span><span class="inferred1"><a
694
- name="line420"></a>420 # x-properties are accessed with underscore but
695
- stored with a dash so </span><span class="inferred0"><a
696
- name="line421"></a>421 # they output correctly and we don't have to special
697
- case the </span><span class="inferred1"><a name="line422"></a>422 # output
698
- code, which would require checking every property. </span><span
699
- class="marked0"><a name="line423"></a>423 if args.size &gt; 0 # Its a setter
700
- </span><span class="inferred1"><a name="line424"></a>424 # Pull off the
701
- possible equals </span><span class="marked0"><a name="line425"></a>425
702
- @properties[method_name[/x_[^=]*/].gsub('x_', 'x-')] = args.first
703
- </span><span class="inferred1"><a name="line426"></a>426 else # Or its a
704
- getter </span><span class="marked0"><a name="line427"></a>427 return
705
- @properties[method_name.gsub('x_', 'x-')] </span><span class="inferred1"><a
706
- name="line428"></a>428 end </span><span class="inferred0"><a
707
- name="line429"></a>429 end </span><span class="inferred1"><a
708
- name="line430"></a>430 </span><span class="marked0"><a
709
- name="line431"></a>431 public </span><span class="inferred1"><a
710
- name="line432"></a>432 </span><span class="marked0"><a
711
- name="line433"></a>433 def respond_to?(method_name) </span><span
712
- class="marked1"><a name="line434"></a>434 if method_name.to_s.downcase =~
713
- /x_.*/ </span><span class="marked0"><a name="line435"></a>435 true
714
- </span><span class="inferred1"><a name="line436"></a>436 else </span><span
715
- class="marked0"><a name="line437"></a>437 super </span><span
716
- class="inferred1"><a name="line438"></a>438 end </span><span
717
- class="inferred0"><a name="line439"></a>439 end </span><span
718
- class="inferred1"><a name="line440"></a>440 </span><span
719
- class="inferred0"><a name="line441"></a>441 end # class Component
720
- </span><span class="inferred1"><a name="line442"></a>442 end </span></pre>
721
- <hr />
722
- <p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
723
- code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
724
- <p>
725
- <a href='http://validator.w3.org/check/referer'>
726
- <img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
727
- </a>
728
- <a href='http://jigsaw.w3.org/css-validator/check/referer'>
729
- <img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
730
- </a>
731
- </p>
732
- </body>
733
- </html>