icalendar / icalendar

icalendar.rb main repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when setting timezones with frozen strings

CHTJonas opened this issue Β· comments

Hi πŸ‘‹ love the gem! However using with the # frozen_string_literal: true magic comment raises a FrozenError on runtime. For clarity the following seems to reproduce the issue with a modern Ruby version eg. 2.6.1:

cal = Icalendar::Calendar.new
cal.timezone do |t|
  t.tzid = 'Europe/London'.freeze
  t.daylight do |d|
    d.tzoffsetfrom = '+0000'.freeze
    d.tzoffsetto   = '+0100'.freeze
    d.tzname       = 'BST'.freeze
    d.dtstart      = '19810329T010000'.freeze
    d.rrule        = 'FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU'.freeze
  end
  t.standard do |s|
    s.tzoffsetfrom = '+0100'.freeze
    s.tzoffsetto   = '+0000'.freeze
    s.tzname       = 'GMT'.freeze
    s.dtstart      = '19961027T020000'.freeze
    s.rrule        = 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU'.freeze
  end
end

This is the line of code that appears to be the issue (there could be others - I haven't done much digging):

value.gsub!(/\s+/, '')

@CHTJonas I believe this has been fixed on master now. I'd love if you could give it a test if you're still using the gem.

@rahearn thank so much for that - seems to be working nicely now! πŸ˜„

Is there any chance of a release with this included? πŸš€

2.6.0 released including this.