rubyredrick-ri_cal 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/History.txt +19 -2
  2. data/Manifest.txt +6 -3
  3. data/README.txt +130 -44
  4. data/Rakefile +1 -1
  5. data/copyrights.txt +1 -2
  6. data/lib/ri_cal/component/alarm.rb +1 -2
  7. data/lib/ri_cal/component/calendar.rb +25 -9
  8. data/lib/ri_cal/component/event.rb +1 -2
  9. data/lib/ri_cal/component/freebusy.rb +1 -2
  10. data/lib/ri_cal/component/journal.rb +1 -2
  11. data/lib/ri_cal/component/t_z_info_timezone.rb +1 -2
  12. data/lib/ri_cal/component/timezone/daylight_period.rb +1 -2
  13. data/lib/ri_cal/component/timezone/standard_period.rb +1 -2
  14. data/lib/ri_cal/component/timezone/timezone_period.rb +1 -2
  15. data/lib/ri_cal/component/timezone.rb +5 -2
  16. data/lib/ri_cal/component.rb +22 -7
  17. data/lib/ri_cal/core_extensions/date/conversions.rb +8 -7
  18. data/lib/ri_cal/core_extensions/date_time.rb +4 -2
  19. data/lib/ri_cal/core_extensions/object/conversions.rb +1 -1
  20. data/lib/ri_cal/core_extensions/string/conversions.rb +37 -6
  21. data/lib/ri_cal/core_extensions/time/conversions.rb +11 -7
  22. data/lib/ri_cal/core_extensions/time/tzid_access.rb +37 -0
  23. data/lib/ri_cal/core_extensions/time.rb +3 -1
  24. data/lib/ri_cal/floating_timezone.rb +32 -0
  25. data/lib/ri_cal/invalid_property_value.rb +8 -0
  26. data/lib/ri_cal/invalid_timezone_identifer.rb +2 -2
  27. data/lib/ri_cal/occurrence_enumerator.rb +5 -3
  28. data/lib/ri_cal/parser.rb +8 -8
  29. data/lib/ri_cal/properties/alarm.rb +8 -8
  30. data/lib/ri_cal/properties/event.rb +60 -60
  31. data/lib/ri_cal/properties/freebusy.rb +16 -16
  32. data/lib/ri_cal/properties/journal.rb +58 -58
  33. data/lib/ri_cal/properties/timezone_period.rb +23 -23
  34. data/lib/ri_cal/properties/todo.rb +63 -64
  35. data/lib/ri_cal/property_value/array.rb +10 -2
  36. data/lib/ri_cal/property_value/cal_address.rb +1 -2
  37. data/lib/ri_cal/property_value/date.rb +15 -3
  38. data/lib/ri_cal/property_value/date_time/additive_methods.rb +34 -33
  39. data/lib/ri_cal/property_value/date_time/time_machine.rb +175 -174
  40. data/lib/ri_cal/property_value/date_time/timezone_support.rb +70 -52
  41. data/lib/ri_cal/property_value/date_time.rb +47 -77
  42. data/lib/ri_cal/property_value/duration.rb +6 -3
  43. data/lib/ri_cal/property_value/geo.rb +1 -2
  44. data/lib/ri_cal/property_value/integer.rb +1 -2
  45. data/lib/ri_cal/property_value/occurrence_list.rb +79 -26
  46. data/lib/ri_cal/property_value/period.rb +23 -3
  47. data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +1 -2
  48. data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +1 -2
  49. data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +1 -2
  50. data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +1 -2
  51. data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +1 -2
  52. data/lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb +1 -2
  53. data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +1 -2
  54. data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +1 -2
  55. data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +1 -2
  56. data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +1 -2
  57. data/lib/ri_cal/property_value/recurrence_rule/validations.rb +1 -2
  58. data/lib/ri_cal/property_value/recurrence_rule.rb +3 -4
  59. data/lib/ri_cal/property_value/text.rb +1 -2
  60. data/lib/ri_cal/property_value/uri.rb +1 -2
  61. data/lib/ri_cal/property_value/utc_offset.rb +1 -2
  62. data/lib/ri_cal/property_value.rb +42 -11
  63. data/lib/ri_cal/required_timezones.rb +1 -2
  64. data/lib/ri_cal.rb +1 -2
  65. data/ri_cal.gemspec +6 -4
  66. data/spec/ri_cal/component/alarm_spec.rb +1 -2
  67. data/spec/ri_cal/component/calendar_spec.rb +1 -2
  68. data/spec/ri_cal/component/event_spec.rb +168 -13
  69. data/spec/ri_cal/component/freebusy_spec.rb +1 -2
  70. data/spec/ri_cal/component/journal_spec.rb +1 -2
  71. data/spec/ri_cal/component/t_z_info_timezone_spec.rb +1 -2
  72. data/spec/ri_cal/component/timezone_spec.rb +1 -2
  73. data/spec/ri_cal/component/todo_spec.rb +4 -5
  74. data/spec/ri_cal/component_spec.rb +30 -18
  75. data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
  76. data/spec/ri_cal/core_extensions/time/calculations_spec.rb +1 -2
  77. data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +1 -2
  78. data/spec/ri_cal/occurrence_enumerator_spec.rb +23 -2
  79. data/spec/ri_cal/parser_spec.rb +6 -7
  80. data/spec/ri_cal/property_value/date_spec.rb +1 -2
  81. data/spec/ri_cal/property_value/date_time_spec.rb +54 -119
  82. data/spec/ri_cal/property_value/duration_spec.rb +12 -2
  83. data/spec/ri_cal/property_value/occurrence_list_spec.rb +67 -0
  84. data/spec/ri_cal/property_value/period_spec.rb +1 -2
  85. data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +1 -2
  86. data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1 -2
  87. data/spec/ri_cal/property_value/text_spec.rb +1 -2
  88. data/spec/ri_cal/property_value/utc_offset_spec.rb +1 -2
  89. data/spec/ri_cal/property_value_spec.rb +19 -8
  90. data/spec/ri_cal/required_timezones_spec.rb +1 -2
  91. data/spec/ri_cal_spec.rb +1 -2
  92. data/spec/spec_helper.rb +2 -7
  93. data/tasks/ri_cal.rake +20 -13
  94. data/tasks/spec.rake +1 -1
  95. metadata +8 -5
  96. data/lib/ri_cal/core_extensions/date_time/conversions.rb +0 -27
  97. data/lib/ri_cal/time_with_floating_timezone.rb +0 -59
data/tasks/ri_cal.rake CHANGED
@@ -1,7 +1,6 @@
1
1
  #require 'active_support'
2
2
  require 'yaml'
3
- #- ©2009 Rick DeNatale
4
- #- All rights reserved. Refer to the file README.txt for the license
3
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
5
4
  #
6
5
  # code stolen from ActiveSupport Gem
7
6
  unless String.instance_methods.include?("camelize")
@@ -166,6 +165,14 @@ class VEntityUpdater
166
165
  else
167
166
  line_evaluator = "#{type_class(type)}.new(self, line)"
168
167
  end
168
+
169
+ if %w{Array, OccurrenceList}.include?(type)
170
+ ruby_val_parm = "*ruby_value"
171
+ val_parm = "*val"
172
+ else
173
+ ruby_val_parm = "ruby_value"
174
+ val_parm = "val"
175
+ end
169
176
  blank_line
170
177
  if multi
171
178
  comment(
@@ -192,45 +199,45 @@ class VEntityUpdater
192
199
  blank_line
193
200
  comment("set the value of the #{name.upcase} property to multiple values")
194
201
  comment("one or more instances of #{describe_type(type)} may be passed to this method")
195
- indent("def #{plural_ruby_method}=(*ruby_values)")
196
- indent(" @#{property} = ruby_values.map {|val| #{type_class(type)}.convert(self, val)}")
202
+ indent("def #{plural_ruby_method}=(ruby_values)")
203
+ indent(" @#{property} = ruby_values.map {|val| #{type_class(type)}.convert(self, #{val_parm})}")
197
204
  indent("end")
198
205
  blank_line
199
206
  comment("set the value of the #{name.upcase} property to a single value")
200
207
  comment("one instance of #{describe_type(type)} may be passed to this method")
201
- indent("def #{ruby_method}=(ruby_value)")
202
- indent(" @#{property} = [#{type_class(type)}.convert(self, ruby_value)]")
208
+ indent("def #{ruby_method}=(#{ruby_val_parm})")
209
+ indent(" @#{property} = [#{type_class(type)}.convert(self, #{ruby_val_parm})]")
203
210
  indent("end")
204
211
  blank_line
205
212
  comment("add one or more values to the #{name.upcase} property")
206
213
  comment("one or more instances of #{describe_type(type)} may be passed to this method")
207
214
  indent("def add_#{plural_ruby_method}(*ruby_values)")
208
- indent(" ruby_values.do {|val| self.#{property} << #{type_class(type)}.convert(self, val)}")
215
+ indent(" ruby_values.each {|val| self.#{property} << #{type_class(type)}.convert(self, #{val_parm})}")
209
216
  indent("end")
210
217
  blank_line
211
218
  comment("add one value to the #{name.upcase} property")
212
219
  comment("one instances of #{describe_type(type)} may be passed to this method")
213
- indent("def add_#{ruby_method}(ruby_value)")
214
- indent(" self.#{property} << #{type_class(type)}.convert(self, ruby_value)")
220
+ indent("def add_#{ruby_method}(#{ruby_val_parm})")
221
+ indent(" self.#{property} << #{type_class(type)}.convert(self, #{ruby_val_parm})")
215
222
  indent("end")
216
223
  blank_line
217
224
  comment("remove one or more values from the #{name.upcase} property")
218
225
  comment("one or more instances of #{describe_type(type)} may be passed to this method")
219
226
  indent("def remove_#{plural_ruby_method}(*ruby_values)")
220
- indent(" ruby_values.do {|val| self.#{property}.delete(#{type_class(type)}.convert(self, val))}")
227
+ indent(" ruby_values.each {|val| self.#{property}.delete(#{type_class(type)}.convert(self, #{val_parm}))}")
221
228
  indent("end")
222
229
  blank_line
223
230
  comment("remove one value from the #{name.upcase} property")
224
231
  comment("one instances of #{describe_type(type)} may be passed to this method")
225
- indent("def remove_#{ruby_method}(ruby_value)")
226
- indent(" self.#{property}.delete(#{type_class(type)}.convert(self, ruby_value))")
232
+ indent("def remove_#{ruby_method}(#{ruby_val_parm})")
233
+ indent(" self.#{property}.delete(#{type_class(type)}.convert(self, #{ruby_val_parm}))")
227
234
  indent("end")
228
235
  end
229
236
  blank_line
230
237
  comment("return the value of the #{name.upcase} property")
231
238
  comment("which will be an array of instances of #{describe_type(type)}")
232
239
  indent("def #{ruby_method}")
233
- indent(" #{property}.map {|prop| prop ? prop.value : prop}")
240
+ indent(" #{property}.map {|prop| prop ? prop.ruby_value : prop}")
234
241
  indent("end")
235
242
  blank_line
236
243
  no_doc("def #{property}_from_string(line)")
data/tasks/spec.rake CHANGED
@@ -14,7 +14,7 @@ EOS
14
14
  exit(0)
15
15
  end
16
16
 
17
- desc "Run the specs under spec/models"
17
+ desc "Run all specs"
18
18
  Spec::Rake::SpecTask.new do |t|
19
19
  t.spec_opts = ['--options', "spec/spec.opts"]
20
20
  t.spec_files = FileList['spec/**/*_spec.rb']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyredrick-ri_cal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - author=Rick DeNatale
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-06 00:00:00 -07:00
12
+ date: 2009-05-14 00:00:00 -07:00
13
13
  default_executable: ri_cal
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.8.0
34
34
  version:
35
- description: This is an UNOFFICIAL version. The public official version will be released on RubyForge. Github will be used for interim versions. USE THIS VERSION AT YOUR OWN RISK. A new Ruby implementation of RFC2445 iCalendar. The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide for parsing and generating icalendar files, but do not support important things like enumerating occurrences of repeating events. This is a clean-slate implementation of RFC2445.
35
+ description: This is an UNOFFICIAL version. The public official version will be released on RubyForge. Github will be used for interim versions. USE THIS VERSION AT YOUR OWN RISK. A new Ruby implementation of RFC2445 iCalendar. The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide for parsing and generating icalendar files, but do not support important things like enumerating occurrences of repeating events. This is a clean-slate implementation of RFC2445. A Google group for discussion of this library has been set up http://groups.google.com/group/rical_gem
36
36
  email:
37
37
  - rick.denatale@gmail.com
38
38
  executables:
@@ -86,7 +86,6 @@ files:
86
86
  - lib/ri_cal/core_extensions/date.rb
87
87
  - lib/ri_cal/core_extensions/date/conversions.rb
88
88
  - lib/ri_cal/core_extensions/date_time.rb
89
- - lib/ri_cal/core_extensions/date_time/conversions.rb
90
89
  - lib/ri_cal/core_extensions/object.rb
91
90
  - lib/ri_cal/core_extensions/object/conversions.rb
92
91
  - lib/ri_cal/core_extensions/string.rb
@@ -94,7 +93,10 @@ files:
94
93
  - lib/ri_cal/core_extensions/time.rb
95
94
  - lib/ri_cal/core_extensions/time/calculations.rb
96
95
  - lib/ri_cal/core_extensions/time/conversions.rb
96
+ - lib/ri_cal/core_extensions/time/tzid_access.rb
97
97
  - lib/ri_cal/core_extensions/time/week_day_predicates.rb
98
+ - lib/ri_cal/floating_timezone.rb
99
+ - lib/ri_cal/invalid_property_value.rb
98
100
  - lib/ri_cal/invalid_timezone_identifer.rb
99
101
  - lib/ri_cal/occurrence_enumerator.rb
100
102
  - lib/ri_cal/parser.rb
@@ -135,7 +137,6 @@ files:
135
137
  - lib/ri_cal/property_value/uri.rb
136
138
  - lib/ri_cal/property_value/utc_offset.rb
137
139
  - lib/ri_cal/required_timezones.rb
138
- - lib/ri_cal/time_with_floating_timezone.rb
139
140
  - ri_cal.gemspec
140
141
  - sample_ical_files/from_ical_dot_app/test1.ics
141
142
  - script/console
@@ -151,6 +152,7 @@ files:
151
152
  - spec/ri_cal/component/timezone_spec.rb
152
153
  - spec/ri_cal/component/todo_spec.rb
153
154
  - spec/ri_cal/component_spec.rb
155
+ - spec/ri_cal/core_extensions/string/conversions_spec.rb
154
156
  - spec/ri_cal/core_extensions/time/calculations_spec.rb
155
157
  - spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb
156
158
  - spec/ri_cal/occurrence_enumerator_spec.rb
@@ -158,6 +160,7 @@ files:
158
160
  - spec/ri_cal/property_value/date_spec.rb
159
161
  - spec/ri_cal/property_value/date_time_spec.rb
160
162
  - spec/ri_cal/property_value/duration_spec.rb
163
+ - spec/ri_cal/property_value/occurrence_list_spec.rb
161
164
  - spec/ri_cal/property_value/period_spec.rb
162
165
  - spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb
163
166
  - spec/ri_cal/property_value/recurrence_rule_spec.rb
@@ -1,27 +0,0 @@
1
- module RiCal
2
- module CoreExtensions #:nodoc:
3
- module DateTime #:nodoc:
4
- #- ©2009 Rick DeNatale
5
- #- All rights reserved. Refer to the file README.txt for the license
6
- #
7
- module Conversions
8
- # Return an RiCal::PropertyValue::DateTime representing the receiver
9
- def to_ri_cal_date_time_value
10
- RiCal::PropertyValue::DateTime.from_time(self)
11
- end
12
-
13
- alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_time_value
14
-
15
- # Return the natural ri_cal_property for this object
16
- def to_ri_cal_property_value
17
- to_ri_cal_date_time_value
18
- end
19
-
20
- # Return a proxy to this object which will be interpreted as a floating time.
21
- def with_floating_timezone
22
- RiCal::TimeWithFloatingTimezone.new(self)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,59 +0,0 @@
1
- module RiCal
2
- #- ©2009 Rick DeNatale
3
- #- All rights reserved. Refer to the file README.txt for the license
4
- #
5
- # FloatingTimezone represents the 'time zone' for a time or date time with no timezone
6
- # Times with floating timezones are always interpreted in the timezone of the observer
7
- class FloatingTimezone
8
-
9
- def self.identifier #:nodoc:
10
- nil
11
- end
12
-
13
- def self.tzinfo_timezone #:nodoc:
14
- nil
15
- end
16
-
17
- # Return the time unchanged #:nodoc:
18
- def self.utc_to_local(time)
19
- time.with_floating_timezone.to_ri_cal_date_time_value
20
- end
21
-
22
- # Return the time unchanged #:nodoc:
23
- def self.local_to_utc(time)
24
- time.with_floating_timezone.to_ri_cal_date_time_value
25
- end
26
- end
27
-
28
- class TimeWithFloatingTimezone #:nodoc:
29
- def initialize(time) #:nodoc:
30
- @time = time
31
- end
32
-
33
- def acts_like_time? #:nodoc:
34
- true
35
- end
36
-
37
- def time_zone
38
- FloatingTimezone #:nodoc:
39
- end
40
-
41
- def strftime(format) #:nodoc:
42
- @time.strftime(format)
43
- end
44
-
45
- def with_floating_timezone #:nodoc:
46
- self
47
- end
48
-
49
- def to_ri_cal_date_time_value #:nodoc:
50
- ::RiCal::PropertyValue::DateTime.new(nil, :value => @time, :params => {'TZID' => nil})
51
- end
52
-
53
- alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_time_value #:nodoc:
54
-
55
- def method_missing(selector, *args) #:nodoc:
56
- @time.send(selector, *args)
57
- end
58
- end
59
- end