
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.
Hiccup mixes a-la-cart recurrence features into your recurring model. It doesn't dictate the data structure of your model, just the interface. It works like Devise does for authenticatable models.
Hiccup does provide a lightweight Schedule
class that mixes in all of Hiccup's feature, but you don't have to use Hiccup's Schedule if you don't want to.
class Schedule
extend Hiccup
hiccup :enumerable,
:validatable,
:humanizable,
:inferable,
:serializable => [:ical]
end
Hiccup requires that a recurring object expose the following properties
:never
, :weekly
, :monthly
, :annually
true
or false
, indicating whether the recurrence has an end dateskip
to 2 to specify an event that occurs every other week, for example)# Every other Monday
Schedule.new(:kind => :weekly, :weekly_pattern => ["Monday"])
# Every year on June 21 (starting in 1999)
Schedule.new(:kind => :yearly, :start_date => Date.new(1999, 6, 21))
# The second and fourth Sundays of the month
Schedule.new(:kind => :monthly, :monthly_pattern => [[2, "Sunday"], [4, "Sunday"]])
Supplies methods for creating instances of a recurring pattern
Examples
schedule = Schedule.new(
:kind => :weekly,
:weekly_pattern => %w{Monday Wednesday Friday},
:start_date => Date.new(2009, 3, 15))
# includes?
schedule.includes? Date.new(2009, 5, 20) # => true
schedule.includes? Date.new(2009, 3, 15) # => false (3/15/09 is a Sunday)
# occurrences_between
schedule.occurrences_between(
Date.new(2009, 3, 26),
Date.new(2009, 3, 31)) #=> [Fri, 27 Mar 2009, Mon, 30 Mar 2009]
# n_occurrences_before
schedule.n_occurrences_before(3, Date.new(2009, 3, 31)) # => [Mon, 30 Mar 2009, Fri, 27 Mar 2009, Wed, 25 Mar 2009]
Mixes in ActiveModel validations for recurrence models
Represents a recurring pattern in a human-readable string
Examples:
# A monthly recurrence
schedule = Schedule.new(:kind => :monthly, :monthly_pattern => [[-1, "Tuesday"]])
schedule.humanize # => "The last Tuesday of every month"
# With skips
schedule = Schedule.new(:kind => :weekly, :weekly_pattern => %w[Sunday], :skip => 2)
schedule.humanize # => "Every other Sunday"
# An anniversary
schedule = Schedule.new(:kind => :annually, start_date: Date.new(2012, 10, 1))
schedule.humanize # => "Every year on October 1"
Infers a schedule from an array of dates
Examples:
schedule = Schedule.infer %w{2012-7-9 2012-8-13 2012-9-10}
schedule.humanize # => "The second Monday of every month"
schedule = Schedule.infer %w{2010-3-4 2011-3-4 2012-3-4}
schedule.humanize # => "Every year on March 4"
schedule = Schedule.infer %w{2012-3-6 2012-3-8 2012-3-15 2012-3-20 2012-3-27 2012-3-29}
schedule.humanize # => "Every Tuesday and Thursday"
Supports serializing and deserializing a recurrence pattern to an array of formats
Examples:
schedule = Schedule.from_ical <<-ICAL
DTSTART;VALUE=DATE-TIME:20090101T000000Z
RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH
ICAL
schedule.humanize # => "Tuesday and Thursday of every other week"
schedule = Schedule.new(
:kind => :weekly,
:weekly_pattern => %w{Tuesday Thursday},
:start_date => DateTime.new(2009, 1, 1),
:skip => 2)
schedule.to_ical # => "DTSTART;VALUE=DATE-TIME:20090101T000000Z\nRRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH\n"
Copyright (c) 2012 Bob Lail, released under the MIT license
FAQs
Unknown package
We found that hiccup 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.