Socket
Book a DemoInstallSign in
Socket

ice_cube_cron

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ice_cube_cron

bundlerRubygems
Version
1.3.0
Version published
Maintainers
1
Created
Source

Gem Version Build Status Code Climate Test Coverage

ice_cube_cron

Adds new methods to ice_cube to create schedules using standard cron expressions.

description

ice_cube is a sold library for projecting and querying recurrence rules. Cron is the standard for expressing recurrence rules. This gem will allow you to generate ice_cube schedules using standard cron expressions explained here. This includes range expressions, series expressions, "last" day of month, Nth weekday of month, etc.

installation

gem install ice_cube_cron

or add to Gemfile

gem "ice_cube_cron"

example

 # * * * * * *  command to execute
 # │ │ │ │ │ │
 # │ │ │ │ │ │
 # │ │ │ │ │ └───── year (optional) (1970–2099)
 # │ │ │ │ └───── day of week (0 - 6)
 # │ │ │ └────────── month (1 - 12)
 # │ │ └─────────────── day of month (1 - 31)
 # │ └──────────────────── hour (0 - 23)
 # └───────────────────────── min (0 - 59)

chart source

Cron expression can be specified using a hash or a string in the format:

require 'ice_cube_cron'

# using cron expression string
schedule = ::IceCube::Schedule.from_cron(::Date.current, "0 0 * * 5")

# using hash
schedule = ::IceCube::Schedule.from_cron(::Date.new(2015, 1, 5), :hour => 0, :minute => 0, :day_of_month => 5)

schedule.occurrences_between(::Date.new(2015, 3, 5), ::Date.new(2015, 6, 5))
# => [2015-03-05 00:00:00 UTC, 2015-04-05 00:00:00 UTC, 2015-05-05 00:00:00 UTC, 2015-06-05 00:00:00 UTC]

recurrence rule examples

  • These are Date Only - hour and minute are set to zero
descintervalyearmonthday_of_monthday_of_week
1st of every month1
1st and 15th of every month1,15
every monday1
1st tuesday of every month2#1
ever other friday25
every 6 months on the 5th65
last friday of every month5L
last day every monthL

notes

  • Does not validate cron expressions

todo

  • Add support for W special character
  • Change hash param day to day_of_month
  • Improve expression validation

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.