
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
This is an add-on to the iCalendar Gem. It helps to handle calendars in iCalendar format with repeating events.
According to the RFC 5545 specification, repeating events are represented by one single entry, the repetitions being shown by an attached repeat rule. Thus when we iterate through a calendar with, for example, a daily repeating event, we'll only see one single entry in the Calendar. Although, for a whole month there would be 30 or 31 events in reality.
The icalendar-rrule gem patches an additional function called scan
into the iCalendar Gem.
The scan shows all events by unrolling the repeat rule for a
given time period.
Add this line to your application's Gemfile:
gem 'icalendar-rrule'
and run bundle install
from your shell.
For explanations on how to parse and process RFC 5545 compatible calendars, please have a look at the iCalendar gem.
To use this gem we'll first have to require it:
require 'icalendar-rrule'
Further we have to declare the use of the "Scannable" namespace. This is called a "Refinement", a new Ruby core feature since Ruby 2.0, that makes "monkey patching" a bit more acceptable.
using Icalendar::Scannable
Now we can inquire a calendar for all events (or tasks) within in a time span.
scan = calendar.scan(begin_time, closing_time)
Here is a simple example:
require 'icalendar-rrule' # this will require all needed GEMS including the icalendar gem
using Icalendar::Scannable # this will make the function Icalendar::Calendar.scan available
# we create a calendar with one single event
calendar = Icalendar::Calendar.new
calendar.event do |e|
# the event starts on January first and lasts from half past eight to five o' clock
e.dtstart = DateTime.civil(2018, 1, 1, 8, 30)
e.dtend = DateTime.civil(2018, 1, 1, 17, 00)
e.summary = 'Working'
# the event repeats all working days
e.rrule = 'FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR'
end
begin_time = Date.new(2018, 4, 22)
closing_time = Date.new(2018, 4, 29)
# we are interested in the calendar entries in the last week of April
scan = calendar.scan(begin_time, closing_time) # that's where the magic happens
scan.each do |occurrence|
puts "#{occurrence.start_time.strftime('%a. %b. %d. %k:%M')}-#{occurrence.end_time.strftime('%k:%M')}"
end
This will produce:
Mon. Apr. 23. 8:30-17:00
Tue. Apr. 24. 8:30-17:00
Wed. Apr. 25. 8:30-17:00
Thu. Apr. 26. 8:30-17:00
Fri. Apr. 27. 8:30-17:00
For a more elaborate example, please have a look at https://github.com/free-creations/sk_calendar
Bug reports and pull requests are welcome on GitHub at https://github.com/free-creations/icalendar-rrule.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that icalendar-rrule demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.