FUJINAKA Tohru
2007-May-07 00:33 UTC
[iCalendar-devel] [patch] fix a bug in formatting a timezone component to ical
Hi all,
I get a runtime error while parsing an .ics includes timezone information.
It can be reproduced by just parsing and re-iCalize the file
`life.ics'', a
library supplied file found in unit test fixtures directory, like:
---[code begin]---
ical =
Icalendar::parse(open(''/home/trac/ruby/gem/gems/icalendar-0.98/test/fixtures/life.ics''),
true)
print ical.to_ical
---[code end]---
That will output an error report:
---[error report begin]---
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb:52:
warning: multiple values for a block parameter (0 for 1)
from
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component.rb:122
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb:52:
warning: multiple values for a block parameter (0 for 1)
from
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component.rb:122
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component.rb:122:in
`+'': can''t convert Hash into String (TypeError)
---[error report end]---
A solution might be like this:
---[patch begin]---
diff -c
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb.org
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb
***
/home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb.org
Wed May 2 13:45:15 2007
--- /home/trac/ruby/gem/gems/icalendar-0.98/lib/icalendar/component/timezone.rb
Mon May 7 08:40:32 2007
***************
*** 49,58 ****
# Also need a custom to_ical because typically it iterates over an array
# of components.
def to_ical
! print_component do |s|
@components.each_value do |comp|
s << comp.to_ical
end
end
end
--- 49,60 ----
# Also need a custom to_ical because typically it iterates over an array
# of components.
def to_ical
! print_component do
! s = ""
@components.each_value do |comp|
s << comp.to_ical
end
+ s
end
end
---[patch end]---
Regards,
--
FUJINAKA Tohru<tohru at nakarika.com>